Skip to content

Commit

Permalink
selected colors
Browse files Browse the repository at this point in the history
fixes bug where the color collection activity loses the current selection
  • Loading branch information
forrestguice committed Dec 21, 2024
1 parent 52d7306 commit c6e6adc
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public class ColorValuesSelectFragment extends ColorValuesFragment
public static final String ARG_COLOR_TAG = "colorTag";
public static final String DEF_COLOR_TAG = null;

public static final String ARG_COLOR_SELECTED_ID = "selectedID";
public static final String ARG_COLOR_SELECTED_DEFAULT = "defaultIsSelected";

protected TextView label;
protected Spinner selector;
protected ImageButton addButton, editButton, backButton, menuButton;
Expand Down Expand Up @@ -163,8 +166,11 @@ public void onNothingSelected(AdapterView<?> parent) {}
};
protected void onColorValuesSelected(int position)
{
ColorValuesItem item = (ColorValuesItem) selector.getItemAtPosition(position);
getArguments().putString(ARG_COLOR_SELECTED_ID, (item != null ? item.colorsID : null));
getArguments().putBoolean(ARG_COLOR_SELECTED_DEFAULT, (item != null && item.colorsID == null));
if (listener != null) {
listener.onItemSelected((ColorValuesItem) selector.getItemAtPosition(position));
listener.onItemSelected(item);
}
updateControls();
}
Expand Down Expand Up @@ -335,7 +341,9 @@ protected void updateViews()
if (colorCollection != null)
{
int selectedIndex = 0;
String selectedColorsID = colorCollection.getSelectedColorsID(getActivity(), getAppWidgetID(), getColorTag());
String selectedColorsID0 = colorCollection.getSelectedColorsID(getActivity(), getAppWidgetID(), getColorTag());
boolean defaultIsSelected = getArguments().getBoolean(ARG_COLOR_SELECTED_DEFAULT, false);
String selectedColorsID = getArguments().getString(ARG_COLOR_SELECTED_ID, (defaultIsSelected ? null : selectedColorsID0));

for (int i=0; i<selector.getCount(); i++)
{
Expand Down

0 comments on commit c6e6adc

Please sign in to comment.