pull/32/head
kunfei 5 years ago
parent b58d9de224
commit fd054211f5
  1. 16
      app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt
  2. 5
      app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt

@ -2,7 +2,9 @@ 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.Menu
import android.widget.GridLayout import android.widget.GridLayout
import android.widget.PopupMenu
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter 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.android.synthetic.main.item_text.view.*
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import org.jetbrains.anko.sdk27.listeners.onClick 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) : 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) 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) { if (exIndex == holder.layoutPosition) {
iv_status.setImageResource(R.drawable.ic_remove) iv_status.setImageResource(R.drawable.ic_remove)
@ -85,5 +100,6 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
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)
fun editSource(sourceUrl: String)
} }
} }

@ -10,6 +10,7 @@ import io.legado.app.R
import io.legado.app.base.BaseFragment import io.legado.app.base.BaseFragment
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.ui.explore.ExploreShowActivity import io.legado.app.ui.explore.ExploreShowActivity
import io.legado.app.ui.sourceedit.SourceEditActivity
import io.legado.app.utils.startActivity import io.legado.app.utils.startActivity
import kotlinx.android.synthetic.main.fragment_find_book.* import kotlinx.android.synthetic.main.fragment_find_book.*
import kotlinx.android.synthetic.main.view_title_bar.* import kotlinx.android.synthetic.main.view_title_bar.*
@ -55,4 +56,8 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book),
Pair("exploreUrl", exploreUrl) Pair("exploreUrl", exploreUrl)
) )
} }
override fun editSource(sourceUrl: String) {
startActivity<SourceEditActivity>(Pair("data", sourceUrl))
}
} }
Loading…
Cancel
Save