添加源地址订阅功能

pull/517/head
gedoor 4 years ago
parent bea16e8667
commit ecc4f2f2df
  1. 16
      app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt

@ -1,7 +1,10 @@
package io.legado.app.ui.rss.subscription package io.legado.app.ui.rss.subscription
import android.content.Context import android.content.Context
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.PopupMenu
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
import io.legado.app.data.entities.SourceSub import io.legado.app.data.entities.SourceSub
@ -31,8 +34,21 @@ class SourceSubAdapter(context: Context, val callBack: Callback) :
callBack.editSubscription(getItem(holder.layoutPosition)!!) callBack.editSubscription(getItem(holder.layoutPosition)!!)
} }
binding.ivMenuMore.onClick { binding.ivMenuMore.onClick {
showMenu(binding.ivMenuMore, holder.layoutPosition)
}
}
private fun showMenu(view: View, position: Int) {
val source = getItem(position) ?: return
val popupMenu = PopupMenu(context, view)
popupMenu.inflate(R.menu.rss_source_item)
popupMenu.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.menu_del -> callBack.delSubscription(source)
}
true
} }
popupMenu.show()
} }
override fun getViewBinding(parent: ViewGroup): ItemSourceSubBinding { override fun getViewBinding(parent: ViewGroup): ItemSourceSubBinding {

Loading…
Cancel
Save