pull/35/head
kunfei 5 years ago
parent 4b846714d0
commit 85902e702e
  1. 24
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookGroupAdapter.kt
  2. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt

@ -1,24 +0,0 @@
package io.legado.app.ui.main.bookshelf
import android.content.Context
import io.legado.app.R
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<BookGroup>(context, R.layout.item_book_group) {
override fun convert(holder: ItemViewHolder, item: BookGroup, payloads: MutableList<Any>) {
with(holder.itemView) {
tv_group.text = item.groupName
tv_group.onClick { callBack.onClickGroup(holder.layoutPosition) }
}
}
interface CallBack {
fun onClickGroup(position: Int)
}
}

@ -28,7 +28,6 @@ import org.jetbrains.anko.startActivity
class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_bookshelf), class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_bookshelf),
SearchView.OnQueryTextListener, SearchView.OnQueryTextListener,
BookGroupAdapter.CallBack,
BookshelfAdapter.CallBack { BookshelfAdapter.CallBack {
override val viewModel: BookshelfViewModel override val viewModel: BookshelfViewModel
@ -84,10 +83,6 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
}) })
} }
override fun onClickGroup(position: Int) {
view_pager_bookshelf.setCurrentItem(position, false)
}
override fun onQueryTextSubmit(query: String?): Boolean { override fun onQueryTextSubmit(query: String?): Boolean {
context?.startActivity<SearchActivity>(Pair("key", query)) context?.startActivity<SearchActivity>(Pair("key", query))
return false return false

Loading…
Cancel
Save