From fd054211f5c0f76024f2b218160bce1a43897410 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 Sep 2019 09:24:44 +0800 Subject: [PATCH] up --- .../app/ui/main/explore/FindBookAdapter.kt | 16 ++++++++++++++++ .../app/ui/main/explore/FindBookFragment.kt | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt index 06bc23c1b..c43c4bf6e 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt @@ -2,7 +2,9 @@ package io.legado.app.ui.main.explore import android.content.Context import android.view.LayoutInflater +import android.view.Menu import android.widget.GridLayout +import android.widget.PopupMenu import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter @@ -15,6 +17,7 @@ import kotlinx.android.synthetic.main.item_find_book.view.* import kotlinx.android.synthetic.main.item_text.view.* import kotlinx.coroutines.CoroutineScope import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.sdk27.listeners.onLongClick class FindBookAdapter(context: Context, private val scope: CoroutineScope, val callBack: CallBack) : @@ -35,6 +38,18 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c } callBack.scrollTo(holder.layoutPosition) } + ll_title.onLongClick { + val popupMenu = PopupMenu(context, ll_title) + popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit) + popupMenu.setOnMenuItemClickListener { + when (it.itemId) { + R.id.menu_edit -> callBack.editSource(item.bookSourceUrl) + } + true + } + popupMenu.show() + true + } } if (exIndex == holder.layoutPosition) { iv_status.setImageResource(R.drawable.ic_remove) @@ -85,5 +100,6 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c interface CallBack { fun scrollTo(pos: Int) fun openExplore(sourceUrl: String, title: String, exploreUrl: String) + fun editSource(sourceUrl: String) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt index 4268bb719..cb456d3ff 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt @@ -10,6 +10,7 @@ import io.legado.app.R import io.legado.app.base.BaseFragment import io.legado.app.lib.theme.ATH import io.legado.app.ui.explore.ExploreShowActivity +import io.legado.app.ui.sourceedit.SourceEditActivity import io.legado.app.utils.startActivity import kotlinx.android.synthetic.main.fragment_find_book.* import kotlinx.android.synthetic.main.view_title_bar.* @@ -55,4 +56,8 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book), Pair("exploreUrl", exploreUrl) ) } + + override fun editSource(sourceUrl: String) { + startActivity(Pair("data", sourceUrl)) + } } \ No newline at end of file