Ejemplo n.º 1
0
 private void createSelectionLayer(Context context) {
   final LayoutInflater inflater =
       (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   mSelectionDragLayer = (DragLayer) inflater.inflate(R.layout.selection_drag_layer, null);
   mDragController = new DragController(context);
   mDragController.setDragListener(this);
   mDragController.addDropTarget(mSelectionDragLayer);
   mSelectionDragLayer.setDragController(mDragController);
   mStartSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.startHandle);
   mStartSelectionHandle.setTag(HandleType.START);
   mEndSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.endHandle);
   mEndSelectionHandle.setTag(HandleType.END);
   final OnTouchListener handleTouchListener =
       new OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           boolean handledHere = false;
           if (event.getAction() == MotionEvent.ACTION_DOWN) {
             handledHere = startDrag(v);
             mLastTouchedSelectionHandle = (HandleType) v.getTag();
           }
           return handledHere;
         }
       };
   mStartSelectionHandle.setOnTouchListener(handleTouchListener);
   mEndSelectionHandle.setOnTouchListener(handleTouchListener);
 }
Ejemplo n.º 2
0
 public void stopDrag() {
   mDragController.cancelDrag();
 }
Ejemplo n.º 3
0
 private boolean startDrag(View v) {
   Object dragInfo = v;
   mDragController.startDrag(v, mSelectionDragLayer, dragInfo, DragBehavior.MOVE);
   return true;
 }