diff --git a/README.md b/README.md index 972f852..a339048 100644 --- a/README.md +++ b/README.md @@ -168,17 +168,6 @@ Do you want to resize the top view instead of scale it? Add ``dragable_view:top_ draggable_view:top_view_resize="true"> ``` -Building the sample app ------------------------ - -youtube-android-player-api is required to successfully build and open the sample app in Android Studio. -Unfortunately this library has not been published to Maven central, so you will need to download and deploy it locally. -The [mvn-install-youtubeplayerapi.sh script][19] can be used to easily do this with the following three commands: - - wget https://raw.githubusercontent.com/wuman/youtube-android-player-mvn-install/master/mvn-install-youtubeplayerapi.sh - chmod +x mvn-install-youtubeplayerapi.sh - ./mvn-install-youtubeplayerapi.sh - Do you want to contribute? TODO ------------------------------- diff --git a/build.gradle b/build.gradle index 5c5b600..8d0a477 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.12.2' + classpath 'com.android.tools.build:gradle:0.12.2' } } diff --git a/draggablepanel/build.gradle b/draggablepanel/build.gradle index 272e796..149fbde 100644 --- a/draggablepanel/build.gradle +++ b/draggablepanel/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'checkstyle' dependencies { - compile 'com.android.support:support-v4:20.0.0' + compile 'com.android.support:support-v4:20.0.0' compile 'com.nineoldandroids:library:2.4.0' } diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java b/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java index 027e1eb..97e55c1 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java @@ -34,9 +34,9 @@ */ public class DraggablePanel extends FrameLayout { - private static final float DEFAULT_TOP_FRAGMENT_HEIGHT = 200; + private static final int DEFAULT_TOP_FRAGMENT_HEIGHT = 200; + private static final int DEFAULT_TOP_FRAGMENT_MARGIN = 0; private static final float DEFAULT_SCALE_FACTOR = 2; - private static final float DEFAULT_TOP_FRAGMENT_MARGIN = 0; private static final boolean DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT = true; private static final boolean DEFAULT_TOP_FRAGMENT_RESIZE = false; @@ -46,9 +46,9 @@ public class DraggablePanel extends FrameLayout { private FragmentManager fragmentManager; private Fragment topFragment; private Fragment bottomFragment; - private float topFragmentHeight; - private float topFragmentMarginRight; - private float topFragmentMarginBottom; + private int topFragmentHeight; + private int topFragmentMarginRight; + private int topFragmentMarginBottom; private float xScaleFactor; private float yScaleFactor; private boolean enableHorizontalAlphaEffect; @@ -99,7 +99,7 @@ public void setBottomFragment(Fragment bottomFragment) { * * @param topFragmentHeight in pixels. */ - public void setTopViewHeight(float topFragmentHeight) { + public void setTopViewHeight(int topFragmentHeight) { this.topFragmentHeight = topFragmentHeight; } @@ -124,7 +124,7 @@ public void setYScaleFactor(float yScaleFactor) { * * @param topFragmentMarginRight in pixels. */ - public void setTopFragmentMarginRight(float topFragmentMarginRight) { + public void setTopFragmentMarginRight(int topFragmentMarginRight) { this.topFragmentMarginRight = topFragmentMarginRight; } @@ -133,7 +133,7 @@ public void setTopFragmentMarginRight(float topFragmentMarginRight) { * * @param topFragmentMarginBottom in pixels. */ - public void setTopFragmentMarginBottom(float topFragmentMarginBottom) { + public void setTopFragmentMarginBottom(int topFragmentMarginBottom) { this.topFragmentMarginBottom = topFragmentMarginBottom; } @@ -253,17 +253,17 @@ public boolean isClosedAtLeft() { private void initializeAttrs(AttributeSet attrs) { TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.draggable_panel); this.topFragmentHeight = - attributes.getDimension(R.styleable.draggable_panel_top_fragment_height, + attributes.getDimensionPixelSize(R.styleable.draggable_panel_top_fragment_height, DEFAULT_TOP_FRAGMENT_HEIGHT); this.xScaleFactor = attributes.getFloat(R.styleable.draggable_panel_x_scale_factor, DEFAULT_SCALE_FACTOR); this.yScaleFactor = attributes.getFloat(R.styleable.draggable_panel_y_scale_factor, DEFAULT_SCALE_FACTOR); this.topFragmentMarginRight = - attributes.getDimension(R.styleable.draggable_panel_top_fragment_margin_right, + attributes.getDimensionPixelSize(R.styleable.draggable_panel_top_fragment_margin_right, DEFAULT_TOP_FRAGMENT_MARGIN); this.topFragmentMarginBottom = - attributes.getDimension(R.styleable.draggable_panel_top_fragment_margin_bottom, + attributes.getDimensionPixelSize(R.styleable.draggable_panel_top_fragment_margin_bottom, DEFAULT_TOP_FRAGMENT_MARGIN); this.enableHorizontalAlphaEffect = attributes.getBoolean(R.styleable.draggable_panel_enable_horizontal_alpha_effect, diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java index d2c72d4..57bab15 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java @@ -40,7 +40,7 @@ public class DraggableView extends RelativeLayout { private static final int DEFAULT_SCALE_FACTOR = 2; private static final int DEFAULT_TOP_VIEW_MARGIN = 30; - private static final float DEFAULT_TOP_VIEW_HEIGHT = -1; + private static final int DEFAULT_TOP_VIEW_HEIGHT = -1; private static final float SLIDE_TOP = 0f; private static final float SLIDE_BOTTOM = 1f; private static final boolean DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT = true; @@ -96,14 +96,14 @@ public void setYTopViewScaleFactor(float yScaleFactor) { * * @param topFragmentMarginRight in pixels. */ - public void setTopViewMarginRight(float topFragmentMarginRight) { + public void setTopViewMarginRight(int topFragmentMarginRight) { transformer.setMarginRight(topFragmentMarginRight); } /** * Configure the dragView margin bottom applied when the dragView is minimized. */ - public void setTopViewMarginBottom(float topFragmentMarginBottom) { + public void setTopViewMarginBottom(int topFragmentMarginBottom) { transformer.setMarginBottom(topFragmentMarginBottom); } @@ -290,13 +290,15 @@ private MotionEvent cloneMotionEventWithAction(MotionEvent event, int action) { * 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) { - int newTop = (int) transformer.getViewHeight(); - int lastTopPosition = transformer.getLastTopPosition(); - int lastLeftPosition = transformer.getLastLeftPosition(); - int newRight = transformer.getLastRightPosition(); - int newBottom = lastTopPosition + newTop; - dragView.layout(lastLeftPosition, lastTopPosition, newRight, newBottom); - secondView.layout(0, (int) transformer.getOriginalHeight(), right, getHeight()); + if (isInEditMode()) + super.onLayout(changed, left, top, right, bottom); + else if (isDragViewAtTop()) { + dragView.layout(left, top, right, (int) transformer.getOriginalHeight()); + secondView.layout(left, (int) transformer.getOriginalHeight(), right, bottom); + + ViewHelper.setY(dragView, top); + ViewHelper.setY(secondView, transformer.getOriginalHeight()); + } } /** @@ -348,22 +350,12 @@ void attachBottomFragment(Fragment bottomFragment) { addFragmentToView(R.id.second_view, bottomFragment); } - /** - * Update the last top and left position when the view is dragged. This last positions are used - * to recreate the dragged view and secondView positions if the requestLayout method is called. - */ - void updateLastDragViewPosition(int lastTopPosition, int lastLeftPosition) { - transformer.setLastTopPosition(lastTopPosition); - transformer.setLastLeftPosition(lastLeftPosition); - } - /** * Modify dragged view pivot based on the dragged view vertical position to simulate a horizontal * displacement while the view is dragged. */ void changeDragViewPosition() { - transformer.updateXPosition(getVerticalDragOffset()); - transformer.updateYPosition(getVerticalDragOffset()); + transformer.updatePosition(getVerticalDragOffset()); } /** @@ -377,8 +369,7 @@ void changeSecondViewPosition() { * Modify dragged view scale based on the dragged view vertical position and the scale factor. */ void changeDragViewScale() { - transformer.updateWidth(getVerticalDragOffset()); - transformer.updateHeight(getVerticalDragOffset()); + transformer.updateScale(getVerticalDragOffset()); } /** @@ -524,7 +515,7 @@ private void initializeTransformer(TypedArray attributes) { 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.getDimension(R.styleable.draggable_view_top_view_height, + 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, @@ -533,10 +524,10 @@ private void initializeTransformer(TypedArray attributes) { attributes.getFloat(R.styleable.draggable_view_top_view_y_scale_factor, DEFAULT_SCALE_FACTOR)); transformer.setMarginRight( - attributes.getDimension(R.styleable.draggable_view_top_view_margin_right, + attributes.getDimensionPixelSize(R.styleable.draggable_view_top_view_margin_right, DEFAULT_TOP_VIEW_MARGIN)); transformer.setMarginBottom( - attributes.getDimension(R.styleable.draggable_view_top_view_margin_bottom, + attributes.getDimensionPixelSize(R.styleable.draggable_view_top_view_margin_bottom, DEFAULT_TOP_VIEW_MARGIN)); } @@ -562,7 +553,7 @@ private void initializeAttributes(AttributeSet attrs) { */ private boolean smoothSlideTo(float slideOffset) { final int topBound = getPaddingTop(); - int x = (int) (slideOffset * (getWidth() - transformer.getMinWidth())); + int x = (int) (slideOffset * (getWidth() - transformer.getMinWidthPlusMarginRight())); int y = (int) (topBound + slideOffset * getVerticalDragRange()); if (viewDragHelper.smoothSlideViewTo(dragView, x, y)) { ViewCompat.postInvalidateOnAnimation(this); diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java index ca0ea84..6b3098b 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java @@ -26,10 +26,10 @@ */ class DraggableViewCallback extends ViewDragHelper.Callback { - private static final int MINIMUN_DX_FOR_HORIZONTAL_DRAG = 5; + private static final int MINIMUM_DX_FOR_HORIZONTAL_DRAG = 5; private static final int MINIMUM_DY_FOR_VERTICAL_DRAG = 15; - private static final float X_MIN_VELOCITY = 1300; - private static final float Y_MIN_VELOCITY = 1300; + private static final float X_MIN_VELOCITY = 1500; + private static final float Y_MIN_VELOCITY = 1000; private DraggableView draggableView; private View draggedView; @@ -54,7 +54,7 @@ public DraggableViewCallback(DraggableView draggableView, View draggedView) { * @param dy change in Y position from the last call. */ @Override public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { - draggableView.updateLastDragViewPosition(top, left); + if (draggableView.isDragViewAtBottom()) { draggableView.changeDragViewViewAlpha(); } else { @@ -65,6 +65,9 @@ public DraggableViewCallback(DraggableView draggableView, View draggedView) { draggableView.changeSecondViewPosition(); draggableView.changeBackgroundAlpha(); } + if (0 == top) { + draggableView.requestLayout(); + } } /** @@ -108,7 +111,7 @@ public DraggableViewCallback(DraggableView draggableView, View draggedView) { */ @Override public int clampViewPositionHorizontal(View child, int left, int dx) { int newLeft = draggedView.getLeft(); - if ((draggableView.isMinimized() && Math.abs(dx) > MINIMUN_DX_FOR_HORIZONTAL_DRAG) || ( + if ((draggableView.isMinimized() && Math.abs(dx) > MINIMUM_DX_FOR_HORIZONTAL_DRAG) || ( draggableView.isDragViewAtBottom() && !draggableView.isDragViewAtRight())) { newLeft = left; diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ResizeTransformer.java b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ResizeTransformer.java index 322aa21..6af7bc3 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ResizeTransformer.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ResizeTransformer.java @@ -26,66 +26,41 @@ */ class ResizeTransformer extends Transformer { - private float lastHeight; + private final RelativeLayout.LayoutParams layoutParams; ResizeTransformer(View view, View parent) { super(view, parent); + layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams(); } /** - * Changes view width using view's LayoutParam. + * Changes view scale using view's LayoutParam. * - * @param verticalDragOffset used to calculate the new width. + * @param verticalDragOffset used to calculate the new size. */ - @Override public void updateWidth(float verticalDragOffset) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getView().getLayoutParams(); - int newWidth = (int) (getOriginalWidth() * (1 - verticalDragOffset / getXScaleFactor())); - params.width = newWidth; - setLastLeftPosition((int) (getOriginalWidth() - newWidth)); - getView().setLayoutParams(params); - } + @Override public void updateScale(float verticalDragOffset) { + layoutParams.width = (int) (getOriginalWidth() * (1 - verticalDragOffset / getXScaleFactor())); + layoutParams.height = (int) (getOriginalHeight() * (1 - verticalDragOffset / getYScaleFactor())); - /** - * Changes view height using view's LayoutParam. - * - * @param verticalDragOffset used to calculate the new width. - */ - @Override public void updateHeight(float verticalDragOffset) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getView().getLayoutParams(); - int newHeight = (int) (getOriginalHeight() * (1 - verticalDragOffset / getYScaleFactor())); - params.height = newHeight; - lastHeight = newHeight; - getView().setLayoutParams(params); + getView().setLayoutParams(layoutParams); } - /** - * @return last updated height or the view height if the view hasn't been changed yet. - */ - @Override public float getViewHeight() { - return lastHeight == 0 ? super.getViewHeight() : lastHeight; - } /** * Changes X view position using layout() method. * * @param verticalDragOffset used to calculate the new X position. */ - @Override public void updateXPosition(float verticalDragOffset) { - int left, top, right, bottom; - left = (int) (getOriginalWidth() - getViewWidth()); - right = getViewRightPosition(verticalDragOffset); - setLastRightPosition(right); - top = getView().getTop(); - bottom = getView().getBottom(); + @Override + public void updatePosition(float verticalDragOffset) { + int right = getViewRightPosition(verticalDragOffset); + int left = right - layoutParams.width; + int top = getView().getTop(); + int bottom = top + layoutParams.height; + getView().layout(left, top, right, bottom); } - /** - * Empty implementation. ViewDragHelper already changes the Y position. - */ - @Override public void updateYPosition(float verticalDragOffset) { - // Empty - } /** * @return true if the right position of the view plus the right margin is equals to the parent @@ -116,21 +91,21 @@ class ResizeTransformer extends Transformer { * the parent width. */ @Override public boolean isNextToLeftBound() { - return (getView().getLeft() - getMarginRight()) < getParentView().getWidth() * 0.25; + return (getView().getLeft() - getMarginRight()) < getParentView().getWidth() * 0.05; } /** * Uses the Y scale factor to calculate the min possible height. */ @Override public int getMinHeightPlusMargin() { - return (int) ((getOriginalHeight() / getYScaleFactor()) + getMarginBottom()); + return (int) (getOriginalHeight() * (1 - 1 / getYScaleFactor()) + getMarginBottom()); } /** * Uses the X scale factor to calculate the min possible width. */ - @Override public int getMinWidth() { - return (int) (getOriginalWidth() / getXScaleFactor()); + @Override public int getMinWidthPlusMarginRight() { + return (int) (getOriginalWidth() * (1 - 1 / getXScaleFactor()) + getMarginRight()); } /** @@ -141,4 +116,5 @@ class ResizeTransformer extends Transformer { private int getViewRightPosition(float verticalDragOffset) { return (int) ((getOriginalWidth()) - getMarginRight() * verticalDragOffset); } + } diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ScaleTransformer.java b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ScaleTransformer.java index 92963b5..e49a13e 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ScaleTransformer.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ScaleTransformer.java @@ -32,38 +32,22 @@ class ScaleTransformer extends Transformer { } /** - * Uses Nineoldandroids to change the scale in the X axis. + * Uses Nineoldandroids to change the scale. * * @param verticalDragOffset used to calculate the new scale. */ - @Override public void updateWidth(float verticalDragOffset) { + @Override public void updateScale(float verticalDragOffset) { ViewHelper.setScaleX(getView(), 1 - verticalDragOffset / getXScaleFactor()); - } - - /** - * Uses Nineoldandroids to change the scale in the Y axis. - * - * @param verticalDragOffset used to calculate the new scale. - */ - @Override public void updateHeight(float verticalDragOffset) { ViewHelper.setScaleY(getView(), 1 - verticalDragOffset / getYScaleFactor()); } /** - * Uses Nineoldandroids to change the X position of the view. + * Uses Nineoldandroids to change the position of the view. * - * @param verticalDragOffset used to calculate the new X position. + * @param verticalDragOffset used to calculate the new position. */ - @Override public void updateXPosition(float verticalDragOffset) { + @Override public void updatePosition(float verticalDragOffset) { ViewHelper.setPivotX(getView(), getView().getWidth() - getMarginRight()); - } - - /** - * Uses Nineoldandroids to change the Y position of the view. - * - * @param verticalDragOffset used to calculate the new Y position. - */ - @Override public void updateYPosition(float verticalDragOffset) { ViewHelper.setPivotY(getView(), getView().getHeight() - getMarginBottom()); } @@ -82,7 +66,7 @@ class ScaleTransformer extends Transformer { } /** - * @return true if the right position of the view is to the left of sixty percent of the parent + * @return true if the left position of the view is to the left of sixty percent of the parent * width. */ @Override public boolean isNextToLeftBound() { @@ -93,9 +77,7 @@ class ScaleTransformer extends Transformer { * @return true if the right position of the view is to the right of the one hundred twenty five * five percent of the parent view width. */ - @Override - - public boolean isNextToRightBound() { + @Override public boolean isNextToRightBound() { return (getView().getRight() - getMarginRight()) > getParentView().getWidth() * 1.25; } @@ -109,11 +91,8 @@ public boolean isNextToRightBound() { /** * @return min view width. */ - @Override public int getMinWidth() { - return (int) getOriginalWidth(); + @Override public int getMinWidthPlusMarginRight() { + return getOriginalWidth(); } - @Override public int getLastLeftPosition() { - return 0; - } } diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/Transformer.java b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/Transformer.java index b231a2e..93a248c 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/Transformer.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/Transformer.java @@ -37,16 +37,14 @@ public abstract class Transformer { private final View view; private final View parent; - private float viewHeight; + private int marginRight; + private int marginBottom; + private float xScaleFactor; private float yScaleFactor; - private float marginRight; - private float marginBottom; - private int lastTopPosition; - private int lastLeftPosition; - private int lastRightPosition; - private float originalHeight; - private float originalWidth; + + private int originalHeight; + private int originalWidth; public Transformer(View view, View parent) { this.view = view; @@ -69,69 +67,37 @@ public void setYScaleFactor(float yScaleFactor) { this.yScaleFactor = yScaleFactor; } - public float getMarginRight() { + public int getMarginRight() { return marginRight; } - public void setMarginRight(float marginRight) { - this.marginRight = marginRight; + public void setMarginRight(int marginRight) { + this.marginRight = Math.round(marginRight); } - public float getMarginBottom() { + public int getMarginBottom() { return marginBottom; } - public void setMarginBottom(float marginBottom) { - this.marginBottom = marginBottom; - } - - public float getViewHeight() { - return viewHeight < 0f ? view.getMeasuredHeight() : viewHeight; + public void setMarginBottom(int marginBottom) { + this.marginBottom = Math.round(marginBottom); } /** * Change view height using the LayoutParams of the view. * - * @param viewHeight to change.. + * @param newHeight to change.. */ - public void setViewHeight(float viewHeight) { - this.viewHeight = viewHeight; - if (viewHeight > 0f) { - originalHeight = viewHeight; + public void setViewHeight(int newHeight) { + if (newHeight > 0) { + originalHeight = newHeight; RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams(); - layoutParams.height = (int) viewHeight; + layoutParams.height = newHeight; view.setLayoutParams(layoutParams); } } - public int getLastRightPosition() { - if (lastRightPosition <= 0) { - lastRightPosition = view.getMeasuredWidth(); - } - return lastRightPosition; - } - - public void setLastRightPosition(int lastRightPosition) { - this.lastRightPosition = lastRightPosition; - } - - public int getLastTopPosition() { - return lastTopPosition; - } - - public void setLastTopPosition(int lastTopPosition) { - this.lastTopPosition = lastTopPosition; - } - - public int getLastLeftPosition() { - return lastLeftPosition; - } - - public void setLastLeftPosition(int lastLeftPosition) { - this.lastLeftPosition = lastLeftPosition; - } - protected View getView() { return view; } @@ -140,20 +106,16 @@ protected View getParentView() { return parent; } - public abstract void updateXPosition(float verticalDragOffset); - - public abstract void updateYPosition(float verticalDragOffset); + public abstract void updatePosition(float verticalDragOffset); - public abstract void updateWidth(float verticalDragOffset); - - public abstract void updateHeight(float verticalDragOffset); + public abstract void updateScale(float verticalDragOffset); /** * @return height of the view before it has change the size. */ - public float getOriginalHeight() { + public int getOriginalHeight() { if (originalHeight == 0) { - originalHeight = viewHeight < 0 ? view.getMeasuredHeight() : viewHeight; + originalHeight = view.getMeasuredHeight(); } return originalHeight; } @@ -161,20 +123,13 @@ public float getOriginalHeight() { /** * @return width of the view before it has change the size. */ - public float getOriginalWidth() { + public int getOriginalWidth() { if (originalWidth == 0) { originalWidth = view.getMeasuredWidth(); } return originalWidth; } - /** - * @return current width of the view. - */ - public int getViewWidth() { - return getView().getMeasuredWidth(); - } - public boolean isViewAtTop() { return view.getTop() == 0; } @@ -201,5 +156,5 @@ public boolean isAboveTheMiddle() { /** * @return min possible width, after apply the transformation. */ - public abstract int getMinWidth(); + public abstract int getMinWidthPlusMarginRight(); } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e14ef43..f3a222f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Mon Aug 18 23:56:49 PDT 2014 +#Fri Dec 05 16:34:39 CET 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/sample/AndroidManifest.xml b/sample/AndroidManifest.xml index 725671f..960a0f2 100755 --- a/sample/AndroidManifest.xml +++ b/sample/AndroidManifest.xml @@ -1,11 +1,8 @@ + package="com.github.pedrovgs.sample"> - + diff --git a/sample/build.gradle b/sample/build.gradle index 854b56b..047b963 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -8,10 +8,10 @@ dependencies { compile 'com.squareup.dagger:dagger-compiler:1.1.0' compile 'com.jakewharton:butterknife:4.0.1' compile 'com.squareup.dagger:dagger:1.1.0' - compile 'com.google.android:youtube-android-player-api:1.0.0' compile 'com.github.pedrovgs:renderers:1.0.9' compile 'com.google.android.gms:play-services:4.1.32' compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' + compile files('libs/YouTubeAndroidPlayerApi.jar') } android { diff --git a/sample/libs/YouTubeAndroidPlayerApi.jar b/sample/libs/YouTubeAndroidPlayerApi.jar new file mode 100644 index 0000000..c7825a7 Binary files /dev/null and b/sample/libs/YouTubeAndroidPlayerApi.jar differ diff --git a/sample/res/values/dimens.xml b/sample/res/values/dimens.xml index 0fea593..e61d3e5 100644 --- a/sample/res/values/dimens.xml +++ b/sample/res/values/dimens.xml @@ -6,8 +6,8 @@ 10dip 18sp 10dip - 2 - 2 + 2.3 + 2.3 10dip 10dip 10dip diff --git a/sample/src/main/java/com/github/pedrovgs/sample/activity/PlacesSampleActivity.java b/sample/src/main/java/com/github/pedrovgs/sample/activity/PlacesSampleActivity.java index e323fe4..f7136e4 100644 --- a/sample/src/main/java/com/github/pedrovgs/sample/activity/PlacesSampleActivity.java +++ b/sample/src/main/java/com/github/pedrovgs/sample/activity/PlacesSampleActivity.java @@ -249,11 +249,11 @@ private void initializeDraggablePanel() { float yScaleFactor = typedValue.getFloat(); draggablePanel.setXScaleFactor(xScaleFactor); draggablePanel.setYScaleFactor(yScaleFactor); - draggablePanel.setTopViewHeight(getResources().getDimension(R.dimen.top_fragment_height)); + draggablePanel.setTopViewHeight(getResources().getDimensionPixelSize(R.dimen.top_fragment_height)); draggablePanel.setTopFragmentMarginRight( - getResources().getDimension(R.dimen.top_fragment_margin)); + getResources().getDimensionPixelSize(R.dimen.top_fragment_margin)); draggablePanel.setTopFragmentMarginBottom( - getResources().getDimension(R.dimen.top_fragment_margin)); + getResources().getDimensionPixelSize(R.dimen.top_fragment_margin)); draggablePanel.initializeView(); draggablePanel.setVisibility(View.GONE); }