From cf88899eb02298f9e274e730d9c45500f2818481 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 27 Sep 2019 08:53:19 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt | 5 +++-- .../io/legado/app/ui/main/bookshelf/BookshelfFragment.kt | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt index 4e0a9e4d8..9e5dd0722 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt @@ -6,6 +6,7 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookGroup import kotlinx.android.synthetic.main.item_book_group.view.* +import org.jetbrains.anko.sdk27.listeners.onClick class BookGroupAdapter(context: Context, val callBack: CallBack) : SimpleRecyclerAdapter(context, R.layout.item_book_group) { @@ -13,11 +14,11 @@ class BookGroupAdapter(context: Context, val callBack: CallBack) : override fun convert(holder: ItemViewHolder, item: BookGroup, payloads: MutableList) { with(holder.itemView) { tv_group.text = item.groupName - tv_group.setOnClickListener { callBack.open(item) } + tv_group.onClick { callBack.onClickGroup(holder.layoutPosition) } } } interface CallBack { - fun open(bookGroup: BookGroup) + fun onClickGroup(position: Int) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index e82bf72c2..0a546e57d 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -94,11 +94,8 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b }) } - override fun open(bookGroup: BookGroup) { - when (bookGroup.groupId) { - -10 -> showGroupInputDialog() - else -> context - } + override fun onClickGroup(position: Int) { + view_pager_bookshelf.setCurrentItem(position, false) } override fun onQueryTextSubmit(query: String?): Boolean {