1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

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) feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter)
feedGroupsSortMenuItem = HeaderWithMenuItem( feedGroupsSortMenuItem = HeaderWithMenuItem(
getString(R.string.feed_groups_header_title), getString(R.string.feed_groups_header_title),
R.drawable.ic_list,
R.drawable.ic_sort, R.drawable.ic_sort,
menuItemOnClickListener = ::openReorderDialog menuItemOnClickListener = ::openReorderDialog
) )

View File

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

View File

@ -22,6 +22,14 @@
android:textStyle="bold" android:textStyle="bold"
tools:text="Header" /> 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 <ImageButton
android:id="@+id/header_menu_item" android:id="@+id/header_menu_item"
android:layout_width="24dp" android:layout_width="24dp"