small fixes p.2

This commit is contained in:
Nazar-Kutz 2020-05-13 15:14:50 +03:00
parent 6b5b3236a4
commit e178c280e0

View file

@ -34,14 +34,12 @@ public class SelectMultipleProfilesBottomSheet extends BasePreferenceBottomSheet
public static final String DISABLED_KEYS = "disabled_keys"; public static final String DISABLED_KEYS = "disabled_keys";
private List<ProfileDataObject> profiles = new ArrayList<>(); private List<ProfileDataObject> profiles = new ArrayList<>();
private Map<String, CompoundButton> compoundButtons = new HashMap<>();
private List<String> selectedProfiles; private List<String> selectedProfiles;
private List<String> disabledProfiles; private List<String> disabledProfiles;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
compoundButtons.clear();
Bundle args = getArguments(); Bundle args = getArguments();
if (savedInstanceState != null) { if (savedInstanceState != null) {
readBundle(savedInstanceState); readBundle(savedInstanceState);
@ -66,19 +64,6 @@ public class SelectMultipleProfilesBottomSheet extends BasePreferenceBottomSheet
} }
} }
@Override
public void onResume() {
super.onResume();
for (ProfileDataObject profile : profiles) {
String key = profile.getStringKey();
boolean selected = selectedProfiles.contains(key);
CompoundButton cb = compoundButtons.get(key);
if (cb != null) {
cb.setChecked(selected);
}
}
}
@Override @Override
public void createMenuItems(Bundle savedInstanceState) { public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(getString(R.string.application_profiles))); items.add(new TitleItem(getString(R.string.application_profiles)));
@ -118,7 +103,8 @@ public class SelectMultipleProfilesBottomSheet extends BasePreferenceBottomSheet
ivIcon.setImageDrawable(drawableIcon); ivIcon.setImageDrawable(drawableIcon);
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app,
enable ? activeColorId : disableColorId), compoundButton); enable ? activeColorId : disableColorId), compoundButton);
compoundButtons.put(profile.getStringKey(), compoundButton); compoundButton.setSaveEnabled(false);
compoundButton.setChecked(profile.isSelected());
View.OnClickListener l = !enable ? null : new View.OnClickListener() { View.OnClickListener l = !enable ? null : new View.OnClickListener() {
@Override @Override