summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUdam Saini <udam@google.com>2016-01-29 17:14:05 -0800
committerUdam Saini <udam@google.com>2016-01-30 03:03:05 +0000
commit2286e48a268aaa0dc57b93b878c3a632c627acec (patch)
treef112e4faf7ef5b9b4d3c43a7f8a549719281e7ac
parent0e9b312956dd28cef21473337800919eb0a54b2d (diff)
downloadsetupwizard-2286e48a268aaa0dc57b93b878c3a632c627acec.tar.gz
Adds a stable ids attribute for recycler views
bug:26877107 Change-Id: Ia1eb9646f887a6e0b61613997558d08da85d057b
-rw-r--r--library/full-support/res/values/attrs.xml32
-rw-r--r--library/full-support/src/com/android/setupwizardlib/GlifRecyclerLayout.java5
-rw-r--r--library/full-support/src/com/android/setupwizardlib/SetupWizardRecyclerItemsLayout.java7
-rw-r--r--library/main/res/values/attrs.xml5
4 files changed, 41 insertions, 8 deletions
diff --git a/library/full-support/res/values/attrs.xml b/library/full-support/res/values/attrs.xml
new file mode 100644
index 0000000..059da5f
--- /dev/null
+++ b/library/full-support/res/values/attrs.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <attr name="suwHasStableIds" format="boolean|reference" />
+
+ <declare-styleable name="SuwSetupWizardRecyclerItemsLayout">
+ <attr name="android:entries" />
+ <attr name="suwHasStableIds" />
+ </declare-styleable>
+
+ <declare-styleable name="SuwGlifRecyclerLayout">
+ <attr name="android:entries" />
+ <attr name="suwHasStableIds" />
+ <attr name="suwDividerInset" />
+ </declare-styleable>
+</resources>
diff --git a/library/full-support/src/com/android/setupwizardlib/GlifRecyclerLayout.java b/library/full-support/src/com/android/setupwizardlib/GlifRecyclerLayout.java
index 3b8f71a..fd8a974 100644
--- a/library/full-support/src/com/android/setupwizardlib/GlifRecyclerLayout.java
+++ b/library/full-support/src/com/android/setupwizardlib/GlifRecyclerLayout.java
@@ -81,7 +81,10 @@ public class GlifRecyclerLayout extends GlifLayout {
final int xml = a.getResourceId(R.styleable.SuwGlifRecyclerLayout_android_entries, 0);
if (xml != 0) {
final ItemGroup inflated = (ItemGroup) new ItemInflater(context).inflate(xml);
- setAdapter(new RecyclerItemAdapter(inflated));
+ RecyclerItemAdapter adapter = new RecyclerItemAdapter(inflated);
+ adapter.setHasStableIds(a.getBoolean(
+ R.styleable.SuwGlifRecyclerLayout_suwHasStableIds, false));
+ setAdapter(adapter);
}
int dividerInset =
a.getDimensionPixelSize(R.styleable.SuwGlifRecyclerLayout_suwDividerInset, 0);
diff --git a/library/full-support/src/com/android/setupwizardlib/SetupWizardRecyclerItemsLayout.java b/library/full-support/src/com/android/setupwizardlib/SetupWizardRecyclerItemsLayout.java
index 0833ee9..97f6589 100644
--- a/library/full-support/src/com/android/setupwizardlib/SetupWizardRecyclerItemsLayout.java
+++ b/library/full-support/src/com/android/setupwizardlib/SetupWizardRecyclerItemsLayout.java
@@ -63,11 +63,14 @@ public class SetupWizardRecyclerItemsLayout extends SetupWizardLayout {
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
final TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.SuwSetupWizardItemsLayout, defStyleAttr, 0);
- final int xml = a.getResourceId(R.styleable.SuwSetupWizardItemsLayout_android_entries, 0);
+ R.styleable.SuwSetupWizardRecyclerItemsLayout, defStyleAttr, 0);
+ final int xml = a.getResourceId(
+ R.styleable.SuwSetupWizardRecyclerItemsLayout_android_entries, 0);
if (xml != 0) {
final ItemGroup inflated = (ItemGroup) new ItemInflater(context).inflate(xml);
mAdapter = new RecyclerItemAdapter(inflated);
+ mAdapter.setHasStableIds(a.getBoolean(
+ R.styleable.SuwSetupWizardRecyclerItemsLayout_suwHasStableIds, false));
setAdapter(mAdapter);
}
a.recycle();
diff --git a/library/main/res/values/attrs.xml b/library/main/res/values/attrs.xml
index 734a470..d485650 100644
--- a/library/main/res/values/attrs.xml
+++ b/library/main/res/values/attrs.xml
@@ -56,11 +56,6 @@
<attr name="suwDividerInset" />
</declare-styleable>
- <declare-styleable name="SuwGlifRecyclerLayout">
- <attr name="android:entries" />
- <attr name="suwDividerInset" />
- </declare-styleable>
-
<declare-styleable name="SuwStatusBarBackgroundLayout">
<attr name="suwStatusBarBackground" format="color|reference" />
</declare-styleable>