diff options
| author | Dan Pasanen <invisiblek@cyanogenmod.org> | 2016-12-05 20:36:24 -0600 |
|---|---|---|
| committer | Dan Pasanen <invisiblek@cyanogenmod.org> | 2016-12-05 20:36:24 -0600 |
| commit | 66dcb82d6a7afb53038aac7135018851300e0a28 (patch) | |
| tree | cdc5d6fcc8a3111ac5f42881c8ece8111e195db1 | |
| parent | b9dc8b25516a8eb4a976e4108df38ccccbf9d33b (diff) | |
| parent | 21ce0a0684aeb04cbf18e887df84ab9f42432b16 (diff) | |
| download | android_frameworks_opt_setupwizard-cm-14.1_prerebase.tar.gz android_frameworks_opt_setupwizard-cm-14.1_prerebase.tar.bz2 android_frameworks_opt_setupwizard-cm-14.1_prerebase.zip | |
Merge tag 'android-7.1.1_r4' into cm-14.1cm-14.1_prerebase
Android 7.1.1 release 4
# gpg: Signature made Thu Dec 1 13:07:03 2016 CST
# gpg: using DSA key E8AD3F819AB10E78
# gpg: Can't check signature: No public key
| -rw-r--r-- | library/full-support/src/com/android/setupwizardlib/view/HeaderRecyclerView.java | 25 |
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); } } |
