Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show subscribed channels count in subscriptions fragment #4384

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.github.libretube.db.DatabaseHelper
import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.SubscriptionGroup
import com.github.libretube.extensions.dpToPx
import com.github.libretube.extensions.formatShort
import com.github.libretube.extensions.toID
import com.github.libretube.helpers.PreferenceHelper
import com.github.libretube.ui.adapters.LegacySubscriptionAdapter
Expand Down Expand Up @@ -210,10 +211,10 @@ class SubscriptionsFragment : Fragment() {
}

private fun showFeed() {
if (viewModel.videoFeed.value == null) return
val videoFeed = viewModel.videoFeed.value ?: return

binding.subRefresh.isRefreshing = false
val feed = viewModel.videoFeed.value!!
val feed = videoFeed
.filter { streamItem ->
// filter for selected channel groups
if (selectedFilterGroup == 0) {
Expand Down Expand Up @@ -287,8 +288,9 @@ class SubscriptionsFragment : Fragment() {
PreferenceHelper.updateLastFeedWatchedTime()
}

@SuppressLint("SetTextI18n")
private fun showSubscriptions() {
if (viewModel.subscriptions.value == null) return
val subscriptions = viewModel.subscriptions.value ?: return

val legacySubscriptions = PreferenceHelper.getBoolean(
PreferenceKeys.LEGACY_SUBSCRIPTIONS,
Expand All @@ -303,10 +305,10 @@ class SubscriptionsFragment : Fragment() {
"4"
).toInt()
)
binding.subChannels.adapter = LegacySubscriptionAdapter(viewModel.subscriptions.value!!)
binding.subChannels.adapter = LegacySubscriptionAdapter(subscriptions)
} else {
binding.subChannels.layoutManager = LinearLayoutManager(context)
binding.subChannels.adapter = SubscriptionChannelAdapter(viewModel.subscriptions.value!!.toMutableList())
binding.subChannels.adapter = SubscriptionChannelAdapter(subscriptions.toMutableList())
}

binding.subRefresh.isRefreshing = false
Expand All @@ -316,5 +318,8 @@ class SubscriptionsFragment : Fragment() {
val notLoaded = viewModel.subscriptions.value.isNullOrEmpty()
binding.subChannelsContainer.isGone = notLoaded
binding.emptyFeed.isVisible = notLoaded

val subCount = subscriptions.size.toLong().formatShort()
binding.toggleSubsText.text = "${getString(R.string.subscriptions)} ($subCount)"
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_subscriptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
app:cardCornerRadius="18dp">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/toggle_subs_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
Expand Down