Created a button in SubscriptionFragment.kt that reads whether button is clicked

This commit is contained in:
Samuel Wu 2022-10-24 16:55:12 +11:00
parent 8482bf9fed
commit 29e56b9f2d
2 changed files with 8 additions and 3 deletions

View file

@ -221,6 +221,10 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
FeedGroupReorderDialog().show(parentFragmentManager, null) FeedGroupReorderDialog().show(parentFragmentManager, null)
} }
private fun temp() {
println("This button is clicked")
}
private fun requestExportResult(result: ActivityResult) { private fun requestExportResult(result: ActivityResult) {
if (result.data != null && result.resultCode == Activity.RESULT_OK) { if (result.data != null && result.resultCode == Activity.RESULT_OK) {
activity.startService( activity.startService(
@ -271,6 +275,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
getString(R.string.feed_groups_header_title), getString(R.string.feed_groups_header_title),
R.drawable.ic_list, R.drawable.ic_list,
R.drawable.ic_sort, R.drawable.ic_sort,
listViewOnClickListener = ::temp,
menuItemOnClickListener = ::openReorderDialog menuItemOnClickListener = ::openReorderDialog
) )
add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel))) add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel)))

View file

@ -14,7 +14,7 @@ class HeaderWithMenuItem(
@DrawableRes val itemIconListView: Int = 0, @DrawableRes val itemIconListView: Int = 0,
var showMenuItem: Boolean = true, var showMenuItem: Boolean = true,
private val onClickListener: (() -> Unit)? = null, private val onClickListener: (() -> Unit)? = null,
private val onClickListenerListView: (() -> Unit)? = null, private val listViewOnClickListener: (() -> Unit)? = null,
private val menuItemOnClickListener: (() -> Unit)? = null private val menuItemOnClickListener: (() -> Unit)? = null
) : BindableItem<HeaderWithMenuItemBinding>() { ) : BindableItem<HeaderWithMenuItemBinding>() {
companion object { companion object {
@ -40,8 +40,8 @@ class HeaderWithMenuItem(
val listener = onClickListener?.let { OnClickListener { onClickListener.invoke() } } val listener = onClickListener?.let { OnClickListener { onClickListener.invoke() } }
viewBinding.root.setOnClickListener(listener) viewBinding.root.setOnClickListener(listener)
val listenerListView = onClickListenerListView?.let { OnClickListener { onClickListenerListView.invoke() } } val listViewListener = listViewOnClickListener?.let { OnClickListener { listViewOnClickListener.invoke() } }
viewBinding.root.setOnClickListener(listenerListView) viewBinding.headerMenuItem2.setOnClickListener(listViewListener)
val menuItemListener = menuItemOnClickListener?.let { OnClickListener { menuItemOnClickListener.invoke() } } val menuItemListener = menuItemOnClickListener?.let { OnClickListener { menuItemOnClickListener.invoke() } }
viewBinding.headerMenuItem.setOnClickListener(menuItemListener) viewBinding.headerMenuItem.setOnClickListener(menuItemListener)