Uses a TransformingTouchDelegate to extend touch target for widgets list. am: 0ef81fdc22

am: 48542731c5

Change-Id: Ia2bd1b6e5203f40ce3ef75a05712ee63ccfbf3e3
This commit is contained in:
Jon Miranda
2016-09-19 21:49:27 +00:00
committed by android-build-merger
2 changed files with 19 additions and 18 deletions

View File

@@ -50,6 +50,7 @@ import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TransformingTouchDelegate;
/**
* The widgets list view container.
@@ -65,11 +66,11 @@ public class WidgetsContainerView extends BaseContainerView
private IconCache mIconCache;
private final Rect mTmpBgPaddingRect = new Rect();
private final Rect mTmpRect = new Rect();
/* Recycler view related member variables */
private WidgetsRecyclerView mRecyclerView;
private WidgetsListAdapter mAdapter;
private TransformingTouchDelegate mRecyclerViewTouchDelegate;
/* Touch handling related member variables. */
private Toast mWidgetInstructionToast;
@@ -96,30 +97,30 @@ public class WidgetsContainerView extends BaseContainerView
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
getRevealView().getBackground().getPadding(mTmpBgPaddingRect);
mRecyclerViewTouchDelegate.setBounds(
mRecyclerView.getLeft() - mTmpBgPaddingRect.left,
mRecyclerView.getTop() - mTmpBgPaddingRect.top,
mRecyclerView.getRight() + mTmpBgPaddingRect.right,
mRecyclerView.getBottom() + mTmpBgPaddingRect.bottom);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mRecyclerView = (WidgetsRecyclerView) getContentView().findViewById(R.id.widgets_list_view);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mRecyclerViewTouchDelegate = new TransformingTouchDelegate(mRecyclerView);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
getRevealView().getBackground().getPadding(mTmpBgPaddingRect);
if (Utilities.isRtl(getResources())) {
getContentView().setPadding(0, mTmpBgPaddingRect.top, mTmpBgPaddingRect.right,
mTmpBgPaddingRect.bottom);
mTmpRect.set(mTmpBgPaddingRect.left, 0, 0, 0);
mRecyclerView.updateBackgroundPadding(mTmpRect);
} else {
getContentView().setPadding(mTmpBgPaddingRect.left, mTmpBgPaddingRect.top, 0,
mTmpBgPaddingRect.bottom);
mTmpRect.set(0, 0, mTmpBgPaddingRect.right, 0);
mRecyclerView.updateBackgroundPadding(mTmpRect);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
protected void onAttachedToWindow() {
super.onAttachedToWindow();
((View) mRecyclerView.getParent()).setTouchDelegate(mRecyclerViewTouchDelegate);
}
//