mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Android: Prevent getSetting ClassCastExceptions in ItemViews
This commit is contained in:
parent
905df6756b
commit
d5ea4b4b80
@ -16,7 +16,7 @@ public final class CheckBoxSetting extends SettingsItem
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof BooleanSetting))
|
||||
{
|
||||
return mDefaultValue;
|
||||
}
|
||||
@ -34,7 +34,7 @@ public final class CheckBoxSetting extends SettingsItem
|
||||
*/
|
||||
public BooleanSetting setChecked(boolean checked)
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof BooleanSetting))
|
||||
{
|
||||
BooleanSetting setting = new BooleanSetting(getKey(), getSection(), checked);
|
||||
setSetting(setting);
|
||||
|
@ -25,14 +25,13 @@ public final class FilePicker extends SettingsItem
|
||||
|
||||
public String getSelectedValue()
|
||||
{
|
||||
StringSetting setting = (StringSetting) getSetting();
|
||||
|
||||
if (setting == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof StringSetting))
|
||||
{
|
||||
return mDefaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringSetting setting = (StringSetting) getSetting();
|
||||
return setting.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class InputBindingSetting extends SettingsItem
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof StringSetting))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class InputBindingSetting extends SettingsItem
|
||||
editor.putString(getKey() + gameId, ui);
|
||||
editor.apply();
|
||||
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof StringSetting))
|
||||
{
|
||||
StringSetting setting = new StringSetting(getKey(), getSection(), bind);
|
||||
setSetting(setting);
|
||||
|
@ -22,7 +22,7 @@ public class RumbleBindingSetting extends InputBindingSetting
|
||||
@Override
|
||||
public String getValue()
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof StringSetting))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ public final class SingleChoiceSetting extends SettingsItem
|
||||
|
||||
public int getSelectedValue()
|
||||
{
|
||||
if (getSetting() != null)
|
||||
if (getSetting() == null || !(getSetting() instanceof IntSetting))
|
||||
{
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
return setting.getValue();
|
||||
return mDefaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mDefaultValue;
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
return setting.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public final class SingleChoiceSetting extends SettingsItem
|
||||
*/
|
||||
public IntSetting setSelectedValue(int selection)
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof IntSetting))
|
||||
{
|
||||
IntSetting setting = new IntSetting(getKey(), getSection(), selection);
|
||||
setSetting(setting);
|
||||
|
@ -59,14 +59,14 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem
|
||||
|
||||
public int getSelectedValue()
|
||||
{
|
||||
if (getSetting() != null)
|
||||
if (getSetting() == null || !(getSetting() instanceof IntSetting))
|
||||
{
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
return setting.getValue();
|
||||
return mDefaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mDefaultValue;
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
return setting.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem
|
||||
*/
|
||||
public IntSetting setSelectedValue(int selection)
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof IntSetting))
|
||||
{
|
||||
IntSetting setting = new IntSetting(getKey(), getSection(), selection);
|
||||
setSetting(setting);
|
||||
|
@ -75,7 +75,7 @@ public final class SliderSetting extends SettingsItem
|
||||
*/
|
||||
public IntSetting setSelectedValue(int selection)
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof IntSetting))
|
||||
{
|
||||
IntSetting setting = new IntSetting(getKey(), getSection(), selection);
|
||||
setSetting(setting);
|
||||
@ -98,7 +98,7 @@ public final class SliderSetting extends SettingsItem
|
||||
*/
|
||||
public FloatSetting setSelectedValue(float selection)
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof FloatSetting))
|
||||
{
|
||||
FloatSetting setting = new FloatSetting(getKey(), getSection(), selection);
|
||||
setSetting(setting);
|
||||
|
@ -71,14 +71,14 @@ public class StringSingleChoiceSetting extends SettingsItem
|
||||
|
||||
public String getSelectedValue()
|
||||
{
|
||||
if (getSetting() != null)
|
||||
if (getSetting() == null || !(getSetting() instanceof StringSetting))
|
||||
{
|
||||
StringSetting setting = (StringSetting) getSetting();
|
||||
return setting.getValue();
|
||||
return mDefaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mDefaultValue;
|
||||
StringSetting setting = (StringSetting) getSetting();
|
||||
return setting.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ public class StringSingleChoiceSetting extends SettingsItem
|
||||
*/
|
||||
public StringSetting setSelectedValue(String selection)
|
||||
{
|
||||
if (getSetting() == null)
|
||||
if (getSetting() == null || !(getSetting() instanceof StringSetting))
|
||||
{
|
||||
StringSetting setting = new StringSetting(getKey(), getSection(), selection);
|
||||
setSetting(setting);
|
||||
|
Loading…
Reference in New Issue
Block a user