From 29e56b9f2d68594ff313f1f9a2a69d3f3903ace1 Mon Sep 17 00:00:00 2001 From: Samuel Wu Date: Mon, 24 Oct 2022 16:55:12 +1100 Subject: [PATCH] Created a button in SubscriptionFragment.kt that reads whether button is clicked --- .../newpipe/local/subscription/SubscriptionFragment.kt | 5 +++++ .../newpipe/local/subscription/item/HeaderWithMenuItem.kt | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index a804b0ff3..bf4941e8e 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -221,6 +221,10 @@ class SubscriptionFragment : BaseStateFragment() { FeedGroupReorderDialog().show(parentFragmentManager, null) } + private fun temp() { + println("This button is clicked") + } + private fun requestExportResult(result: ActivityResult) { if (result.data != null && result.resultCode == Activity.RESULT_OK) { activity.startService( @@ -271,6 +275,7 @@ class SubscriptionFragment : BaseStateFragment() { getString(R.string.feed_groups_header_title), R.drawable.ic_list, R.drawable.ic_sort, + listViewOnClickListener = ::temp, menuItemOnClickListener = ::openReorderDialog ) add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel))) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderWithMenuItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderWithMenuItem.kt index cb312b023..338083c87 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderWithMenuItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderWithMenuItem.kt @@ -14,7 +14,7 @@ class HeaderWithMenuItem( @DrawableRes val itemIconListView: Int = 0, var showMenuItem: Boolean = true, private val onClickListener: (() -> Unit)? = null, - private val onClickListenerListView: (() -> Unit)? = null, + private val listViewOnClickListener: (() -> Unit)? = null, private val menuItemOnClickListener: (() -> Unit)? = null ) : BindableItem() { companion object { @@ -40,8 +40,8 @@ class HeaderWithMenuItem( val listener = onClickListener?.let { OnClickListener { onClickListener.invoke() } } viewBinding.root.setOnClickListener(listener) - val listenerListView = onClickListenerListView?.let { OnClickListener { onClickListenerListView.invoke() } } - viewBinding.root.setOnClickListener(listenerListView) + val listViewListener = listViewOnClickListener?.let { OnClickListener { listViewOnClickListener.invoke() } } + viewBinding.headerMenuItem2.setOnClickListener(listViewListener) val menuItemListener = menuItemOnClickListener?.let { OnClickListener { menuItemOnClickListener.invoke() } } viewBinding.headerMenuItem.setOnClickListener(menuItemListener)