diff --git a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt index 84fad112c..1fb30b6e5 100644 --- a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt @@ -5,6 +5,7 @@ import android.view.Menu import android.view.View import android.view.ViewGroup import android.widget.PopupMenu +import androidx.paging.PagedList import androidx.paging.PagedListAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView @@ -33,7 +34,7 @@ class BookSourceAdapter : PagedListAdapter() + private val checkedList = HashSet() val itemTouchCallbackListener = object : OnItemTouchCallbackListener { override fun onSwiped(adapterPosition: Int) { @@ -56,6 +57,25 @@ class BookSourceAdapter : PagedListAdapter?, currentList: PagedList?) { + super.onCurrentListChanged(previousList, currentList) + callBack?.upCount(itemCount) + } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_book_source, parent, false)) } @@ -116,6 +136,7 @@ class BookSourceAdapter : PagedListAdapter { context?.startActivity() } + R.id.action_select_all -> adapter.selectAll() } } @@ -98,6 +99,10 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour return false } + override fun upCount(count: Int) { + search_view.queryHint = getString(R.string.search_book_source_num, count) + } + override fun del(bookSource: BookSource) { launch(IO) { App.db.bookSourceDao().delete(bookSource) } }