pull/1119/head
gedoor 3 years ago
parent 6e2b264536
commit bb8e76d9de
  1. 6
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  2. 4
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt

@ -155,9 +155,10 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
when (it.itemId) { when (it.itemId) {
R.id.menu_edit -> callBack.editSource(source.bookSourceUrl) R.id.menu_edit -> callBack.editSource(source.bookSourceUrl)
R.id.menu_top -> callBack.toTop(source) R.id.menu_top -> callBack.toTop(source)
R.id.menu_refresh -> { R.id.menu_refresh -> Coroutine.async(scope) {
ACache.get(context, "explore").remove(source.bookSourceUrl) ACache.get(context, "explore").remove(source.bookSourceUrl)
notifyItemChanged(position) }.onSuccess {
callBack.refreshData()
} }
R.id.menu_del -> Coroutine.async(scope) { R.id.menu_del -> Coroutine.async(scope) {
appDb.bookSourceDao.delete(source) appDb.bookSourceDao.delete(source)
@ -170,6 +171,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
} }
interface CallBack { interface CallBack {
fun refreshData()
fun scrollTo(pos: Int) fun scrollTo(pos: Int)
fun openExplore(sourceUrl: String, title: String, exploreUrl: String?) fun openExplore(sourceUrl: String, title: String, exploreUrl: String?)
fun editSource(sourceUrl: String) fun editSource(sourceUrl: String)

@ -150,6 +150,10 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
} }
} }
override fun refreshData() {
initExploreData(searchView.query?.toString())
}
override fun scrollTo(pos: Int) { override fun scrollTo(pos: Int) {
(binding.rvFind.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(pos, 0) (binding.rvFind.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(pos, 0)
} }

Loading…
Cancel
Save