diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt index 1ca198a1e..b1998cfb5 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt @@ -36,7 +36,6 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo private var changeSourceDialog: ChangeSourceDialog? = null private lateinit var adapter: ChapterListAdapter - private var reorder: Boolean = false; // 是否倒序 override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) @@ -205,7 +204,7 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo } } iv_chapter_top.onClick { - reorder = !reorder; + adapter.reorder = !adapter.reorder; adapter.notifyDataSetChanged(); } } diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt index d6851e193..3b2edf158 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt @@ -13,16 +13,22 @@ import org.jetbrains.anko.textColorResource class ChapterListAdapter(context: Context, var callBack: CallBack) : SimpleRecyclerAdapter(context, R.layout.item_chapter_list) { + var reorder: Boolean = false; // 是否倒序 + override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList) { holder.itemView.apply { - tv_chapter_name.text = item.title - if (item.index == callBack.durChapterIndex()) { + var _item: BookChapter = item; + if (reorder) { + _item = getItems().get(getItems().size - item.index - 1); + } + tv_chapter_name.text = _item.title + if (_item.index == callBack.durChapterIndex()) { tv_chapter_name.setTextColor(context.accentColor) } else { tv_chapter_name.textColorResource = R.color.tv_text_secondary } this.onClick { - callBack.openChapter(item) + callBack.openChapter(_item) } } }