mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Fix some UI subscription groups issues
This commit is contained in:
parent
a4088189bf
commit
caea47d0ed
@ -33,12 +33,13 @@ class SubscriptionGroupsAdapter(
|
||||
holder.binding.apply {
|
||||
groupName.text = subscriptionGroup.name
|
||||
deleteGroup.setOnClickListener {
|
||||
groups.remove(subscriptionGroup)
|
||||
groups.removeAt(position)
|
||||
runBlocking(Dispatchers.IO) {
|
||||
DatabaseHolder.Database.subscriptionGroupsDao().deleteGroup(
|
||||
subscriptionGroup.name
|
||||
)
|
||||
}
|
||||
onGroupsChanged(groups)
|
||||
notifyItemRemoved(position)
|
||||
notifyItemRangeChanged(position, itemCount)
|
||||
}
|
||||
@ -48,7 +49,7 @@ class SubscriptionGroupsAdapter(
|
||||
runBlocking(Dispatchers.IO) {
|
||||
// delete the old one as it might have a different name
|
||||
DatabaseHolder.Database.subscriptionGroupsDao().deleteGroup(
|
||||
subscriptionGroup.name
|
||||
groupName.text.toString()
|
||||
)
|
||||
DatabaseHolder.Database.subscriptionGroupsDao().createGroup(it)
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ import kotlinx.serialization.json.JsonNull
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
|
||||
class BackupDialog(
|
||||
private val createBackupFile: (BackupFile) -> Unit,
|
||||
private val createBackupFile: (BackupFile) -> Unit
|
||||
) : DialogFragment() {
|
||||
sealed class BackupOption(
|
||||
@StringRes val name: Int,
|
||||
val onSelected: suspend (BackupFile) -> Unit,
|
||||
val onSelected: suspend (BackupFile) -> Unit
|
||||
) {
|
||||
object WatchHistory : BackupOption(R.string.watch_history, onSelected = {
|
||||
it.watchHistory = Database.watchHistoryDao().getAll()
|
||||
@ -78,7 +78,7 @@ class BackupDialog(
|
||||
BackupOption.PlaylistBookmarks,
|
||||
BackupOption.LocalPlaylists,
|
||||
BackupOption.SubscriptionGroups,
|
||||
BackupOption.Preferences,
|
||||
BackupOption.Preferences
|
||||
)
|
||||
|
||||
val backupItems = backupOptions.map { context?.getString(it.name)!! }.toTypedArray()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.libretube.ui.fragments
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -162,19 +163,19 @@ class SubscriptionsFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
private suspend fun initChannelGroups() {
|
||||
channelGroups = DatabaseHolder.Database.subscriptionGroupsDao().getAll()
|
||||
|
||||
binding.chipAll.isSelected = true
|
||||
binding.channelGroups.children.forEach { view ->
|
||||
if (view.id != R.id.chip_all) binding.channelGroups.removeView(view)
|
||||
}
|
||||
binding.chipAll.isChecked = true
|
||||
binding.channelGroups.removeAllViews()
|
||||
|
||||
binding.channelGroups.addView(binding.chipAll)
|
||||
channelGroups.forEach { group ->
|
||||
val chip = Chip(context, null, R.style.ElevatedFilterChip).apply {
|
||||
val chip = layoutInflater.inflate(R.layout.filter_chip, null) as Chip
|
||||
chip.apply {
|
||||
id = View.generateViewId()
|
||||
isCheckable = true
|
||||
isClickable = true
|
||||
text = group.name
|
||||
}
|
||||
|
||||
|
5
app/src/main/res/layout/filter_chip.xml
Normal file
5
app/src/main/res/layout/filter_chip.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.chip.Chip xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/Widget.Material3.Chip.Filter.Elevated"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
Loading…
Reference in New Issue
Block a user