summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAjay Nadathur <ajayns@google.com>2016-08-16 16:38:20 -0700
committerMaurice Lam <yukl@google.com>2016-09-14 19:25:27 +0000
commit21ce0a0684aeb04cbf18e887df84ab9f42432b16 (patch)
treefbfa339455a01bba5dc850411a7eed91fe9a4f35
parent04eecdd42f0bc9751825f9f21131a59852256278 (diff)
downloadsetupwizard-nougat-mr2-security-release.tar.gz
[SetupWizard] Setup Wizard crash on scrolling the list in Select Wi-Fiandroid-cts_7.1_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1nougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-devnougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-release
screen - Setupwizard was crashing because RecyclerView during keyboard scrolls invokes onCreateViewHolder(ViewGroup, int) for header view more than once. We return the same headerView object each time which causes problems later on. - Fixed the problem by wrapping the header in a framelayout and inserting the header to the current framelayout in onBindViewHeader(ViewHolder, int). Testing: ------- - Verified by running on Pixel C, no crashes observed - Also attempted scrolling using touchscreen, works as usual. bug:30789424 Change-Id: I89ac09e14f21ceec3628f249f2cd2a391f020072 (cherry picked from commit c3a97eece385d93a85a215281ef48bdea728af0b)
-rw-r--r--library/full-support/src/com/android/setupwizardlib/view/HeaderRecyclerView.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/library/full-support/src/com/android/setupwizardlib/view/HeaderRecyclerView.java b/library/full-support/src/com/android/setupwizardlib/view/HeaderRecyclerView.java
index e0c0e46..29329b4 100644
--- a/library/full-support/src/com/android/setupwizardlib/view/HeaderRecyclerView.java
+++ b/library/full-support/src/com/android/setupwizardlib/view/HeaderRecyclerView.java
@@ -25,6 +25,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
+import android.widget.FrameLayout;
import com.android.setupwizardlib.DividerItemDecoration;
import com.android.setupwizardlib.R;
@@ -102,8 +103,21 @@ public class HeaderRecyclerView extends RecyclerView {
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ /*
+ * Returning the same view (mHeader) results in crash ".. but view is not a real child."
+ * The framework creates more than one instance of header because of "disappear"
+ * animations applied on the header and this necessitates creation of another headerview
+ * to use after the animation. We work around this restriction by returning an empty
+ * framelayout to which the header is attached using #onBindViewHolder method.
+ */
if (viewType == HEADER_VIEW_TYPE) {
- return new HeaderViewHolder(mHeader);
+ FrameLayout frameLayout = new FrameLayout(parent.getContext());
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.MATCH_PARENT,
+ FrameLayout.LayoutParams.WRAP_CONTENT
+ );
+ frameLayout.setLayoutParams(params);
+ return new HeaderViewHolder(frameLayout);
} else {
return mAdapter.onCreateViewHolder(parent, viewType);
}
@@ -115,7 +129,14 @@ public class HeaderRecyclerView extends RecyclerView {
if (mHeader != null) {
position--;
}
- if (position >= 0) {
+
+ if (holder instanceof HeaderViewHolder) {
+ if (mHeader.getParent() != null) {
+ ((ViewGroup) mHeader.getParent()).removeView(mHeader);
+ }
+ FrameLayout mHeaderParent = (FrameLayout) holder.itemView;
+ mHeaderParent.addView(mHeader);
+ } else {
mAdapter.onBindViewHolder(holder, position);
}
}