示例#1
0
 /**
  * Close the custom view applying an animation to close the view to the left side of the screen.
  */
 public void closeToLeft() {
   if (viewDragHelper.smoothSlideViewTo(
       dragView,
       -transformer.getOriginalWidth(),
       getHeight() - transformer.getMinHeightPlusMargin())) {
     ViewCompat.postInvalidateOnAnimation(this);
     notifyCloseToLeftListener();
   }
 }
示例#2
0
 /** Override method to configure the dragged view and secondView layout properly. */
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   if (isInEditMode()) super.onLayout(changed, left, top, right, bottom);
   else if (isDragViewAtTop()) {
     dragView.layout(left, top, right, transformer.getOriginalHeight());
     secondView.layout(left, transformer.getOriginalHeight(), right, bottom);
     ViewHelper.setY(dragView, top);
     ViewHelper.setY(secondView, transformer.getOriginalHeight());
   } else {
     secondView.layout(left, transformer.getOriginalHeight(), right, bottom);
   }
 }
示例#3
0
 /**
  * Realize an smooth slide to an slide offset passed as argument. This method is the base of
  * maximize, minimize and close methods.
  *
  * @param slideOffset to apply
  * @return true if the view is slided.
  */
 private boolean smoothSlideTo(float slideOffset) {
   final int topBound = getPaddingTop();
   int x = (int) (slideOffset * (getWidth() - transformer.getMinWidthPlusMarginRight()));
   int y = (int) (topBound + slideOffset * getVerticalDragRange());
   if (viewDragHelper.smoothSlideViewTo(dragView, x, y)) {
     ViewCompat.postInvalidateOnAnimation(this);
     return true;
   }
   return false;
 }
示例#4
0
 /** Initialize Transformer with a scalable or change width/height implementation. */
 private void initializeTransformer(TypedArray attributes) {
   topViewResize =
       attributes.getBoolean(R.styleable.draggable_view_top_view_resize, DEFAULT_TOP_VIEW_RESIZE);
   TransformerFactory transformerFactory = new TransformerFactory();
   transformer = transformerFactory.getTransformer(topViewResize, dragView, this);
   transformer.setViewHeight(
       attributes.getDimensionPixelSize(
           R.styleable.draggable_view_top_view_height, DEFAULT_TOP_VIEW_HEIGHT));
   transformer.setXScaleFactor(
       attributes.getFloat(
           R.styleable.draggable_view_top_view_x_scale_factor, DEFAULT_SCALE_FACTOR));
   transformer.setYScaleFactor(
       attributes.getFloat(
           R.styleable.draggable_view_top_view_y_scale_factor, DEFAULT_SCALE_FACTOR));
   transformer.setMarginRight(
       attributes.getDimensionPixelSize(
           R.styleable.draggable_view_top_view_margin_right, DEFAULT_TOP_VIEW_MARGIN));
   transformer.setMarginBottom(
       attributes.getDimensionPixelSize(
           R.styleable.draggable_view_top_view_margin_bottom, DEFAULT_TOP_VIEW_MARGIN));
 }
示例#5
0
 /**
  * Check if dragged view is at the bottom of the custom view.
  *
  * @return true if dragged view bottom position is equals to custom view height.
  */
 boolean isDragViewAtBottom() {
   return transformer.isViewAtBottom();
 }
示例#6
0
 /**
  * Check if dragged view is at the right of the custom view.
  *
  * @return true if dragged view right position is equals to custom view width.
  */
 boolean isDragViewAtRight() {
   return transformer.isViewAtRight();
 }
示例#7
0
 /** Configure the dragView margin bottom applied when the dragView is minimized. */
 public void setTopViewMarginBottom(int topFragmentMarginBottom) {
   transformer.setMarginBottom(topFragmentMarginBottom);
 }
示例#8
0
 /**
  * Configure the horizontal scale factor applied when the view is dragged to the bottom of the
  * custom view.
  */
 public void setXTopViewScaleFactor(float xScaleFactor) {
   transformer.setXScaleFactor(xScaleFactor);
 }
示例#9
0
 /**
  * Calculate the vertical drag range between the custom view and dragged view.
  *
  * @return the difference between the custom view height and the dragged view height.
  */
 private float getVerticalDragRange() {
   return getHeight() - transformer.getMinHeightPlusMargin();
 }
示例#10
0
 /**
  * Check if dragged view is above the middle of the custom view.
  *
  * @return true if dragged view is above the middle of the custom view or false if is below.
  */
 boolean isDragViewAboveTheMiddle() {
   return transformer.isAboveTheMiddle();
 }
示例#11
0
 /** Modify dragged view scale based on the dragged view vertical position and the scale factor. */
 void changeDragViewScale() {
   transformer.updateScale(getVerticalDragOffset());
 }
示例#12
0
 /**
  * Modify dragged view pivot based on the dragged view vertical position to simulate a horizontal
  * displacement while the view is dragged.
  */
 void changeDragViewPosition() {
   transformer.updatePosition(getVerticalDragOffset());
 }
示例#13
0
 /**
  * Configure the dragged view height.
  *
  * @param topFragmentHeight in pixels
  */
 public void setTopViewHeight(int topFragmentHeight) {
   transformer.setViewHeight(topFragmentHeight);
 }
示例#14
0
 /** @return configured dragged view margin right configured. */
 private int getDragViewMarginRight() {
   return transformer.getMarginRight();
 }
示例#15
0
 /**
  * Check if dragged view is next to the left bound.
  *
  * @return true if dragged view right position is behind the right half of the custom view.
  */
 boolean isNextToLeftBound() {
   return transformer.isNextToLeftBound();
 }
示例#16
0
 /** @return configured dragged view margin bottom. */
 private int getDragViewMarginBottom() {
   return transformer.getMarginBottom();
 }
示例#17
0
 /**
  * Check if dragged view is next to the right bound.
  *
  * @return true if dragged view left position is behind the left quarter of the custom view.
  */
 boolean isNextToRightBound() {
   return transformer.isNextToRightBound();
 }
示例#18
0
 public int getDraggedViewHeightPlusMarginTop() {
   return transformer.getMinHeightPlusMargin();
 }
示例#19
0
 /**
  * Check if dragged view is at the top of the custom view.
  *
  * @return true if dragged view top position is equals to zero.
  */
 boolean isDragViewAtTop() {
   return transformer.isViewAtTop();
 }
示例#20
0
 /**
  * Configure the vertical scale factor applied when the view is dragged to the bottom of the
  * custom view.
  */
 public void setYTopViewScaleFactor(float yScaleFactor) {
   transformer.setYScaleFactor(yScaleFactor);
 }
示例#21
0
 /**
  * Configure the dragged view margin right applied when the dragged view is minimized.
  *
  * @param topFragmentMarginRight in pixels.
  */
 public void setTopViewMarginRight(int topFragmentMarginRight) {
   transformer.setMarginRight(topFragmentMarginRight);
 }