0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-22 19:25:11 +00:00

null safety for installation preferences

This commit is contained in:
Xinto 2020-11-15 14:29:20 +04:00
parent 411bb08ba3
commit 870725a09a
2 changed files with 8 additions and 2 deletions

View file

@ -35,7 +35,10 @@ class AppVersionSelectorDialog(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
loadBoxes()
view.findViewWithTag<MaterialRadioButton>(prefs.getString("${app}_version", "latest")).isChecked = true
val tag = view.findViewWithTag<MaterialRadioButton>(prefs.getString("${app}_version", "latest"))
if (tag != null) {
tag.isChecked = true
}
binding.dialogTitle.text = requireActivity().getString(R.string.version)
binding.dialogSave.setOnClickListener {
prefs.edit {

View file

@ -34,7 +34,10 @@ class VancedThemeSelectorDialog : BottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
loadButtons()
binding.dialogTitle.text = requireActivity().getString(R.string.theme)
view.findViewWithTag<MaterialRadioButton>(prefs.getString("theme", "dark")).isChecked = true
val tag = view.findViewWithTag<MaterialRadioButton>(prefs.getString("theme", "dark"))
if (tag != null) {
tag.isChecked = true
}
binding.dialogSave.setOnClickListener {
prefs.edit { putString("theme", binding.dialogRadiogroup.getCheckedButtonTag()) }
dismiss()