mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
Finalized design for vertical card view and removed unneeded variables in SubscriptionFragment.kt
This commit is contained in:
parent
ed68e3bd46
commit
28464344c1
@ -78,9 +78,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
|
||||
private val groupAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
||||
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<SubscriptionState>() {
|
||||
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<SubscriptionState>() {
|
||||
view?.let { initViews(it, savedInstanceState = Bundle()) }
|
||||
}
|
||||
|
||||
private fun changeLayout() {
|
||||
private fun changeVerticalLayout() {
|
||||
defaultListView = false
|
||||
Section().apply {
|
||||
val carouselAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
||||
|
||||
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<SubscriptionState>() {
|
||||
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<SubscriptionState>() {
|
||||
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<SubscriptionState>() {
|
||||
|
||||
private fun handleFeedGroupsVertical(groups: List<Group>) {
|
||||
if (!defaultListView) {
|
||||
feedGroupsVerticalSection.update(groups)
|
||||
feedGroupsSection.update(groups)
|
||||
|
||||
if (feedGroupsListVerticalState != null) {
|
||||
feedGroupsVerticalCarousel?.onRestoreInstanceState(feedGroupsListVerticalState)
|
||||
feedGroupsCarousel?.onRestoreInstanceState(feedGroupsListVerticalState)
|
||||
feedGroupsListVerticalState = null
|
||||
}
|
||||
|
||||
|
@ -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<FeedGroupAddNewItemVerticalBinding>() {
|
||||
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<FeedGroupAddNewVerticalItemBinding>() {
|
||||
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)
|
||||
}
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="51dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:scaleType="centerInside"
|
||||
tools:ignore="ContentDescription"
|
||||
@ -31,12 +31,13 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:ellipsize="end"
|
||||
android:gravity="start"
|
||||
android:background="?attr/card_item_contrast_color"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:padding="2dp"
|
||||
android:padding="10dp"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textSize="20sp"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="ALL" />
|
||||
</LinearLayout>
|
||||
|
@ -125,7 +125,7 @@
|
||||
|
||||
<!-- Feed Groups dimensions-->
|
||||
<dimen name="feed_group_carousel_start_end_margin">12dp</dimen>
|
||||
<dimen name="feed_group_carousel_top_bottom_margin">2dp</dimen>
|
||||
<dimen name="feed_group_carousel_top_bottom_margin">4dp</dimen>
|
||||
<dimen name="feed_group_carousel_between_items_margin">4dp</dimen>
|
||||
|
||||
<dimen name="search_suggestion_text_size">16sp</dimen>
|
||||
|
Loading…
Reference in New Issue
Block a user