diff options
author | Santiago Etchebehere <santie@google.com> | 2019-03-15 17:39:11 -0700 |
---|---|---|
committer | Santiago Etchebehere <santie@google.com> | 2019-03-21 16:49:47 -0700 |
commit | 8efe2ea61bf8f7c5b4a37724b34e3da69ddb30fc (patch) | |
tree | 7ef498ccd6487b36694c3cc89edf1127bd2b59ae /src/com/android/customization/widget/OptionSelectorController.java | |
parent | 833a6b92b9a38c58a78ddfae77b38effc821a157 (diff) |
Custom Theme 7/n: delete custom theme
Add delete option on custom theme fragments, and reload the
options when going back after deleting to ensure we show the
correct ones.
Bug: 124796742
Change-Id: I23fa0f418a3872a5426faa4b7d514bc0395f79b5
Diffstat (limited to 'src/com/android/customization/widget/OptionSelectorController.java')
-rw-r--r-- | src/com/android/customization/widget/OptionSelectorController.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/com/android/customization/widget/OptionSelectorController.java b/src/com/android/customization/widget/OptionSelectorController.java index 10b6d287..090dc7e4 100644 --- a/src/com/android/customization/widget/OptionSelectorController.java +++ b/src/com/android/customization/widget/OptionSelectorController.java @@ -37,9 +37,10 @@ import java.util.Set; * Simple controller for a RecyclerView-based widget to hold the options for each customization * section (eg, thumbnails for themes, clocks, grid sizes). * To use, just pass the RV that will contain the tiles and the list of {@link CustomizationOption} - * representing each option, and call {@link #initOptions()} to populate the widget. + * representing each option, and call {@link #initOptions(CustomizationManager)} to populate the + * widget. */ -public class OptionSelectorController { +public class OptionSelectorController<T extends CustomizationOption<T>> { /** * Interface to be notified when an option is selected by the user. @@ -52,14 +53,13 @@ public class OptionSelectorController { } private final RecyclerView mContainer; - private final List<? extends CustomizationOption> mOptions; + private final List<T> mOptions; private final Set<OptionSelectedListener> mListeners = new HashSet<>(); private RecyclerView.Adapter<TileViewHolder> mAdapter; private CustomizationOption mSelectedOption; - public OptionSelectorController(RecyclerView container, - List<? extends CustomizationOption> options) { + public OptionSelectorController(RecyclerView container, List<T> options) { mContainer = container; mOptions = options; } @@ -84,7 +84,7 @@ public class OptionSelectorController { /** * Initializes the UI for the options passed in the constructor of this class. */ - public void initOptions(final CustomizationManager<? extends CustomizationOption> manager) { + public void initOptions(final CustomizationManager<T> manager) { mAdapter = new RecyclerView.Adapter<TileViewHolder>() { @Override public int getItemViewType(int position) { @@ -126,6 +126,12 @@ public class OptionSelectorController { mContainer.setAdapter(mAdapter); } + public void resetOptions(List<T> options) { + mOptions.clear(); + mOptions.addAll(options); + mAdapter.notifyDataSetChanged(); + } + private void notifyListeners() { if (mListeners.isEmpty()) { return; |