diff --git a/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubActivity.kt b/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubActivity.kt index 490d23491..73cab72ca 100644 --- a/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubActivity.kt @@ -12,7 +12,8 @@ import io.legado.app.databinding.ActivitySourceSubBinding import io.legado.app.databinding.DialogSourceSubEditBinding import io.legado.app.lib.dialogs.alert -class SourceSubActivity : BaseActivity() { +class SourceSubActivity : BaseActivity(), + SourceSubAdapter.Callback { private lateinit var adapter: SourceSubAdapter private var liveData: LiveData>? = null @@ -39,7 +40,7 @@ class SourceSubActivity : BaseActivity() { } private fun initView() { - adapter = SourceSubAdapter(this) + adapter = SourceSubAdapter(this, this) binding.recyclerView.adapter = adapter } @@ -51,7 +52,7 @@ class SourceSubActivity : BaseActivity() { } } - private fun editSubscription(sourceSub: SourceSub) { + override fun editSubscription(sourceSub: SourceSub) { alert(R.string.source_subscription) { val alertBinding = DialogSourceSubEditBinding.inflate(layoutInflater).apply { when (sourceSub.type) { @@ -75,5 +76,7 @@ class SourceSubActivity : BaseActivity() { }.show() } + override fun delSubscription(sourceSub: SourceSub) { + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt index d2b98105c..f08b443e7 100644 --- a/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/subscription/SourceSubAdapter.kt @@ -6,8 +6,9 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.SourceSub import io.legado.app.databinding.ItemSourceSubBinding +import org.jetbrains.anko.sdk27.listeners.onClick -class SourceSubAdapter(context: Context) : +class SourceSubAdapter(context: Context, val callBack: Callback) : SimpleRecyclerAdapter(context) { @@ -17,16 +18,24 @@ class SourceSubAdapter(context: Context) : item: SourceSub, payloads: MutableList ) { + binding.tvType.text = SourceSub.Type.values()[item.type].name binding.tvName.text = item.name binding.tvUrl.text = item.url } override fun registerListener(holder: ItemViewHolder, binding: ItemSourceSubBinding) { - + binding.ivEdit.onClick { + callBack.editSubscription(getItem(holder.layoutPosition)!!) + } } override fun getViewBinding(parent: ViewGroup): ItemSourceSubBinding { return ItemSourceSubBinding.inflate(inflater, parent, false) } + interface Callback { + fun editSubscription(sourceSub: SourceSub) + fun delSubscription(sourceSub: SourceSub) + } + } \ No newline at end of file diff --git a/app/src/main/res/layout/item_source_sub.xml b/app/src/main/res/layout/item_source_sub.xml index b64595177..6e65c171e 100644 --- a/app/src/main/res/layout/item_source_sub.xml +++ b/app/src/main/res/layout/item_source_sub.xml @@ -15,6 +15,7 @@ android:textColor="@color/primaryText" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toLeftOf="@id/iv_edit" tools:text="name" /> -