Example #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();
   }
 }
Example #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);
   }
 }
Example #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;
 }
Example #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));
 }
Example #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();
 }
Example #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();
 }
Example #7
0
 /** Configure the dragView margin bottom applied when the dragView is minimized. */
 public void setTopViewMarginBottom(int topFragmentMarginBottom) {
   transformer.setMarginBottom(topFragmentMarginBottom);
 }
Example #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);
 }
Example #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();
 }
Example #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();
 }
Example #11
0
 /** Modify dragged view scale based on the dragged view vertical position and the scale factor. */
 void changeDragViewScale() {
   transformer.updateScale(getVerticalDragOffset());
 }
Example #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());
 }
Example #13
0
 /**
  * Configure the dragged view height.
  *
  * @param topFragmentHeight in pixels
  */
 public void setTopViewHeight(int topFragmentHeight) {
   transformer.setViewHeight(topFragmentHeight);
 }
Example #14
0
 /** @return configured dragged view margin right configured. */
 private int getDragViewMarginRight() {
   return transformer.getMarginRight();
 }
Example #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();
 }
Example #16
0
 /** @return configured dragged view margin bottom. */
 private int getDragViewMarginBottom() {
   return transformer.getMarginBottom();
 }
Example #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();
 }
Example #18
0
 public int getDraggedViewHeightPlusMarginTop() {
   return transformer.getMinHeightPlusMargin();
 }
Example #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();
 }
Example #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);
 }
Example #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);
 }