From 4eb9871ead5fa5f6b86bacee3a18d9ad52ad6d32 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Wed, 14 Oct 2015 13:10:18 -0700 Subject: [PATCH] Fix bugs introduced in ChooserActivity * Wait to start animations until all state has been initialized, as the process of starting an Animator will set initial values, triggering other events relying on the configured state. * Correctly track underlying item indexes for columns. * Do not over-extend the ResolverDrawerLayout when multiple rows animate in. Bug 24926885 Bug 24928706 Change-Id: I4772e1a0ba79b17b5dc19c778f3ef0cb5200c533 --- .../com/android/internal/app/ChooserActivity.java | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 6bbebb7dd43b..9708ccef0b59 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -1017,7 +1017,15 @@ public class ChooserActivity extends ResolverActivity { final RowScale rs = new RowScale(ChooserRowAdapter.this, 0.f, 1.f) .setInterpolator(mInterpolator); mServiceTargetScale[i] = rs; - rs.startAnimation(); + } + + // Start the animations in a separate loop. + // The process of starting animations will result in + // binding views to set up initial values, and we must + // have ALL of the new RowScale objects created above before + // we get started. + for (int i = oldRCount; i < rcount; i++) { + mServiceTargetScale[i].startAnimation(); } } @@ -1097,17 +1105,19 @@ public class ChooserActivity extends ResolverActivity { for (int i = 0; i < mColumnCount; i++) { final View v = mChooserListAdapter.createView(row); + final int column = i; v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - startSelected(holder.itemIndex, false, true); + startSelected(holder.itemIndices[column], false, true); } }); v.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { showAppDetails( - mChooserListAdapter.resolveInfoForPosition(holder.itemIndex, true)); + mChooserListAdapter.resolveInfoForPosition( + holder.itemIndices[column], true)); return true; } }); @@ -1165,8 +1175,8 @@ public class ChooserActivity extends ResolverActivity { final View v = holder.cells[i]; if (start + i <= end) { v.setVisibility(View.VISIBLE); - holder.itemIndex = start + i; - mChooserListAdapter.bindView(holder.itemIndex, v); + holder.itemIndices[i] = start + i; + mChooserListAdapter.bindView(holder.itemIndices[i], v); } else { v.setVisibility(View.GONE); } @@ -1197,11 +1207,12 @@ public class ChooserActivity extends ResolverActivity { final View[] cells; final ViewGroup row; int measuredRowHeight; - int itemIndex; + int[] itemIndices; public RowViewHolder(ViewGroup row, int cellCount) { this.row = row; this.cells = new View[cellCount]; + this.itemIndices = new int[cellCount]; } public void measure() { @@ -1389,7 +1400,7 @@ public class ChooserActivity extends ResolverActivity { final View v = mChooserRowAdapter.getView(pos, mCachedView, mListView); int height = ((RowViewHolder) (v.getTag())).measuredRowHeight; - offset += (int) (height * mChooserRowAdapter.getRowScale(pos) * chooserTargetRows); + offset += (int) (height * mChooserRowAdapter.getRowScale(pos)); if (vt >= 0) { mCachedViewType = vt; -- 2.11.0