Merge "Fix bug 6499508" into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a2c628fb40
@@ -41,7 +41,8 @@ import com.android.systemui.R;
|
|||||||
import com.android.systemui.SwipeHelper;
|
import com.android.systemui.SwipeHelper;
|
||||||
import com.android.systemui.recent.RecentsPanelView.TaskDescriptionAdapter;
|
import com.android.systemui.recent.RecentsPanelView.TaskDescriptionAdapter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class RecentsHorizontalScrollView extends HorizontalScrollView
|
public class RecentsHorizontalScrollView extends HorizontalScrollView
|
||||||
implements SwipeHelper.Callback, RecentsPanelView.RecentsScrollView {
|
implements SwipeHelper.Callback, RecentsPanelView.RecentsScrollView {
|
||||||
@@ -53,7 +54,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
protected int mLastScrollPosition;
|
protected int mLastScrollPosition;
|
||||||
private SwipeHelper mSwipeHelper;
|
private SwipeHelper mSwipeHelper;
|
||||||
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
|
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
|
||||||
private ArrayList<View> mRecycledViews;
|
private HashSet<View> mRecycledViews;
|
||||||
private int mNumItemsInOneScreenful;
|
private int mNumItemsInOneScreenful;
|
||||||
|
|
||||||
public RecentsHorizontalScrollView(Context context, AttributeSet attrs) {
|
public RecentsHorizontalScrollView(Context context, AttributeSet attrs) {
|
||||||
@@ -62,7 +63,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
|
float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
|
||||||
mSwipeHelper = new SwipeHelper(SwipeHelper.Y, this, densityScale, pagingTouchSlop);
|
mSwipeHelper = new SwipeHelper(SwipeHelper.Y, this, densityScale, pagingTouchSlop);
|
||||||
mPerformanceHelper = RecentsScrollViewPerformanceHelper.create(context, attrs, this, false);
|
mPerformanceHelper = RecentsScrollViewPerformanceHelper.create(context, attrs, this, false);
|
||||||
mRecycledViews = new ArrayList<View>();
|
mRecycledViews = new HashSet<View>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinSwipeAlpha(float minAlpha) {
|
public void setMinSwipeAlpha(float minAlpha) {
|
||||||
@@ -89,16 +90,12 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
setLayoutTransition(null);
|
setLayoutTransition(null);
|
||||||
|
|
||||||
mLinearLayout.removeAllViews();
|
mLinearLayout.removeAllViews();
|
||||||
for (int i = 0; i < mRecycledViews.size(); i++) {
|
Iterator<View> recycledViews = mRecycledViews.iterator();
|
||||||
View child = mRecycledViews.get(i);
|
|
||||||
if (child.getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has a parent");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < mAdapter.getCount(); i++) {
|
for (int i = 0; i < mAdapter.getCount(); i++) {
|
||||||
View old = null;
|
View old = null;
|
||||||
if (mRecycledViews.size() != 0) {
|
if (recycledViews.hasNext()) {
|
||||||
old = mRecycledViews.remove(mRecycledViews.size() - 1);
|
old = recycledViews.next();
|
||||||
|
recycledViews.remove();
|
||||||
old.setVisibility(VISIBLE);
|
old.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,9 +192,6 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
public void onChildDismissed(View v) {
|
public void onChildDismissed(View v) {
|
||||||
addToRecycledViews(v);
|
addToRecycledViews(v);
|
||||||
mLinearLayout.removeView(v);
|
mLinearLayout.removeView(v);
|
||||||
if (v.getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has parent");
|
|
||||||
}
|
|
||||||
mCallback.handleSwipe(v);
|
mCallback.handleSwipe(v);
|
||||||
// Restore the alpha/translation parameters to what they were before swiping
|
// Restore the alpha/translation parameters to what they were before swiping
|
||||||
// (for when these items are recycled)
|
// (for when these items are recycled)
|
||||||
@@ -369,15 +363,9 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
mNumItemsInOneScreenful =
|
mNumItemsInOneScreenful =
|
||||||
(int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth());
|
(int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth());
|
||||||
addToRecycledViews(child);
|
addToRecycledViews(child);
|
||||||
if (child.getParent() != null) {
|
|
||||||
throw new RuntimeException("First recycled child has parent");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
|
for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
|
||||||
addToRecycledViews(mAdapter.createView(mLinearLayout));
|
addToRecycledViews(mAdapter.createView(mLinearLayout));
|
||||||
if (mRecycledViews.get(mRecycledViews.size() - 1).getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has parent");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ import com.android.systemui.R;
|
|||||||
import com.android.systemui.SwipeHelper;
|
import com.android.systemui.SwipeHelper;
|
||||||
import com.android.systemui.recent.RecentsPanelView.TaskDescriptionAdapter;
|
import com.android.systemui.recent.RecentsPanelView.TaskDescriptionAdapter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class RecentsVerticalScrollView extends ScrollView
|
public class RecentsVerticalScrollView extends ScrollView
|
||||||
implements SwipeHelper.Callback, RecentsPanelView.RecentsScrollView {
|
implements SwipeHelper.Callback, RecentsPanelView.RecentsScrollView {
|
||||||
@@ -53,7 +54,7 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
protected int mLastScrollPosition;
|
protected int mLastScrollPosition;
|
||||||
private SwipeHelper mSwipeHelper;
|
private SwipeHelper mSwipeHelper;
|
||||||
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
|
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
|
||||||
private ArrayList<View> mRecycledViews;
|
private HashSet<View> mRecycledViews;
|
||||||
private int mNumItemsInOneScreenful;
|
private int mNumItemsInOneScreenful;
|
||||||
|
|
||||||
public RecentsVerticalScrollView(Context context, AttributeSet attrs) {
|
public RecentsVerticalScrollView(Context context, AttributeSet attrs) {
|
||||||
@@ -63,7 +64,7 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
|
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
|
||||||
|
|
||||||
mPerformanceHelper = RecentsScrollViewPerformanceHelper.create(context, attrs, this, true);
|
mPerformanceHelper = RecentsScrollViewPerformanceHelper.create(context, attrs, this, true);
|
||||||
mRecycledViews = new ArrayList<View>();
|
mRecycledViews = new HashSet<View>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinSwipeAlpha(float minAlpha) {
|
public void setMinSwipeAlpha(float minAlpha) {
|
||||||
@@ -93,19 +94,16 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
setLayoutTransition(null);
|
setLayoutTransition(null);
|
||||||
|
|
||||||
mLinearLayout.removeAllViews();
|
mLinearLayout.removeAllViews();
|
||||||
for (int i = 0; i < mRecycledViews.size(); i++) {
|
|
||||||
View child = mRecycledViews.get(i);
|
|
||||||
if (child.getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has parent");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Once we can clear the data associated with individual item views,
|
// Once we can clear the data associated with individual item views,
|
||||||
// we can get rid of the removeAllViews() and the code below will
|
// we can get rid of the removeAllViews() and the code below will
|
||||||
// recycle them.
|
// recycle them.
|
||||||
|
Iterator<View> recycledViews = mRecycledViews.iterator();
|
||||||
for (int i = 0; i < mAdapter.getCount(); i++) {
|
for (int i = 0; i < mAdapter.getCount(); i++) {
|
||||||
View old = null;
|
View old = null;
|
||||||
if (mRecycledViews.size() != 0) {
|
if (recycledViews.hasNext()) {
|
||||||
old = mRecycledViews.remove(mRecycledViews.size() - 1);
|
old = recycledViews.next();
|
||||||
|
recycledViews.remove();
|
||||||
old.setVisibility(VISIBLE);
|
old.setVisibility(VISIBLE);
|
||||||
if (old.getParent() != null) {
|
if (old.getParent() != null) {
|
||||||
throw new RuntimeException("Recycled child has parent (i: " + i + ", recycled i: " + mRecycledViews.size());
|
throw new RuntimeException("Recycled child has parent (i: " + i + ", recycled i: " + mRecycledViews.size());
|
||||||
@@ -150,9 +148,6 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
thumbnailView.setClickable(true);
|
thumbnailView.setClickable(true);
|
||||||
thumbnailView.setOnClickListener(launchAppListener);
|
thumbnailView.setOnClickListener(launchAppListener);
|
||||||
thumbnailView.setOnLongClickListener(longClickListener);
|
thumbnailView.setOnLongClickListener(longClickListener);
|
||||||
if (view.getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has parent");
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't want to dismiss recents if a user clicks on the app title
|
// We don't want to dismiss recents if a user clicks on the app title
|
||||||
// (we also don't want to launch the app either, though, because the
|
// (we also don't want to launch the app either, though, because the
|
||||||
@@ -162,9 +157,6 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
appTitle.setOnTouchListener(noOpListener);
|
appTitle.setOnTouchListener(noOpListener);
|
||||||
final View calloutLine = view.findViewById(R.id.recents_callout_line);
|
final View calloutLine = view.findViewById(R.id.recents_callout_line);
|
||||||
calloutLine.setOnTouchListener(noOpListener);
|
calloutLine.setOnTouchListener(noOpListener);
|
||||||
if (view.getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has parent");
|
|
||||||
}
|
|
||||||
|
|
||||||
mLinearLayout.addView(view);
|
mLinearLayout.addView(view);
|
||||||
}
|
}
|
||||||
@@ -213,9 +205,6 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
public void onChildDismissed(View v) {
|
public void onChildDismissed(View v) {
|
||||||
addToRecycledViews(v);
|
addToRecycledViews(v);
|
||||||
mLinearLayout.removeView(v);
|
mLinearLayout.removeView(v);
|
||||||
if (v.getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has parent");
|
|
||||||
}
|
|
||||||
mCallback.handleSwipe(v);
|
mCallback.handleSwipe(v);
|
||||||
// Restore the alpha/translation parameters to what they were before swiping
|
// Restore the alpha/translation parameters to what they were before swiping
|
||||||
// (for when these items are recycled)
|
// (for when these items are recycled)
|
||||||
@@ -389,15 +378,9 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
mNumItemsInOneScreenful =
|
mNumItemsInOneScreenful =
|
||||||
(int) FloatMath.ceil(dm.heightPixels / (float) child.getMeasuredHeight());
|
(int) FloatMath.ceil(dm.heightPixels / (float) child.getMeasuredHeight());
|
||||||
addToRecycledViews(child);
|
addToRecycledViews(child);
|
||||||
if (child.getParent() != null) {
|
|
||||||
throw new RuntimeException("First recycled child has parent");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
|
for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
|
||||||
addToRecycledViews(mAdapter.createView(mLinearLayout));
|
addToRecycledViews(mAdapter.createView(mLinearLayout));
|
||||||
if (mRecycledViews.get(mRecycledViews.size() - 1).getParent() != null) {
|
|
||||||
throw new RuntimeException("Recycled child has parent");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user