fix orientation and list bug
This commit is contained in:
parent
dc85d184b4
commit
26f6f37616
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue