コード例 #1
0
        public void handleMessage(Message m) {

          if (mSelectionBounds == null) return;

          addView(mSelectionDragLayer);

          drawSelectionHandles();

          int contentHeight =
              (int) Math.ceil(getDensityDependentValue(getContentHeight(), mContext));

          // Update Layout Params
          ViewGroup.LayoutParams layerParams = mSelectionDragLayer.getLayoutParams();
          layerParams.height = contentHeight;
          layerParams.width = mContentWidth;
          mSelectionDragLayer.setLayoutParams(layerParams);
        }
コード例 #2
0
  /**
   * Creates the selection layer.
   *
   * @param context
   */
  protected void createSelectionLayer(Context context) {

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mSelectionDragLayer = (DragLayer) inflater.inflate(R.layout.selection_drag_layer, null);

    // Make sure it's filling parent
    mDragController = new DragController(context);
    mDragController.setDragListener(this);
    mDragController.addDropTarget(mSelectionDragLayer);
    mSelectionDragLayer.setDragController(mDragController);

    mStartSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.startHandle);
    mStartSelectionHandle.setTag(new Integer(SELECTION_START_HANDLE));
    mEndSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.endHandle);
    mEndSelectionHandle.setTag(new Integer(SELECTION_END_HANDLE));

    OnTouchListener handleTouchListener =
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {

            boolean handledHere = false;

            final int action = event.getAction();

            // Down event starts drag for handle.
            if (action == MotionEvent.ACTION_DOWN) {
              handledHere = startDrag(v);
              mLastTouchedSelectionHandle = (Integer) v.getTag();
            }

            return handledHere;
          }
        };

    mStartSelectionHandle.setOnTouchListener(handleTouchListener);
    mEndSelectionHandle.setOnTouchListener(handleTouchListener);
  }
コード例 #3
0
  /**
   * Checks to see if this view is in selection mode.
   *
   * @return
   */
  public boolean isInSelectionMode() {

    return mSelectionDragLayer.getParent() != null;
  }