Merge "Fix black bar drawn sometimes when swiping away items in Recents" into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4c8cc720e7
@@ -30,7 +30,7 @@ import android.widget.LinearLayout;
|
|||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
|
||||||
public class RecentsScrollViewPerformanceHelper {
|
public class FadedEdgeDrawHelper {
|
||||||
public static final boolean OPTIMIZE_SW_RENDERED_RECENTS = true;
|
public static final boolean OPTIMIZE_SW_RENDERED_RECENTS = true;
|
||||||
public static final boolean USE_DARK_FADE_IN_HW_ACCELERATED_MODE = true;
|
public static final boolean USE_DARK_FADE_IN_HW_ACCELERATED_MODE = true;
|
||||||
private View mScrollView;
|
private View mScrollView;
|
||||||
@@ -43,18 +43,18 @@ public class RecentsScrollViewPerformanceHelper {
|
|||||||
private Matrix mFadeMatrix;
|
private Matrix mFadeMatrix;
|
||||||
private LinearGradient mFade;
|
private LinearGradient mFade;
|
||||||
|
|
||||||
public static RecentsScrollViewPerformanceHelper create(Context context,
|
public static FadedEdgeDrawHelper create(Context context,
|
||||||
AttributeSet attrs, View scrollView, boolean isVertical) {
|
AttributeSet attrs, View scrollView, boolean isVertical) {
|
||||||
boolean isTablet = context.getResources().
|
boolean isTablet = context.getResources().
|
||||||
getBoolean(R.bool.config_recents_interface_for_tablets);
|
getBoolean(R.bool.config_recents_interface_for_tablets);
|
||||||
if (!isTablet && (OPTIMIZE_SW_RENDERED_RECENTS || USE_DARK_FADE_IN_HW_ACCELERATED_MODE)) {
|
if (!isTablet && (OPTIMIZE_SW_RENDERED_RECENTS || USE_DARK_FADE_IN_HW_ACCELERATED_MODE)) {
|
||||||
return new RecentsScrollViewPerformanceHelper(context, attrs, scrollView, isVertical);
|
return new FadedEdgeDrawHelper(context, attrs, scrollView, isVertical);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecentsScrollViewPerformanceHelper(Context context,
|
public FadedEdgeDrawHelper(Context context,
|
||||||
AttributeSet attrs, View scrollView, boolean isVertical) {
|
AttributeSet attrs, View scrollView, boolean isVertical) {
|
||||||
mScrollView = scrollView;
|
mScrollView = scrollView;
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.View);
|
TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.View);
|
||||||
@@ -64,7 +64,7 @@ public class RecentsScrollViewPerformanceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onAttachedToWindowCallback(
|
public void onAttachedToWindowCallback(
|
||||||
RecentsCallback callback, LinearLayout layout, boolean hardwareAccelerated) {
|
LinearLayout layout, boolean hardwareAccelerated) {
|
||||||
mSoftwareRendered = !hardwareAccelerated;
|
mSoftwareRendered = !hardwareAccelerated;
|
||||||
if ((mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS)
|
if ((mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS)
|
||||||
|| USE_DARK_FADE_IN_HW_ACCELERATED_MODE) {
|
|| USE_DARK_FADE_IN_HW_ACCELERATED_MODE) {
|
||||||
@@ -178,11 +178,11 @@ public class RecentsScrollViewPerformanceHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVerticalFadingEdgeLengthCallback() {
|
public int getVerticalFadingEdgeLength() {
|
||||||
return mFadingEdgeLength;
|
return mFadingEdgeLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHorizontalFadingEdgeLengthCallback() {
|
public int getHorizontalFadingEdgeLength() {
|
||||||
return mFadingEdgeLength;
|
return mFadingEdgeLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,16 +49,17 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
private RecentsCallback mCallback;
|
private RecentsCallback mCallback;
|
||||||
protected int mLastScrollPosition;
|
protected int mLastScrollPosition;
|
||||||
private SwipeHelper mSwipeHelper;
|
private SwipeHelper mSwipeHelper;
|
||||||
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
|
private FadedEdgeDrawHelper mFadedEdgeDrawHelper;
|
||||||
private HashSet<View> mRecycledViews;
|
private HashSet<View> mRecycledViews;
|
||||||
private int mNumItemsInOneScreenful;
|
private int mNumItemsInOneScreenful;
|
||||||
|
private Runnable mOnScrollListener;
|
||||||
|
|
||||||
public RecentsHorizontalScrollView(Context context, AttributeSet attrs) {
|
public RecentsHorizontalScrollView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs, 0);
|
super(context, attrs, 0);
|
||||||
float densityScale = getResources().getDisplayMetrics().density;
|
float densityScale = getResources().getDisplayMetrics().density;
|
||||||
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);
|
mFadedEdgeDrawHelper = FadedEdgeDrawHelper.create(context, attrs, this, false);
|
||||||
mRecycledViews = new HashSet<View>();
|
mRecycledViews = new HashSet<View>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +109,8 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
|
|
||||||
final View view = mAdapter.getView(i, old, mLinearLayout);
|
final View view = mAdapter.getView(i, old, mLinearLayout);
|
||||||
|
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
mPerformanceHelper.addViewCallback(view);
|
mFadedEdgeDrawHelper.addViewCallback(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnTouchListener noOpListener = new OnTouchListener() {
|
OnTouchListener noOpListener = new OnTouchListener() {
|
||||||
@@ -234,36 +235,32 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void drawFadedEdges(Canvas canvas, int left, int right, int top, int bottom) {
|
||||||
super.draw(canvas);
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
|
|
||||||
if (mPerformanceHelper != null) {
|
mFadedEdgeDrawHelper.drawCallback(canvas,
|
||||||
int paddingLeft = mPaddingLeft;
|
|
||||||
final boolean offsetRequired = isPaddingOffsetRequired();
|
|
||||||
if (offsetRequired) {
|
|
||||||
paddingLeft += getLeftPaddingOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
int left = mScrollX + paddingLeft;
|
|
||||||
int right = left + mRight - mLeft - mPaddingRight - paddingLeft;
|
|
||||||
int top = mScrollY + getFadeTop(offsetRequired);
|
|
||||||
int bottom = top + getFadeHeight(offsetRequired);
|
|
||||||
|
|
||||||
if (offsetRequired) {
|
|
||||||
right += getRightPaddingOffset();
|
|
||||||
bottom += getBottomPaddingOffset();
|
|
||||||
}
|
|
||||||
mPerformanceHelper.drawCallback(canvas,
|
|
||||||
left, right, top, bottom, mScrollX, mScrollY,
|
left, right, top, bottom, mScrollX, mScrollY,
|
||||||
0, 0,
|
0, 0,
|
||||||
getLeftFadingEdgeStrength(), getRightFadingEdgeStrength(), mPaddingTop);
|
getLeftFadingEdgeStrength(), getRightFadingEdgeStrength(), mPaddingTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||||
|
super.onScrollChanged(l, t, oldl, oldt);
|
||||||
|
if (mOnScrollListener != null) {
|
||||||
|
mOnScrollListener.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnScrollListener(Runnable listener) {
|
||||||
|
mOnScrollListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVerticalFadingEdgeLength() {
|
public int getVerticalFadingEdgeLength() {
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
return mPerformanceHelper.getVerticalFadingEdgeLengthCallback();
|
return mFadedEdgeDrawHelper.getVerticalFadingEdgeLength();
|
||||||
} else {
|
} else {
|
||||||
return super.getVerticalFadingEdgeLength();
|
return super.getVerticalFadingEdgeLength();
|
||||||
}
|
}
|
||||||
@@ -271,8 +268,8 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHorizontalFadingEdgeLength() {
|
public int getHorizontalFadingEdgeLength() {
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
return mPerformanceHelper.getHorizontalFadingEdgeLengthCallback();
|
return mFadedEdgeDrawHelper.getHorizontalFadingEdgeLength();
|
||||||
} else {
|
} else {
|
||||||
return super.getHorizontalFadingEdgeLength();
|
return super.getHorizontalFadingEdgeLength();
|
||||||
}
|
}
|
||||||
@@ -290,9 +287,8 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
mPerformanceHelper.onAttachedToWindowCallback(
|
mFadedEdgeDrawHelper.onAttachedToWindowCallback(mLinearLayout, isHardwareAccelerated());
|
||||||
mCallback, mLinearLayout, isHardwareAccelerated());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.content.res.Configuration;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Shader.TileMode;
|
import android.graphics.Shader.TileMode;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
@@ -74,7 +75,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
private PopupMenu mPopup;
|
private PopupMenu mPopup;
|
||||||
private View mRecentsScrim;
|
private View mRecentsScrim;
|
||||||
private View mRecentsNoApps;
|
private View mRecentsNoApps;
|
||||||
private ViewGroup mRecentsContainer;
|
private RecentsScrollView mRecentsContainer;
|
||||||
|
|
||||||
private boolean mShowing;
|
private boolean mShowing;
|
||||||
private boolean mWaitingToShow;
|
private boolean mWaitingToShow;
|
||||||
@@ -98,6 +99,8 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
public void setCallback(RecentsCallback callback);
|
public void setCallback(RecentsCallback callback);
|
||||||
public void setMinSwipeAlpha(float minAlpha);
|
public void setMinSwipeAlpha(float minAlpha);
|
||||||
public View findViewForTask(int persistentTaskId);
|
public View findViewForTask(int persistentTaskId);
|
||||||
|
public void drawFadedEdges(Canvas c, int left, int right, int top, int bottom);
|
||||||
|
public void setOnScrollListener(Runnable listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class OnLongClickDelegate implements View.OnLongClickListener {
|
private final class OnLongClickDelegate implements View.OnLongClickListener {
|
||||||
@@ -270,13 +273,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int numItemsInOneScreenful() {
|
public int numItemsInOneScreenful() {
|
||||||
if (mRecentsContainer instanceof RecentsScrollView){
|
return mRecentsContainer.numItemsInOneScreenful();
|
||||||
RecentsScrollView scrollView
|
|
||||||
= (RecentsScrollView) mRecentsContainer;
|
|
||||||
return scrollView.numItemsInOneScreenful();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("missing Recents[Horizontal]ScrollView");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean pointInside(int x, int y, View v) {
|
private boolean pointInside(int x, int y, View v) {
|
||||||
@@ -288,7 +285,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInContentArea(int x, int y) {
|
public boolean isInContentArea(int x, int y) {
|
||||||
return pointInside(x, y, mRecentsContainer);
|
return pointInside(x, y, (View) mRecentsContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(boolean show) {
|
public void show(boolean show) {
|
||||||
@@ -436,16 +433,16 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
mRecentsContainer = (ViewGroup) findViewById(R.id.recents_container);
|
mRecentsContainer = (RecentsScrollView) findViewById(R.id.recents_container);
|
||||||
|
mRecentsContainer.setOnScrollListener(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
// need to redraw the faded edges
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
});
|
||||||
mListAdapter = new TaskDescriptionAdapter(mContext);
|
mListAdapter = new TaskDescriptionAdapter(mContext);
|
||||||
if (mRecentsContainer instanceof RecentsScrollView){
|
mRecentsContainer.setAdapter(mListAdapter);
|
||||||
RecentsScrollView scrollView
|
mRecentsContainer.setCallback(this);
|
||||||
= (RecentsScrollView) mRecentsContainer;
|
|
||||||
scrollView.setAdapter(mListAdapter);
|
|
||||||
scrollView.setCallback(this);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("missing Recents[Horizontal]ScrollView");
|
|
||||||
}
|
|
||||||
|
|
||||||
mRecentsScrim = findViewById(R.id.recents_bg_protect);
|
mRecentsScrim = findViewById(R.id.recents_bg_protect);
|
||||||
mRecentsNoApps = findViewById(R.id.recents_no_apps);
|
mRecentsNoApps = findViewById(R.id.recents_no_apps);
|
||||||
@@ -462,11 +459,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMinSwipeAlpha(float minAlpha) {
|
public void setMinSwipeAlpha(float minAlpha) {
|
||||||
if (mRecentsContainer instanceof RecentsScrollView){
|
mRecentsContainer.setMinSwipeAlpha(minAlpha);
|
||||||
RecentsScrollView scrollView
|
|
||||||
= (RecentsScrollView) mRecentsContainer;
|
|
||||||
scrollView.setMinSwipeAlpha(minAlpha);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCustomAnimations(LayoutTransition transitioner) {
|
private void createCustomAnimations(LayoutTransition transitioner) {
|
||||||
@@ -524,7 +517,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
void onTaskThumbnailLoaded(TaskDescription td) {
|
void onTaskThumbnailLoaded(TaskDescription td) {
|
||||||
synchronized (td) {
|
synchronized (td) {
|
||||||
if (mRecentsContainer != null) {
|
if (mRecentsContainer != null) {
|
||||||
ViewGroup container = mRecentsContainer;
|
ViewGroup container = (ViewGroup) mRecentsContainer;
|
||||||
if (container instanceof RecentsScrollView) {
|
if (container instanceof RecentsScrollView) {
|
||||||
container = (ViewGroup) container.findViewById(
|
container = (ViewGroup) container.findViewById(
|
||||||
R.id.recents_linear_layout);
|
R.id.recents_linear_layout);
|
||||||
@@ -633,7 +626,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
final int items = mRecentTaskDescriptions != null
|
final int items = mRecentTaskDescriptions != null
|
||||||
? mRecentTaskDescriptions.size() : 0;
|
? mRecentTaskDescriptions.size() : 0;
|
||||||
|
|
||||||
mRecentsContainer.setVisibility(items > 0 ? View.VISIBLE : View.GONE);
|
((View) mRecentsContainer).setVisibility(items > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
// Set description for accessibility
|
// Set description for accessibility
|
||||||
int numRecentApps = mRecentTaskDescriptions != null
|
int numRecentApps = mRecentTaskDescriptions != null
|
||||||
@@ -650,14 +643,10 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean simulateClick(int persistentTaskId) {
|
public boolean simulateClick(int persistentTaskId) {
|
||||||
if (mRecentsContainer instanceof RecentsScrollView){
|
View v = mRecentsContainer.findViewForTask(persistentTaskId);
|
||||||
RecentsScrollView scrollView
|
if (v != null) {
|
||||||
= (RecentsScrollView) mRecentsContainer;
|
handleOnClick(v);
|
||||||
View v = scrollView.findViewForTask(persistentTaskId);
|
return true;
|
||||||
if (v != null) {
|
|
||||||
handleOnClick(v);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -775,7 +764,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
if (item.getItemId() == R.id.recent_remove_item) {
|
if (item.getItemId() == R.id.recent_remove_item) {
|
||||||
mRecentsContainer.removeViewInLayout(selectedView);
|
((ViewGroup) mRecentsContainer).removeViewInLayout(selectedView);
|
||||||
} else if (item.getItemId() == R.id.recent_inspect_item) {
|
} else if (item.getItemId() == R.id.recent_inspect_item) {
|
||||||
ViewHolder viewHolder = (ViewHolder) selectedView.getTag();
|
ViewHolder viewHolder = (ViewHolder) selectedView.getTag();
|
||||||
if (viewHolder != null) {
|
if (viewHolder != null) {
|
||||||
@@ -799,4 +788,26 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
|
|||||||
});
|
});
|
||||||
popup.show();
|
popup.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
|
super.dispatchDraw(canvas);
|
||||||
|
|
||||||
|
int paddingLeft = mPaddingLeft;
|
||||||
|
final boolean offsetRequired = isPaddingOffsetRequired();
|
||||||
|
if (offsetRequired) {
|
||||||
|
paddingLeft += getLeftPaddingOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
int left = mScrollX + paddingLeft;
|
||||||
|
int right = left + mRight - mLeft - mPaddingRight - paddingLeft;
|
||||||
|
int top = mScrollY + getFadeTop(offsetRequired);
|
||||||
|
int bottom = top + getFadeHeight(offsetRequired);
|
||||||
|
|
||||||
|
if (offsetRequired) {
|
||||||
|
right += getRightPaddingOffset();
|
||||||
|
bottom += getBottomPaddingOffset();
|
||||||
|
}
|
||||||
|
mRecentsContainer.drawFadedEdges(canvas, left, right, top, bottom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,10 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
private RecentsCallback mCallback;
|
private RecentsCallback mCallback;
|
||||||
protected int mLastScrollPosition;
|
protected int mLastScrollPosition;
|
||||||
private SwipeHelper mSwipeHelper;
|
private SwipeHelper mSwipeHelper;
|
||||||
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
|
private FadedEdgeDrawHelper mFadedEdgeDrawHelper;
|
||||||
private HashSet<View> mRecycledViews;
|
private HashSet<View> mRecycledViews;
|
||||||
private int mNumItemsInOneScreenful;
|
private int mNumItemsInOneScreenful;
|
||||||
|
private Runnable mOnScrollListener;
|
||||||
|
|
||||||
public RecentsVerticalScrollView(Context context, AttributeSet attrs) {
|
public RecentsVerticalScrollView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs, 0);
|
super(context, attrs, 0);
|
||||||
@@ -59,7 +60,7 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
|
float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
|
||||||
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
|
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
|
||||||
|
|
||||||
mPerformanceHelper = RecentsScrollViewPerformanceHelper.create(context, attrs, this, true);
|
mFadedEdgeDrawHelper = FadedEdgeDrawHelper.create(context, attrs, this, true);
|
||||||
mRecycledViews = new HashSet<View>();
|
mRecycledViews = new HashSet<View>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +113,8 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
}
|
}
|
||||||
final View view = mAdapter.getView(i, old, mLinearLayout);
|
final View view = mAdapter.getView(i, old, mLinearLayout);
|
||||||
|
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
mPerformanceHelper.addViewCallback(view);
|
mFadedEdgeDrawHelper.addViewCallback(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnTouchListener noOpListener = new OnTouchListener() {
|
OnTouchListener noOpListener = new OnTouchListener() {
|
||||||
@@ -243,36 +244,32 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void drawFadedEdges(Canvas canvas, int left, int right, int top, int bottom) {
|
||||||
super.draw(canvas);
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
|
|
||||||
if (mPerformanceHelper != null) {
|
|
||||||
int paddingLeft = mPaddingLeft;
|
|
||||||
final boolean offsetRequired = isPaddingOffsetRequired();
|
final boolean offsetRequired = isPaddingOffsetRequired();
|
||||||
if (offsetRequired) {
|
mFadedEdgeDrawHelper.drawCallback(canvas,
|
||||||
paddingLeft += getLeftPaddingOffset();
|
left, right, top + getFadeTop(offsetRequired), bottom, mScrollX, mScrollY,
|
||||||
}
|
|
||||||
|
|
||||||
int left = mScrollX + paddingLeft;
|
|
||||||
int right = left + mRight - mLeft - mPaddingRight - paddingLeft;
|
|
||||||
int top = mScrollY + getFadeTop(offsetRequired);
|
|
||||||
int bottom = top + getFadeHeight(offsetRequired);
|
|
||||||
|
|
||||||
if (offsetRequired) {
|
|
||||||
right += getRightPaddingOffset();
|
|
||||||
bottom += getBottomPaddingOffset();
|
|
||||||
}
|
|
||||||
mPerformanceHelper.drawCallback(canvas,
|
|
||||||
left, right, top, bottom, mScrollX, mScrollY,
|
|
||||||
getTopFadingEdgeStrength(), getBottomFadingEdgeStrength(),
|
getTopFadingEdgeStrength(), getBottomFadingEdgeStrength(),
|
||||||
0, 0, mPaddingTop);
|
0, 0, mPaddingTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||||
|
super.onScrollChanged(l, t, oldl, oldt);
|
||||||
|
if (mOnScrollListener != null) {
|
||||||
|
mOnScrollListener.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnScrollListener(Runnable listener) {
|
||||||
|
mOnScrollListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVerticalFadingEdgeLength() {
|
public int getVerticalFadingEdgeLength() {
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
return mPerformanceHelper.getVerticalFadingEdgeLengthCallback();
|
return mFadedEdgeDrawHelper.getVerticalFadingEdgeLength();
|
||||||
} else {
|
} else {
|
||||||
return super.getVerticalFadingEdgeLength();
|
return super.getVerticalFadingEdgeLength();
|
||||||
}
|
}
|
||||||
@@ -280,8 +277,8 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHorizontalFadingEdgeLength() {
|
public int getHorizontalFadingEdgeLength() {
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
return mPerformanceHelper.getHorizontalFadingEdgeLengthCallback();
|
return mFadedEdgeDrawHelper.getHorizontalFadingEdgeLength();
|
||||||
} else {
|
} else {
|
||||||
return super.getHorizontalFadingEdgeLength();
|
return super.getHorizontalFadingEdgeLength();
|
||||||
}
|
}
|
||||||
@@ -299,9 +296,8 @@ public class RecentsVerticalScrollView extends ScrollView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
if (mPerformanceHelper != null) {
|
if (mFadedEdgeDrawHelper != null) {
|
||||||
mPerformanceHelper.onAttachedToWindowCallback(
|
mFadedEdgeDrawHelper.onAttachedToWindowCallback(mLinearLayout, isHardwareAccelerated());
|
||||||
mCallback, mLinearLayout, isHardwareAccelerated());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user