Merge pull request #10981 from JosJuice/android-string-single-choice-naming

Android: Clean up StringSingleChoiceSetting naming
This commit is contained in:
Mai 2022-08-18 10:37:56 -04:00 committed by GitHub
commit fea552a4de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 22 deletions

View File

@ -14,24 +14,24 @@ public class StringSingleChoiceSetting extends SettingsItem
{
private AbstractStringSetting mSetting;
private String[] mChoicesId;
private String[] mValuesId;
private String[] mChoices;
private String[] mValues;
private MenuTag mMenuTag;
public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, String[] choicesId, String[] valuesId, MenuTag menuTag)
int descriptionId, String[] choices, String[] values, MenuTag menuTag)
{
super(context, titleId, descriptionId);
mSetting = setting;
mChoicesId = choicesId;
mValuesId = valuesId;
mChoices = choices;
mValues = values;
mMenuTag = menuTag;
}
public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, String[] choicesId, String[] valuesId)
int descriptionId, String[] choices, String[] values)
{
this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
this(context, setting, titleId, descriptionId, choices, values, null);
}
public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
@ -39,8 +39,8 @@ public class StringSingleChoiceSetting extends SettingsItem
{
super(context, titleId, descriptionId);
mSetting = setting;
mChoicesId = DolphinApplication.getAppContext().getResources().getStringArray(choicesId);
mValuesId = DolphinApplication.getAppContext().getResources().getStringArray(valuesId);
mChoices = DolphinApplication.getAppContext().getResources().getStringArray(choicesId);
mValues = DolphinApplication.getAppContext().getResources().getStringArray(valuesId);
mMenuTag = menuTag;
}
@ -50,24 +50,24 @@ public class StringSingleChoiceSetting extends SettingsItem
this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
}
public String[] getChoicesId()
public String[] getChoices()
{
return mChoicesId;
return mChoices;
}
public String[] getValuesId()
public String[] getValues()
{
return mValuesId;
return mValues;
}
public String getValueAt(int index)
{
if (mValuesId == null)
if (mValues == null)
return null;
if (index >= 0 && index < mValuesId.length)
if (index >= 0 && index < mValues.length)
{
return mValuesId[index];
return mValues[index];
}
return "";
@ -78,12 +78,12 @@ public class StringSingleChoiceSetting extends SettingsItem
return mSetting.getString(settings);
}
public int getSelectValueIndex(Settings settings)
public int getSelectedValueIndex(Settings settings)
{
String selectedValue = getSelectedValue(settings);
for (int i = 0; i < mValuesId.length; i++)
for (int i = 0; i < mValues.length; i++)
{
if (mValuesId[i].equals(selectedValue))
if (mValues[i].equals(selectedValue))
{
return i;
}

View File

@ -251,7 +251,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());
builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(getSettings()),
builder.setSingleChoiceItems(item.getChoices(), item.getSelectedValueIndex(getSettings()),
this);
mDialog = builder.show();

View File

@ -64,8 +64,8 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
else if (item instanceof StringSingleChoiceSetting)
{
StringSingleChoiceSetting setting = (StringSingleChoiceSetting) item;
String[] choices = setting.getChoicesId();
int valueIndex = setting.getSelectValueIndex(getAdapter().getSettings());
String[] choices = setting.getChoices();
int valueIndex = setting.getSelectedValueIndex(getAdapter().getSettings());
if (valueIndex != -1)
mTextSettingDescription.setText(choices[valueIndex]);
}