mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 23:15:28 +03:00
Add refreshRequired
xml attribute in IntegerListPreference
This attribute controls whether a rom list refresh will be triggered when the setting value changes.
This commit is contained in:
parent
221039084e
commit
6135f531ae
@ -22,6 +22,7 @@ import androidx.preference.R
|
|||||||
import androidx.preference.DialogPreference
|
import androidx.preference.DialogPreference
|
||||||
import androidx.preference.PreferenceDialogFragmentCompat
|
import androidx.preference.PreferenceDialogFragmentCompat
|
||||||
import emu.skyline.R as sR
|
import emu.skyline.R as sR
|
||||||
|
import emu.skyline.di.getSettings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Preference that displays a list of entries as a dialog.
|
* A Preference that displays a list of entries as a dialog.
|
||||||
@ -65,6 +66,7 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var isValueSet = false
|
private var isValueSet = false
|
||||||
|
val refreshRequired : Boolean
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val res : Resources = context.resources
|
val res : Resources = context.resources
|
||||||
@ -91,6 +93,12 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
) {
|
) {
|
||||||
summaryProvider = SimpleSummaryProvider.instance
|
summaryProvider = SimpleSummaryProvider.instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshRequired = TypedArrayUtils.getBoolean(
|
||||||
|
a, sR.styleable.IntegerListPreference_refreshRequired,
|
||||||
|
sR.styleable.IntegerListPreference_refreshRequired, false
|
||||||
|
)
|
||||||
|
|
||||||
a.recycle()
|
a.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +282,11 @@ class IntegerListPreference @JvmOverloads constructor(
|
|||||||
builder.setSingleChoiceItems(
|
builder.setSingleChoiceItems(
|
||||||
entries, clickedDialogEntryIndex
|
entries, clickedDialogEntryIndex
|
||||||
) { dialog, which ->
|
) { dialog, which ->
|
||||||
clickedDialogEntryIndex = which
|
if (clickedDialogEntryIndex != which) {
|
||||||
|
clickedDialogEntryIndex = which
|
||||||
|
if (listPreference.refreshRequired)
|
||||||
|
context?.getSettings()?.refreshRequired = true
|
||||||
|
}
|
||||||
|
|
||||||
// Clicking on an item simulates the positive button click, and dismisses
|
// Clicking on an item simulates the positive button click, and dismisses
|
||||||
// the dialog.
|
// the dialog.
|
||||||
|
@ -17,5 +17,7 @@
|
|||||||
<!-- Whether the preference should automatically set its summary to the value saved for the
|
<!-- Whether the preference should automatically set its summary to the value saved for the
|
||||||
preference, and update the summary when the value is changed. Defaults to false. -->
|
preference, and update the summary when the value is changed. Defaults to false. -->
|
||||||
<attr format="boolean" name="useSimpleSummaryProvider"/>
|
<attr format="boolean" name="useSimpleSummaryProvider"/>
|
||||||
|
<!-- Whether the preference should request a game list refresh or not. Defaults to false. -->
|
||||||
|
<attr format="boolean" name="refreshRequired"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
android:entries="@array/system_languages"
|
android:entries="@array/system_languages"
|
||||||
app:key="system_language"
|
app:key="system_language"
|
||||||
app:title="@string/system_language"
|
app:title="@string/system_language"
|
||||||
|
app:refreshRequired="true"
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
Loading…
Reference in New Issue
Block a user