diff options
author | Ajay Nadathur <ajayns@google.com> | 2017-04-14 15:02:58 -0700 |
---|---|---|
committer | Ajay Nadathur <ajayns@google.com> | 2017-04-18 10:33:22 -0700 |
commit | bb9086d69daf97f22eb096ecb6055b8360958ac7 (patch) | |
tree | 7b8c37616b1cab81b6977d863393a95f06b01ad7 /library/main | |
parent | c8fc4211a744cb947c732d959ef34bf10d48798c (diff) | |
download | setupwizard-bb9086d69daf97f22eb096ecb6055b8360958ac7.tar.gz |
Customize Item callbacks and support existing background in
RecycleItemAdapter
- Added support for custom backgrounds in RecyclerItemAdapter.
- Added callbacks in Item to allow overriding state/level
that gets copied from icon to drawable
Test: Tests added, verified that changes work
Change-Id: I33c883e0a1a0b76ccccaf8a61ab0bb49f46da3fb
Diffstat (limited to 'library/main')
-rw-r--r-- | library/main/src/com/android/setupwizardlib/items/Item.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/library/main/src/com/android/setupwizardlib/items/Item.java b/library/main/src/com/android/setupwizardlib/items/Item.java index 59ab1a1..fc8823e 100644 --- a/library/main/src/com/android/setupwizardlib/items/Item.java +++ b/library/main/src/com/android/setupwizardlib/items/Item.java @@ -155,8 +155,7 @@ public class Item extends AbstractItem { // Set the image drawable to null before setting the state and level to avoid affecting // any recycled drawable in the ImageView iconView.setImageDrawable(null); - iconView.setImageState(icon.getState(), false /* merge */); - iconView.setImageLevel(icon.getLevel()); + onMergeIconStateAndLevels(iconView, icon); iconView.setImageDrawable(icon); iconContainer.setVisibility(View.VISIBLE); } else { @@ -165,4 +164,14 @@ public class Item extends AbstractItem { view.setId(getViewId()); } + + /** + * Copies state and level information from {@link #getIcon()} to the currently bound view's + * ImageView. Subclasses can override this method to change whats being copied from the icon + * to the ImageView. + */ + protected void onMergeIconStateAndLevels(ImageView iconView, Drawable icon) { + iconView.setImageState(icon.getState(), false /* merge */); + iconView.setImageLevel(icon.getLevel()); + } } |