From 28464344c14425ebfdc80c653c48a8a4380f6dfe Mon Sep 17 00:00:00 2001 From: Samuel Wu Date: Tue, 25 Oct 2022 11:43:25 +1100 Subject: [PATCH] Finalized design for vertical card view and removed unneeded variables in SubscriptionFragment.kt --- .../local/subscription/SubscriptionFragment.kt | 16 +++++++--------- .../item/FeedGroupAddVerticalItem.kt | 10 +++++----- ....xml => feed_group_add_new_vertical_item.xml} | 0 .../res/layout/feed_group_card_vertical_item.xml | 13 +++++++------ app/src/main/res/values/dimens.xml | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) rename app/src/main/res/layout/{feed_group_add_new_item_vertical.xml => feed_group_add_new_vertical_item.xml} (100%) 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 89d394a4a..348dd5897 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 @@ -78,9 +78,7 @@ class SubscriptionFragment : BaseStateFragment() { private val groupAdapter = GroupAdapter>() private val feedGroupsSection = Section() - private val feedGroupsVerticalSection = Section() private var feedGroupsCarousel: FeedGroupCarouselItem? = null - private var feedGroupsVerticalCarousel: FeedGroupCarouselItem? = null private lateinit var feedGroupsSortMenuItem: HeaderWithMenuItem private val subscriptionsSection = Section() private var defaultListView: Boolean = true @@ -284,7 +282,7 @@ class SubscriptionFragment : BaseStateFragment() { getString(R.string.feed_groups_header_title), R.drawable.ic_list, R.drawable.ic_sort, - listViewOnClickListener = ::changeLayout, + listViewOnClickListener = ::changeVerticalLayout, menuItemOnClickListener = ::openReorderDialog ) @@ -307,13 +305,13 @@ class SubscriptionFragment : BaseStateFragment() { view?.let { initViews(it, savedInstanceState = Bundle()) } } - private fun changeLayout() { + private fun changeVerticalLayout() { defaultListView = false Section().apply { val carouselAdapter = GroupAdapter>() carouselAdapter.add(FeedGroupCardVerticalItem(-1, getString(R.string.all), FeedGroupIcon.RSS)) - carouselAdapter.add(feedGroupsVerticalSection) + carouselAdapter.add(feedGroupsSection) carouselAdapter.add(FeedGroupAddVerticalItem()) carouselAdapter.setOnItemClickListener { item, _ -> @@ -328,7 +326,7 @@ class SubscriptionFragment : BaseStateFragment() { listenerFeedVerticalGroups.held(item) return@setOnItemLongClickListener true } - feedGroupsVerticalCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter, RecyclerView.VERTICAL) + feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter, RecyclerView.VERTICAL) feedGroupsSortMenuItem = HeaderWithMenuItem( getString(R.string.feed_groups_header_title), @@ -337,7 +335,7 @@ class SubscriptionFragment : BaseStateFragment() { listViewOnClickListener = ::setupInitialLayout, menuItemOnClickListener = ::openReorderDialog ) - add(Section(feedGroupsSortMenuItem, listOf(feedGroupsVerticalCarousel))) + add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel))) groupAdapter.clear() groupAdapter.add(this) } @@ -499,10 +497,10 @@ class SubscriptionFragment : BaseStateFragment() { private fun handleFeedGroupsVertical(groups: List) { if (!defaultListView) { - feedGroupsVerticalSection.update(groups) + feedGroupsSection.update(groups) if (feedGroupsListVerticalState != null) { - feedGroupsVerticalCarousel?.onRestoreInstanceState(feedGroupsListVerticalState) + feedGroupsCarousel?.onRestoreInstanceState(feedGroupsListVerticalState) feedGroupsListVerticalState = null } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/FeedGroupAddVerticalItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/FeedGroupAddVerticalItem.kt index eae8bd5f2..049728591 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/FeedGroupAddVerticalItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/FeedGroupAddVerticalItem.kt @@ -3,10 +3,10 @@ package org.schabi.newpipe.local.subscription.item import android.view.View import com.xwray.groupie.viewbinding.BindableItem import org.schabi.newpipe.R -import org.schabi.newpipe.databinding.FeedGroupAddNewItemVerticalBinding +import org.schabi.newpipe.databinding.FeedGroupAddNewVerticalItemBinding -class FeedGroupAddVerticalItem : BindableItem() { - override fun getLayout(): Int = R.layout.feed_group_add_new_item_vertical - override fun bind(viewBinding: FeedGroupAddNewItemVerticalBinding, position: Int) {} - override fun initializeViewBinding(view: View) = FeedGroupAddNewItemVerticalBinding.bind(view) +class FeedGroupAddVerticalItem : BindableItem() { + override fun getLayout(): Int = R.layout.feed_group_add_new_vertical_item + override fun bind(viewBinding: FeedGroupAddNewVerticalItemBinding, position: Int) {} + override fun initializeViewBinding(view: View) = FeedGroupAddNewVerticalItemBinding.bind(view) } diff --git a/app/src/main/res/layout/feed_group_add_new_item_vertical.xml b/app/src/main/res/layout/feed_group_add_new_vertical_item.xml similarity index 100% rename from app/src/main/res/layout/feed_group_add_new_item_vertical.xml rename to app/src/main/res/layout/feed_group_add_new_vertical_item.xml diff --git a/app/src/main/res/layout/feed_group_card_vertical_item.xml b/app/src/main/res/layout/feed_group_card_vertical_item.xml index aadfc95a8..2924483c2 100644 --- a/app/src/main/res/layout/feed_group_card_vertical_item.xml +++ b/app/src/main/res/layout/feed_group_card_vertical_item.xml @@ -17,10 +17,10 @@ diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 419b3ca43..86bf9da5b 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -125,7 +125,7 @@ 12dp - 2dp + 4dp 4dp 16sp