Move TransformingTouchDelegate logic to BaseContainerView.

In ag/1460444 we used TransformingTouchDelegate to extend the
touch target for the widgets list. Now both WidgetsContainerView
and AllAppsContainerView will use the same TransformingTouchDelegate logic
to extend the touch target for their respective lists.

This is part of a larger refactor where in a follow up CL, we will
handle the logic for dismissing WCV and AACV when touching outside
of its content in BaseContainerView. (currently broken in WCV).

Change-Id: I7fddb456bba34a6533f8824da0481d308a8b715e
This commit is contained in:
Jon Miranda
2016-09-21 14:27:41 -07:00
parent dc733b2c07
commit 177ad2bf89
3 changed files with 46 additions and 119 deletions

View File

@@ -21,7 +21,6 @@ import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView.State;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -50,7 +49,6 @@ 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,12 +63,9 @@ public class WidgetsContainerView extends BaseContainerView
private DragController mDragController;
private IconCache mIconCache;
private final Rect mTmpBgPaddingRect = new Rect();
/* Recycler view related member variables */
private WidgetsRecyclerView mRecyclerView;
private WidgetsListAdapter mAdapter;
private TransformingTouchDelegate mRecyclerViewTouchDelegate;
/* Touch handling related member variables. */
private Toast mWidgetInstructionToast;
@@ -98,14 +93,8 @@ 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);
public View getTouchDelegateTargetView() {
return mRecyclerView;
}
@Override
@@ -114,13 +103,6 @@ public class WidgetsContainerView extends BaseContainerView
mRecyclerView = (WidgetsRecyclerView) getContentView().findViewById(R.id.widgets_list_view);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mRecyclerViewTouchDelegate = new TransformingTouchDelegate(mRecyclerView);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
((View) mRecyclerView.getParent()).setTouchDelegate(mRecyclerViewTouchDelegate);
}
//