pull/32/head
yangyxd 5 years ago
parent 6870876388
commit 37ced84112
  1. 3
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt
  2. 12
      app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt

@ -36,7 +36,6 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(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<BookInfoViewModel>(R.layout.activity_boo
}
}
iv_chapter_top.onClick {
reorder = !reorder;
adapter.reorder = !adapter.reorder;
adapter.notifyDataSetChanged();
}
}

@ -13,16 +13,22 @@ import org.jetbrains.anko.textColorResource
class ChapterListAdapter(context: Context, var callBack: CallBack) :
SimpleRecyclerAdapter<BookChapter>(context, R.layout.item_chapter_list) {
var reorder: Boolean = false; // 是否倒序
override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) {
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)
}
}
}

Loading…
Cancel
Save