|
|
@ -2,6 +2,7 @@ package io.legado.app.ui.main.explore |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.LayoutInflater |
|
|
|
|
|
|
|
import android.view.View |
|
|
|
import android.widget.PopupMenu |
|
|
|
import android.widget.PopupMenu |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
@ -39,24 +40,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca |
|
|
|
callBack.scrollTo(holder.layoutPosition) |
|
|
|
callBack.scrollTo(holder.layoutPosition) |
|
|
|
} |
|
|
|
} |
|
|
|
ll_title.onLongClick { |
|
|
|
ll_title.onLongClick { |
|
|
|
val popupMenu = PopupMenu(context, ll_title) |
|
|
|
showMenu(ll_title, getItem(holder.layoutPosition), holder.layoutPosition) |
|
|
|
popupMenu.inflate(R.menu.explore_item) |
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener { |
|
|
|
|
|
|
|
when (it.itemId) { |
|
|
|
|
|
|
|
R.id.menu_edit -> callBack.editSource(item.bookSourceUrl) |
|
|
|
|
|
|
|
R.id.menu_top -> callBack.toTop(item) |
|
|
|
|
|
|
|
R.id.menu_refresh -> { |
|
|
|
|
|
|
|
ACache.get(context, "explore").remove(item.bookSourceUrl) |
|
|
|
|
|
|
|
notifyItemChanged(holder.layoutPosition) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
R.id.menu_del -> Coroutine.async(scope) { |
|
|
|
|
|
|
|
App.db.bookSourceDao().delete(item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
popupMenu.show() |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (exIndex == holder.layoutPosition) { |
|
|
|
if (exIndex == holder.layoutPosition) { |
|
|
@ -96,6 +80,28 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun showMenu(view: View, source: BookSource?, position: Int): Boolean { |
|
|
|
|
|
|
|
if (source == null) return true |
|
|
|
|
|
|
|
val popupMenu = PopupMenu(context, view) |
|
|
|
|
|
|
|
popupMenu.inflate(R.menu.explore_item) |
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener { |
|
|
|
|
|
|
|
when (it.itemId) { |
|
|
|
|
|
|
|
R.id.menu_edit -> callBack.editSource(source.bookSourceUrl) |
|
|
|
|
|
|
|
R.id.menu_top -> callBack.toTop(source) |
|
|
|
|
|
|
|
R.id.menu_refresh -> { |
|
|
|
|
|
|
|
ACache.get(context, "explore").remove(source.bookSourceUrl) |
|
|
|
|
|
|
|
notifyItemChanged(position) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
R.id.menu_del -> Coroutine.async(scope) { |
|
|
|
|
|
|
|
App.db.bookSourceDao().delete(source) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
popupMenu.show() |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CallBack { |
|
|
|
interface CallBack { |
|
|
|
fun scrollTo(pos: Int) |
|
|
|
fun scrollTo(pos: Int) |
|
|
|
fun openExplore(sourceUrl: String, title: String, exploreUrl: String) |
|
|
|
fun openExplore(sourceUrl: String, title: String, exploreUrl: String) |
|
|
|