Fixed critical TV crash and made the bookmarks single select

This commit is contained in:
Blatzar 2022-10-28 21:14:57 +02:00
parent c18856c8c3
commit 9ee0653ecf
3 changed files with 15 additions and 4 deletions

View file

@ -770,9 +770,19 @@ class HomeFragment : Fragment() {
for ((chip, watch) in toggleList) {
chip.isChecked = currentSet.contains(watch)
chip?.setOnCheckedChangeListener { _, _ ->
homeViewModel.loadStoredData(toggleList.filter { it.first?.isChecked == true }
.map { it.second }.toSet())
chip?.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
homeViewModel.loadStoredData(
setOf(watch)
// If we filter all buttons then two can be checked at the same time
// Revert this if you want to go back to multi selection
// toggleList.filter { it.first?.isChecked == true }.map { it.second }.toSet()
)
}
// Else if all are unchecked -> Do not load data
else if (toggleList.all { it.first?.isChecked != true }) {
homeViewModel.loadStoredData(emptySet())
}
}
/*chip?.setOnClickListener {

View file

@ -514,6 +514,7 @@
<com.google.android.material.chip.ChipGroup
android:layout_width="wrap_content"
app:singleSelection="true"
android:layout_height="wrap_content"
android:orientation="horizontal">

View file

@ -354,7 +354,7 @@
android:visibility="gone" />
<com.lagradost.cloudstream3.widget.FlowLayout
<com.google.android.material.chip.ChipGroup
android:id="@+id/result_tag"
android:layout_width="match_parent"
android:layout_height="wrap_content" />