Created a non-functional button in HeaderWithMenuItem.kt

This commit is contained in:
Samuel Wu 2022-10-23 23:43:52 +11:00
parent 2a98cca801
commit 8482bf9fed
3 changed files with 16 additions and 1 deletions

View File

@ -269,6 +269,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter)
feedGroupsSortMenuItem = HeaderWithMenuItem(
getString(R.string.feed_groups_header_title),
R.drawable.ic_list,
R.drawable.ic_sort,
menuItemOnClickListener = ::openReorderDialog
)

View File

@ -11,8 +11,10 @@ import org.schabi.newpipe.databinding.HeaderWithMenuItemBinding
class HeaderWithMenuItem(
val title: String,
@DrawableRes val itemIcon: Int = 0,
@DrawableRes val itemIconListView: Int = 0,
var showMenuItem: Boolean = true,
private val onClickListener: (() -> Unit)? = null,
private val onClickListenerListView: (() -> Unit)? = null,
private val menuItemOnClickListener: (() -> Unit)? = null
) : BindableItem<HeaderWithMenuItemBinding>() {
companion object {
@ -32,11 +34,15 @@ class HeaderWithMenuItem(
override fun bind(viewBinding: HeaderWithMenuItemBinding, position: Int) {
viewBinding.headerTitle.text = title
viewBinding.headerMenuItem.setImageResource(itemIcon)
viewBinding.headerMenuItem2.setImageResource(itemIcon)
viewBinding.headerMenuItem.setImageResource(itemIconListView)
val listener = onClickListener?.let { OnClickListener { onClickListener.invoke() } }
viewBinding.root.setOnClickListener(listener)
val listenerListView = onClickListenerListView?.let { OnClickListener { onClickListenerListView.invoke() } }
viewBinding.root.setOnClickListener(listenerListView)
val menuItemListener = menuItemOnClickListener?.let { OnClickListener { menuItemOnClickListener.invoke() } }
viewBinding.headerMenuItem.setOnClickListener(menuItemListener)
updateMenuItemVisibility(viewBinding)

View File

@ -22,6 +22,14 @@
android:textStyle="bold"
tools:text="Header" />
<ImageButton
android:id="@+id/header_menu_item2"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:background="?attr/selectableItemBackgroundBorderless"
tools:src="@drawable/ic_bookmark" />
<ImageButton
android:id="@+id/header_menu_item"
android:layout_width="24dp"