fix orientation and list bug

This commit is contained in:
Maufeat
2025-12-19 11:38:05 +01:00
parent a87b437320
commit 2685e8f877
3 changed files with 12 additions and 4 deletions

View File

@@ -32,8 +32,9 @@ class AddonAdapter(val addonViewModel: AddonViewModel) :
binding.addonSwitch.performClick()
}
binding.title.text = model.name
binding.addonSwitch.isChecked = model.enabled
binding.addonSwitch.setOnCheckedChangeListener(null)
binding.addonSwitch.isChecked = model.enabled
binding.addonSwitch.setOnCheckedChangeListener { _, checked ->
model.enabled = checked
}

View File

@@ -73,7 +73,7 @@ class AddonsFragment : Fragment() {
}
addonViewModel.addonList.collect(viewLifecycleOwner) {
(binding.listAddons.adapter as AddonAdapter).submitList(it)
(binding.listAddons.adapter as AddonAdapter).submitList(it.toList())
}
addonViewModel.showModInstallPicker.collect(
viewLifecycleOwner,
@@ -127,7 +127,9 @@ class AddonsFragment : Fragment() {
override fun onDestroy() {
super.onDestroy()
addonViewModel.onCloseAddons()
if (!requireActivity().isChangingConfigurations) {
addonViewModel.onCloseAddons()
}
}
val installAddon =

View File

@@ -31,10 +31,14 @@ class AddonViewModel : ViewModel() {
val addonToDelete = _addonToDelete.asStateFlow()
var game: Game? = null
private set
private val isRefreshing = AtomicBoolean(false)
fun onOpenAddons(game: Game) {
if (this.game?.programId == game.programId && _patchList.value.isNotEmpty()) {
return
}
this.game = game
refreshAddons()
}
@@ -67,6 +71,7 @@ class AddonViewModel : ViewModel() {
PatchType.Mod -> NativeLibrary.removeMod(patch.programId, patch.name)
PatchType.Cheat -> {}
}
_patchList.value.clear()
refreshAddons()
}
@@ -81,7 +86,7 @@ class AddonViewModel : ViewModel() {
if (it.enabled) {
null
} else {
it.getStorageKey() // Use storage key for proper cheat identification
it.getStorageKey()
}
}.toTypedArray()
)