mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #4384 from Bnyro/master
feat: show subscribed channels count in subscriptions fragment
This commit is contained in:
commit
aad860a397
@ -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
|
||||
@ -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) {
|
||||
@ -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,
|
||||
@ -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
|
||||
@ -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)"
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user