Skip to content

Commit 2846434

Browse files
committed
Finalized design for vertical card view and removed unneeded variables in SubscriptionFragment.kt
1 parent ed68e3b commit 2846434

5 files changed

Lines changed: 20 additions & 21 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
7878

7979
private val groupAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
8080
private val feedGroupsSection = Section()
81-
private val feedGroupsVerticalSection = Section()
8281
private var feedGroupsCarousel: FeedGroupCarouselItem? = null
83-
private var feedGroupsVerticalCarousel: FeedGroupCarouselItem? = null
8482
private lateinit var feedGroupsSortMenuItem: HeaderWithMenuItem
8583
private val subscriptionsSection = Section()
8684
private var defaultListView: Boolean = true
@@ -284,7 +282,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
284282
getString(R.string.feed_groups_header_title),
285283
R.drawable.ic_list,
286284
R.drawable.ic_sort,
287-
listViewOnClickListener = ::changeLayout,
285+
listViewOnClickListener = ::changeVerticalLayout,
288286
menuItemOnClickListener = ::openReorderDialog
289287
)
290288

@@ -307,13 +305,13 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
307305
view?.let { initViews(it, savedInstanceState = Bundle()) }
308306
}
309307

310-
private fun changeLayout() {
308+
private fun changeVerticalLayout() {
311309
defaultListView = false
312310
Section().apply {
313311
val carouselAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
314312

315313
carouselAdapter.add(FeedGroupCardVerticalItem(-1, getString(R.string.all), FeedGroupIcon.RSS))
316-
carouselAdapter.add(feedGroupsVerticalSection)
314+
carouselAdapter.add(feedGroupsSection)
317315
carouselAdapter.add(FeedGroupAddVerticalItem())
318316

319317
carouselAdapter.setOnItemClickListener { item, _ ->
@@ -328,7 +326,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
328326
listenerFeedVerticalGroups.held(item)
329327
return@setOnItemLongClickListener true
330328
}
331-
feedGroupsVerticalCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter, RecyclerView.VERTICAL)
329+
feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter, RecyclerView.VERTICAL)
332330

333331
feedGroupsSortMenuItem = HeaderWithMenuItem(
334332
getString(R.string.feed_groups_header_title),
@@ -337,7 +335,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
337335
listViewOnClickListener = ::setupInitialLayout,
338336
menuItemOnClickListener = ::openReorderDialog
339337
)
340-
add(Section(feedGroupsSortMenuItem, listOf(feedGroupsVerticalCarousel)))
338+
add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel)))
341339
groupAdapter.clear()
342340
groupAdapter.add(this)
343341
}
@@ -499,10 +497,10 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
499497

500498
private fun handleFeedGroupsVertical(groups: List<Group>) {
501499
if (!defaultListView) {
502-
feedGroupsVerticalSection.update(groups)
500+
feedGroupsSection.update(groups)
503501

504502
if (feedGroupsListVerticalState != null) {
505-
feedGroupsVerticalCarousel?.onRestoreInstanceState(feedGroupsListVerticalState)
503+
feedGroupsCarousel?.onRestoreInstanceState(feedGroupsListVerticalState)
506504
feedGroupsListVerticalState = null
507505
}
508506

app/src/main/java/org/schabi/newpipe/local/subscription/item/FeedGroupAddVerticalItem.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package org.schabi.newpipe.local.subscription.item
33
import android.view.View
44
import com.xwray.groupie.viewbinding.BindableItem
55
import org.schabi.newpipe.R
6-
import org.schabi.newpipe.databinding.FeedGroupAddNewItemVerticalBinding
6+
import org.schabi.newpipe.databinding.FeedGroupAddNewVerticalItemBinding
77

8-
class FeedGroupAddVerticalItem : BindableItem<FeedGroupAddNewItemVerticalBinding>() {
9-
override fun getLayout(): Int = R.layout.feed_group_add_new_item_vertical
10-
override fun bind(viewBinding: FeedGroupAddNewItemVerticalBinding, position: Int) {}
11-
override fun initializeViewBinding(view: View) = FeedGroupAddNewItemVerticalBinding.bind(view)
8+
class FeedGroupAddVerticalItem : BindableItem<FeedGroupAddNewVerticalItemBinding>() {
9+
override fun getLayout(): Int = R.layout.feed_group_add_new_vertical_item
10+
override fun bind(viewBinding: FeedGroupAddNewVerticalItemBinding, position: Int) {}
11+
override fun initializeViewBinding(view: View) = FeedGroupAddNewVerticalItemBinding.bind(view)
1212
}

app/src/main/res/layout/feed_group_add_new_item_vertical.xml renamed to app/src/main/res/layout/feed_group_add_new_vertical_item.xml

File renamed without changes.

app/src/main/res/layout/feed_group_card_vertical_item.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
<ImageView
1919
android:id="@+id/icon"
20-
android:layout_width="51dp"
21-
android:layout_height="64dp"
20+
android:layout_width="64dp"
21+
android:layout_height="48dp"
2222
android:layout_gravity="center"
23-
android:paddingTop="8dp"
23+
android:paddingTop="2dp"
2424
android:paddingBottom="2dp"
2525
android:scaleType="centerInside"
2626
tools:ignore="ContentDescription"
@@ -31,12 +31,13 @@
3131
android:layout_width="match_parent"
3232
android:layout_height="match_parent"
3333
android:ellipsize="end"
34-
android:gravity="start"
34+
android:background="?attr/card_item_contrast_color"
35+
android:gravity="center_vertical"
3536
android:maxLines="1"
36-
android:padding="2dp"
37+
android:padding="10dp"
3738
android:textAllCaps="false"
3839
android:textColor="?attr/colorAccent"
39-
android:textSize="20sp"
40+
android:textSize="16sp"
4041
android:textStyle="bold"
4142
tools:text="ALL" />
4243
</LinearLayout>

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125

126126
<!-- Feed Groups dimensions-->
127127
<dimen name="feed_group_carousel_start_end_margin">12dp</dimen>
128-
<dimen name="feed_group_carousel_top_bottom_margin">2dp</dimen>
128+
<dimen name="feed_group_carousel_top_bottom_margin">4dp</dimen>
129129
<dimen name="feed_group_carousel_between_items_margin">4dp</dimen>
130130

131131
<dimen name="search_suggestion_text_size">16sp</dimen>

0 commit comments

Comments
 (0)