diff --git a/README.md b/README.md index 8063538..b9e4ab9 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ private void initializeDraggablePanel() throws Resources.NotFoundException { Import DraggablePanel dependency -------------------------------- -Download the project, compile it using maven or gradle and import ``draggablepanel-1.0.2.aar`` into your project. +Download the project, compile it using maven or gradle and import ``draggablepanel-1.1.aar`` into your project. Or declare it into your pom.xml. This library uses NineOldAndroid library and Android support library v4 version 19.1.0, you have to provide this dependencies from your local artifact repository or from maven central repository. @@ -97,7 +97,7 @@ Or declare it into your pom.xml. This library uses NineOldAndroid library and An com.github.pedrovgs draggablepanel - 1.0.3 + 1.1 aar ``` @@ -107,7 +107,7 @@ Or into your build.gradle ```groovy dependencies { - compile 'com.github.pedrovgs:draggablepanel:1.0.3@aar' + compile 'com.github.pedrovgs:draggablepanel:1.1@aar' compile 'com.android.support:support-v4:19.1.+' compile 'com.nineoldandroids:library:2.4.+' } @@ -158,14 +158,22 @@ draggablePanel.setTopFragmentMarginBottom(topViewMargnBottom); Similar customizable attributes are available programatically or using styleable attributes in ``DraggableView``. +Do you want to resize the top view instead of scale it? Add ``dragable_view:top_view_resize`` attribute to your DraggableView: + +```xml + +``` -TODO ----- -I don't have too much time to work on this library and I'm going to put in this section some things to do in the future: +Do you want to contribute? TODO +------------------------------- * Support Android Studio / IntelliJ layout preview mode. -* Create other draggable component to resize elements instead of scale the view. This new component is needed to drag and resize videos. +* Add Travis CI support wity .travis.yml file. Developed By @@ -184,6 +192,7 @@ Who's using it -------------- * [El Rubius Vídeos][9] using the first beta release. +* [DudePerfect Vídeos] [18] using the first beta release. *Does your app use DraggablePanel? If you want to be featured on this list tell me on [Twitter][10] @@ -234,3 +243,4 @@ License [15]: https://github.com/square/picasso [16]: http://actionbarsherlock.com/ [17]: https://developers.google.com/youtube/android/player/ +[18]: https://play.google.com/store/apps/details?id=com.nero.dudeperfect diff --git a/art/screenshot4.gif b/art/screenshot4.gif index ef3b3b4..ad2c556 100644 Binary files a/art/screenshot4.gif and b/art/screenshot4.gif differ diff --git a/build.gradle b/build.gradle index 93bea03..b96c77e 100644 --- a/build.gradle +++ b/build.gradle @@ -2,17 +2,13 @@ buildscript { repositories { mavenCentral() } - dependencies { - classpath 'com.android.tools.build:gradle:0.9.+' + classpath 'com.android.tools.build:gradle:0.12.+' } } -def isReleaseBuild() { - return version.contains("SNAPSHOT") == false -} - allprojects { + version = VERSION_NAME group = GROUP @@ -20,4 +16,11 @@ allprojects { mavenCentral() mavenLocal() } -} \ No newline at end of file +} + +def isReleaseBuild() { + return version.contains("SNAPSHOT") == false +} + + + diff --git a/draggablepanel/AndroidManifest.xml b/draggablepanel/AndroidManifest.xml index 44633f9..1ede4fb 100644 --- a/draggablepanel/AndroidManifest.xml +++ b/draggablepanel/AndroidManifest.xml @@ -1,9 +1,9 @@ - + - + diff --git a/draggablepanel/build.gradle b/draggablepanel/build.gradle index d4aefc6..178f7ec 100644 --- a/draggablepanel/build.gradle +++ b/draggablepanel/build.gradle @@ -19,7 +19,7 @@ android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src'] + java.srcDirs = ['src/main/java'] res.srcDirs = ['res'] } } @@ -29,4 +29,5 @@ android { } } -apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' \ No newline at end of file +apply from: 'https://raw.github.com/jpardogo/gradle-mvn-push/master/gradle-mvn-push.gradle' + diff --git a/draggablepanel/pom.xml b/draggablepanel/pom.xml deleted file mode 100755 index cbdb9fd..0000000 --- a/draggablepanel/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - - - com.github.pedrovgs - draggablepanel-parent - 1.0.4-SNAPSHOT - - - draggablepanel - 1.0.4-SNAPSHOT - apklib - - DRAGGABLE PANEL - LIBRARY - - - - - com.google.android - android - - - - com.nineoldandroids - library - - - - com.android.support - support-v4 - - - - junit - junit - - - - org.robolectric - robolectric - - - - org.mockito - mockito-all - - - - - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - true - - false - - false - - ${project.basedir}/AndroidManifest.xml - ${project.basedir}/res - - - - - - diff --git a/draggablepanel/res/layout/draggable_panel.xml b/draggablepanel/res/layout/draggable_panel.xml index 48cf59d..f6a8411 100644 --- a/draggablepanel/res/layout/draggable_panel.xml +++ b/draggablepanel/res/layout/draggable_panel.xml @@ -1,24 +1,23 @@ - + + android:id="@+id/second_view" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_below="@+id/drag_view" /> + android:id="@+id/drag_view" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:orientation="vertical" /> \ No newline at end of file diff --git a/draggablepanel/res/values/attrs.xml b/draggablepanel/res/values/attrs.xml index b8b6eb6..8398637 100644 --- a/draggablepanel/res/values/attrs.xml +++ b/draggablepanel/res/values/attrs.xml @@ -1,23 +1,24 @@ - - - - - - + + + + + + - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java b/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java index 1d937d6..047443c 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/DraggablePanel.java @@ -35,6 +35,7 @@ public class DraggablePanel extends FrameLayout { 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; private DraggableView draggableView; private DraggableListener draggableListener; diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java index fc8c279..959a0e9 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java @@ -27,6 +27,9 @@ import android.view.MotionEvent; import android.view.View; import android.widget.RelativeLayout; + +import com.github.pedrovgs.transformer.Transformer; +import com.github.pedrovgs.transformer.TransformerFactory; import com.nineoldandroids.view.ViewHelper; /** @@ -36,42 +39,32 @@ */ public class DraggableView extends RelativeLayout { - private static final float HALF = 0.5f; - private static final double QUARTER = 0.25; - private static final int ZERO = 0; + private static final int DEFAULT_SCALE_FACTOR = 2; - private static final float DEFAULT_TOP_VIEW_HEIGHT = -1; private static final int DEFAULT_TOP_VIEW_MARGIN = 30; + private static final float 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; private static final int ONE_HUNDRED = 100; private static final float SENSITIVITY = 1f; + private static final boolean DEFAULT_TOP_VIEW_RESIZE = false; private View dragView; private View secondView; + private TypedArray attributes; private FragmentManager fragmentManager; private ViewDragHelper viewDragHelper; + private Transformer transformer; - private float xScaleFactor = DEFAULT_SCALE_FACTOR; - private float yScaleFactor = DEFAULT_SCALE_FACTOR; - private float topViewMarginRight = DEFAULT_TOP_VIEW_MARGIN; - private float topViewMarginBottom = DEFAULT_TOP_VIEW_MARGIN; - private float topViewHeight = DEFAULT_TOP_VIEW_HEIGHT; private boolean enableHorizontalAlphaEffect; - private int dragViewId; - private int secondViewId; + private boolean topViewResize; private DraggableListener listener; - private int lastTopPosition; - private int lastLeftPosition; - - public DraggableView(Context context) { super(context); - initializeViewDragHelper(); } public DraggableView(Context context, AttributeSet attrs) { @@ -90,7 +83,7 @@ public DraggableView(Context context, AttributeSet attrs, int defStyle) { * @param xScaleFactor */ public void setXTopViewScaleFactor(float xScaleFactor) { - this.xScaleFactor = xScaleFactor; + transformer.setXScaleFactor(xScaleFactor); } /** @@ -99,7 +92,7 @@ public void setXTopViewScaleFactor(float xScaleFactor) { * @param yScaleFactor */ public void setYTopViewScaleFactor(float yScaleFactor) { - this.yScaleFactor = yScaleFactor; + transformer.setYScaleFactor(yScaleFactor); } /** @@ -108,7 +101,7 @@ public void setYTopViewScaleFactor(float yScaleFactor) { * @param topFragmentMarginRight in pixels. */ public void setTopViewMarginRight(float topFragmentMarginRight) { - this.topViewMarginRight = topFragmentMarginRight; + transformer.setMarginRight(topFragmentMarginRight); } /** @@ -117,7 +110,7 @@ public void setTopViewMarginRight(float topFragmentMarginRight) { * @param topFragmentMarginBottom */ public void setTopViewMarginBottom(float topFragmentMarginBottom) { - this.topViewMarginBottom = topFragmentMarginBottom; + transformer.setMarginBottom(topFragmentMarginBottom); } /** @@ -126,12 +119,7 @@ public void setTopViewMarginBottom(float topFragmentMarginBottom) { * @param topFragmentHeight in pixels */ public void setTopViewHeight(float topFragmentHeight) { - if (topFragmentHeight > 0) { - this.topViewHeight = topFragmentHeight; - LayoutParams layoutParams = (LayoutParams) dragView.getLayoutParams(); - layoutParams.height = (int) topFragmentHeight; - dragView.setLayoutParams(layoutParams); - } + transformer.setViewHeight((int) topFragmentHeight); } /** @@ -153,6 +141,15 @@ public void setDraggableListener(DraggableListener listener) { this.listener = listener; } + /** + * Configure DraggableView to resize top view instead of scale it. + * + * @param topViewResize + */ + public void setTopViewResize(boolean topViewResize) { + this.topViewResize = topViewResize; + } + /** * To ensure the animation is going to work this method has been override to call postInvalidateOnAnimation if the * view is not settled yet. @@ -184,7 +181,7 @@ public void minimize() { * Close the custom view applying an animation to close the view to the right side of the screen. */ public void closeToRight() { - if (viewDragHelper.smoothSlideViewTo(dragView, dragView.getWidth(), getHeight() - dragView.getHeight())) { + if (viewDragHelper.smoothSlideViewTo(dragView, (int) transformer.getOriginalWidth(), getHeight() - transformer.getMinHeightPlusMargin())) { ViewCompat.postInvalidateOnAnimation(this); notifyCloseToRightListener(); } @@ -194,7 +191,7 @@ public void closeToRight() { * 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, -dragView.getWidth(), getHeight() - dragView.getHeight())) { + if (viewDragHelper.smoothSlideViewTo(dragView, (int) -transformer.getOriginalWidth(), getHeight() - transformer.getMinHeightPlusMargin())) { ViewCompat.postInvalidateOnAnimation(this); notifyCloseToLeftListener(); } @@ -295,9 +292,13 @@ public boolean onTouchEvent(MotionEvent ev) { */ @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - int newTop = this.topViewHeight == DEFAULT_TOP_VIEW_HEIGHT ? dragView.getMeasuredHeight() : (int) this.topViewHeight; - dragView.layout(lastLeftPosition, lastTopPosition, lastLeftPosition + dragView.getMeasuredWidth(), lastTopPosition + newTop); - secondView.layout(0, lastTopPosition + newTop, right, lastTopPosition + 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, newBottom, right, lastTopPosition + bottom); } /** @@ -308,14 +309,21 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto protected void onFinishInflate() { super.onFinishInflate(); if (!isInEditMode()) { - dragView = findViewById(dragViewId); - secondView = findViewById(secondViewId); - setTopViewHeight(topViewHeight); + mapGUI(attributes); + initializeTransformer(attributes); + attributes.recycle(); initializeViewDragHelper(); } } + private void mapGUI(TypedArray attributes) { + int dragViewId = attributes.getResourceId(R.styleable.draggable_view_top_view_id, R.id.drag_view); + int secondViewId = attributes.getResourceId(R.styleable.draggable_view_bottom_view_id, R.id.second_view); + dragView = findViewById(dragViewId); + secondView = findViewById(secondViewId); + } + /** * Configure the FragmentManager used to attach top and bottom Fragments to the view. The FragmentManager is going * to be provided only by DraggablePanel view. @@ -352,17 +360,17 @@ void attachBottomFragment(Fragment bottomFragment) { * @param lastLeftPosition */ void updateLastDragViewPosition(int lastTopPosition, int lastLeftPosition) { - this.lastTopPosition = lastTopPosition; - this.lastLeftPosition = 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.. + * the view is dragged. */ void changeDragViewPosition() { - ViewHelper.setPivotX(dragView, dragView.getWidth() - getDragViewMarginRight()); - ViewHelper.setPivotY(dragView, dragView.getHeight() - getDragViewMarginBottom()); + transformer.updateXPosition(getVerticalDragOffset()); + transformer.updateYPosition(getVerticalDragOffset()); } /** @@ -370,15 +378,14 @@ void changeDragViewPosition() { */ void changeSecondViewPosition() { ViewHelper.setY(secondView, dragView.getBottom()); - ViewHelper.setX(secondView, dragView.getLeft()); } /** * Modify dragged view scale based on the dragged view vertical position and the scale factor. */ void changeDragViewScale() { - ViewHelper.setScaleX(dragView, 1 - getVerticalDragOffset() / xScaleFactor); - ViewHelper.setScaleY(dragView, 1 - getVerticalDragOffset() / yScaleFactor); + transformer.updateWidth(getVerticalDragOffset()); + transformer.updateHeight(getVerticalDragOffset()); } /** @@ -412,15 +419,22 @@ void changeDragViewViewAlpha() { } } + /** + * Restore view alpha to 1 + */ + void restoreAlpha() { + if (enableHorizontalAlphaEffect && ViewHelper.getAlpha(dragView) < 1) { + ViewHelper.setAlpha(dragView, 1); + } + } + /** * 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() { - int viewHeight = getHeight(); - float viewHeaderY = ViewHelper.getY(dragView) + (dragView.getHeight() * HALF); - return viewHeaderY < (viewHeight * HALF); + return transformer.isAboveTheMiddle(); } /** @@ -429,7 +443,7 @@ boolean isDragViewAboveTheMiddle() { * @return true if dragged view right position is behind the right half of the custom view. */ boolean isNextToLeftBound() { - return (dragView.getRight() - getDragViewMarginRight()) < getWidth() * HALF; + return transformer.isNextToLeftBound(); } /** @@ -438,7 +452,7 @@ boolean isNextToLeftBound() { * @return true if dragged view left position is behind the left quarter of the custom view. */ boolean isNextToRightBound() { - return (dragView.getLeft() - getDragViewMarginRight()) > getWidth() * QUARTER; + return transformer.isNextToRightBound(); } /** @@ -447,7 +461,7 @@ boolean isNextToRightBound() { * @return true if dragged view top position is equals to zero. */ boolean isDragViewAtTop() { - return dragView.getTop() == ZERO; + return transformer.isViewAtTop(); } /** @@ -456,7 +470,7 @@ boolean isDragViewAtTop() { * @return true if dragged view right position is equals to custom view width. */ boolean isDragViewAtRight() { - return dragView.getRight() == getWidth(); + return transformer.isViewAtRight(); } /** @@ -465,7 +479,7 @@ boolean isDragViewAtRight() { * @return true if dragged view bottom position is equals to custom view height. */ boolean isDragViewAtBottom() { - return dragView.getBottom() == getHeight(); + return transformer.isViewAtBottom(); } /** @@ -504,6 +518,26 @@ private void initializeViewDragHelper() { viewDragHelper = ViewDragHelper.create(this, SENSITIVITY, new DraggableViewCallback(this, dragView)); } + /** + * Initialize Transformer with a scalable or change width/height implementation. + * + * @param attributes + */ + 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.getDimension(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.getDimension(R.styleable.draggable_view_top_view_margin_right, DEFAULT_TOP_VIEW_MARGIN)); + transformer.setMarginBottom(attributes.getDimension(R.styleable.draggable_view_top_view_margin_bottom, DEFAULT_TOP_VIEW_MARGIN)); + } + + private boolean shouldScaleView() { + return !topViewResize; + } + /** * Initialize XML attributes. * @@ -511,16 +545,8 @@ private void initializeViewDragHelper() { */ private void initializeAttributes(AttributeSet attrs) { TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.draggable_view); - this.dragViewId = attributes.getResourceId(R.styleable.draggable_view_top_view_id, R.id.drag_view); - this.secondViewId = attributes.getResourceId(R.styleable.draggable_view_bottom_view_id, R.id.second_view); - this.topViewHeight = attributes.getDimension(R.styleable.draggable_view_top_view_height, DEFAULT_TOP_VIEW_HEIGHT); - this.xScaleFactor = attributes.getFloat(R.styleable.draggable_view_top_view_x_scale_factor, DEFAULT_SCALE_FACTOR); - this.yScaleFactor = attributes.getFloat(R.styleable.draggable_view_top_view_y_scale_factor, DEFAULT_SCALE_FACTOR); - this.topViewMarginRight = attributes.getDimension(R.styleable.draggable_view_top_view_margin_right, DEFAULT_TOP_VIEW_MARGIN); - this.topViewMarginBottom = attributes.getDimension(R.styleable.draggable_view_top_view_margin_bottom, DEFAULT_TOP_VIEW_MARGIN); this.enableHorizontalAlphaEffect = attributes.getBoolean(R.styleable.draggable_view_enable_minimized_horizontal_alpha_effect, DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT); - attributes.recycle(); - + this.attributes = attributes; } /** @@ -532,9 +558,9 @@ private void initializeAttributes(AttributeSet attrs) { */ private boolean smoothSlideTo(float slideOffset) { final int topBound = getPaddingTop(); + int x = (int) (slideOffset * (getWidth() - transformer.getMinWidth())); int y = (int) (topBound + slideOffset * getVerticalDragRange()); - - if (viewDragHelper.smoothSlideViewTo(dragView, 0, y)) { + if (viewDragHelper.smoothSlideViewTo(dragView, x, y)) { ViewCompat.postInvalidateOnAnimation(this); return true; } @@ -545,14 +571,14 @@ private boolean smoothSlideTo(float slideOffset) { * @return configured dragged view margin right configured. */ private float getDragViewMarginRight() { - return topViewMarginRight; + return transformer.getMarginRight(); } /** * @return configured dragged view margin bottom. */ private float getDragViewMarginBottom() { - return topViewMarginBottom; + return transformer.getMarginBottom(); } /** @@ -579,7 +605,7 @@ private float getVerticalDragOffset() { * @return the difference between the custom view height and the dragged view height. */ private float getVerticalDragRange() { - return getHeight() - dragView.getHeight(); + return getHeight() - transformer.getMinHeightPlusMargin(); } /** @@ -618,4 +644,8 @@ private void notifyCloseToLeftListener() { } } + public int getDraggedViewHeightPlusMarginTop() { + return transformer.getMinHeightPlusMargin(); + } + } \ No newline at end of file diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java index 80ddbc2..fc280d8 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java @@ -60,13 +60,13 @@ public void onViewPositionChanged(View changedView, int left, int top, int dx, i if (draggableView.isDragViewAtBottom()) { draggableView.changeDragViewViewAlpha(); } else { + draggableView.restoreAlpha(); draggableView.changeDragViewScale(); draggableView.changeDragViewPosition(); draggableView.changeSecondViewAlpha(); draggableView.changeSecondViewPosition(); draggableView.changeBackgroundAlpha(); } - draggableView.invalidate(); } /** @@ -112,7 +112,7 @@ public boolean tryCaptureView(View view, int pointerId) { */ @Override public int clampViewPositionHorizontal(View child, int left, int dx) { - int newLeft = 0; + int newLeft = draggedView.getLeft(); if ((draggableView.isMinimized() && Math.abs(dx) > MINIMUN_DX_FOR_HORIZONTAL_DRAG) || (draggableView.isDragViewAtBottom() && !draggableView.isDragViewAtRight())) { newLeft = left; } @@ -130,10 +130,11 @@ public int clampViewPositionHorizontal(View child, int left, int dx) { */ @Override public int clampViewPositionVertical(View child, int top, int dy) { - int newTop = draggableView.getHeight() - draggedView.getHeight(); + int newTop = draggableView.getHeight() - draggableView.getDraggedViewHeightPlusMarginTop(); if (draggableView.isMinimized() && Math.abs(dy) >= MINIMUM_DY_FOR_VERTICAL_DRAG || (!draggableView.isMinimized() && !draggableView.isDragViewAtBottom())) { + final int topBound = draggableView.getPaddingTop(); - final int bottomBound = draggableView.getHeight() - child.getHeight() - child.getPaddingBottom(); + final int bottomBound = draggableView.getHeight() - draggableView.getDraggedViewHeightPlusMarginTop() - draggedView.getPaddingBottom(); newTop = Math.min(Math.max(top, topBound), bottomBound); } diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ResizeTransformer.java b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ResizeTransformer.java new file mode 100644 index 0000000..008358e --- /dev/null +++ b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ResizeTransformer.java @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2014 Pedro Vicente Gómez Sánchez. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.pedrovgs.transformer; + +import android.view.View; +import android.widget.RelativeLayout; + +/** + * Transformer extension created to resize the view instead of scale it as the other + * implementation does. This implementation is based on change the LayoutParams. + * + * @author Pedro Vicente Gómez Sánchez + */ +class ResizeTransformer extends Transformer { + + private float lastHeight; + + ResizeTransformer(View view, View parent) { + super(view, parent); + } + + /** + * Changes view width using view's LayoutParam. + * + * @param verticalDragOffset used to calculate the new width. + */ + @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); + } + + /** + * 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); + } + + /** + * @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(); + getView().layout(left, top, right, bottom); + } + + /** + * Empty implementation. ViewDragHelper already changes the Y position. + * + * @param verticalDragOffset + */ + @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 + * width. + */ + @Override + public boolean isViewAtRight() { + return getView().getRight() + getMarginRight() == getParentView().getWidth(); + } + + /** + * @return true if the bottom position of the view plus the margin right is equals to + * the parent view height. + */ + @Override + public boolean isViewAtBottom() { + return getView().getBottom() + getMarginBottom() == getParentView().getHeight(); + } + + /** + * @return true if the left position of the view is to the right of the seventy five percent of the + * parent view width. + */ + @Override + public boolean isNextToRightBound() { + return (getView().getLeft() - getMarginRight()) > getParentView().getWidth() * 0.75; + } + + /** + * @return true if the left position of the view is to the left of the twenty five percent of + * the parent width. + */ + @Override + public boolean isNextToLeftBound() { + return (getView().getLeft() - getMarginRight()) < getParentView().getWidth() * 0.25; + } + + /** + * Uses the Y scale factor to calculate the min possible height. + * + * @return + */ + @Override + public int getMinHeightPlusMargin() { + return (int) ((getOriginalHeight() / getYScaleFactor()) + getMarginBottom()); + } + + /** + * Uses the X scale factor to calculate the min possible width. + * + * @return + */ + @Override + public int getMinWidth() { + return (int) (getOriginalWidth() / getXScaleFactor()); + } + + /** + * Calculate the current view right position for a given verticalDragOffset. + * + * @param verticalDragOffset used to calculate the new right position. + * @return + */ + 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 new file mode 100644 index 0000000..37295e8 --- /dev/null +++ b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/ScaleTransformer.java @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2014 Pedro Vicente Gómez Sánchez. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.pedrovgs.transformer; + +import android.view.View; + +import com.nineoldandroids.view.ViewHelper; + +/** + * Transformer extension created to scale the view instead of resize it as the other + * implementation does. This implementation is based on Nineoldanroids library to scale + * the view. + * + * @author Pedro Vicente Gómez Sánchez + */ +class ScaleTransformer extends Transformer { + + ScaleTransformer(View view, View parent) { + super(view, parent); + } + + /** + * Uses Nineoldandroids to change the scale in the X axis. + * + * @param verticalDragOffset used to calculate the new scale. + */ + @Override + public void updateWidth(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. + * + * @param verticalDragOffset used to calculate the new X position. + */ + @Override + public void updateXPosition(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()); + } + + /** + * @return true if the right corner of the view matches with the parent view width. + */ + @Override + public boolean isViewAtRight() { + return getView().getRight() == getParentView().getWidth(); + } + + /** + * @return true if the bottom corner of the view matches with the parent view height. + */ + @Override + public boolean isViewAtBottom() { + return getView().getBottom() == getParentView().getHeight(); + } + + /** + * @return true if the left position of the view is to the right of the twenty five percent of + * the parent width. + */ + @Override + public boolean isNextToRightBound() { + return (getView().getLeft() - getMarginRight()) > getParentView().getWidth() * 0.25; + } + + /** + * @return true if the left position of the view is to the left of the twenty five percent of + * the parent width. + */ + @Override + public boolean isNextToLeftBound() { + return (getView().getLeft() - getMarginRight()) < getParentView().getWidth() * 0.25; + } + + /** + * @return min view height taking into account the configured margin. + */ + @Override + public int getMinHeightPlusMargin() { + return getView().getHeight(); + } + + /** + * @return min view width. + */ + @Override + public int getMinWidth() { + return (int) 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 new file mode 100644 index 0000000..7d8ea6f --- /dev/null +++ b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/Transformer.java @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2014 Pedro Vicente Gómez Sánchez. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.pedrovgs.transformer; + +import android.view.View; +import android.widget.RelativeLayout; + +import com.nineoldandroids.view.ViewHelper; + +/** + * Abstract class created to be implemented by different classes are going to change the size of a + * view. The most basic one is going to scale the view and the most complex used with VideoView + * is going to change the size of the view. + *

+ * The view used in this class has to be contained by a RelativeLayout. + *

+ * This class also provide information about the size of the view and the position because different + * Transformer implementations could change the size of the view but not the position, like + * ScaleTransformer does. + * + * @author Pedro Vicente Gómez Sánchez + */ +public abstract class Transformer { + + private final View view; + private final View parent; + + private float viewHeight; + 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; + + public Transformer(View view, View parent) { + this.view = view; + this.parent = parent; + } + + public float getXScaleFactor() { + return xScaleFactor; + } + + public void setXScaleFactor(float xScaleFactor) { + this.xScaleFactor = xScaleFactor; + } + + public float getYScaleFactor() { + return yScaleFactor; + } + + public void setYScaleFactor(float yScaleFactor) { + this.yScaleFactor = yScaleFactor; + } + + public float getMarginRight() { + return marginRight; + } + + public void setMarginRight(float marginRight) { + this.marginRight = marginRight; + } + + public float getMarginBottom() { + return marginBottom; + } + + public void setMarginBottom(float marginBottom) { + this.marginBottom = marginBottom; + } + + public float getViewHeight() { + return viewHeight < 0f ? view.getMeasuredHeight() : viewHeight; + } + + /** + * Change view height using the LayoutParams of the view. + * + * @param viewHeight to change.. + */ + public void setViewHeight(float viewHeight) { + this.viewHeight = viewHeight; + if (viewHeight > 0f) { + originalHeight = viewHeight; + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams(); + layoutParams.height = (int) viewHeight; + 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; + } + + protected View getParentView() { + return parent; + } + + public abstract void updateXPosition(float verticalDragOffset); + + public abstract void updateYPosition(float verticalDragOffset); + + public abstract void updateWidth(float verticalDragOffset); + + public abstract void updateHeight(float verticalDragOffset); + + /** + * @return height of the view before it has change the size. + */ + public float getOriginalHeight() { + if (originalHeight == 0) { + originalHeight = viewHeight < 0 ? view.getMeasuredHeight() : viewHeight; + } + return originalHeight; + } + + /** + * @return width of the view before it has change the size. + */ + public float 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; + } + + public boolean isAboveTheMiddle() { + int parentHeight = parent.getHeight(); + float viewYPosition = ViewHelper.getY(view) + (view.getHeight() * 0.5f); + return viewYPosition < (parentHeight * 0.5); + } + + public abstract boolean isViewAtRight(); + + public abstract boolean isViewAtBottom(); + + public abstract boolean isNextToRightBound(); + + public abstract boolean isNextToLeftBound(); + + /** + * @return min possible height, after apply the transformation, plus the margin right. + */ + public abstract int getMinHeightPlusMargin(); + + + /** + * @return min possible width, after apply the transformation. + */ + public abstract int getMinWidth(); + +} diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/transformer/TransformerFactory.java b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/TransformerFactory.java new file mode 100644 index 0000000..fa100a3 --- /dev/null +++ b/draggablepanel/src/main/java/com/github/pedrovgs/transformer/TransformerFactory.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 Pedro Vicente Gómez Sánchez. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.pedrovgs.transformer; + +import android.view.View; + +/** + * Factory created to provide Transformer implementations like ResizeTransformer o ScaleTransformer. + * + * @author Pedro Vicente Gómez Sánchez + */ +public class TransformerFactory { + + public Transformer getTransformer(final boolean resize, final View view, final View parent) { + Transformer transformer = null; + if (resize) { + transformer = new ResizeTransformer(view, parent); + } else { + transformer = new ScaleTransformer(view, parent); + } + return transformer; + } + +} diff --git a/gradle.bat b/gradle.bat deleted file mode 100644 index d4552f3..0000000 --- a/gradle.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 007608c..274e4f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -VERSION_NAME=1.0.4-SNAPSHOT -VERSION_CODE=4 +VERSION_NAME=1.1 +VERSION_CODE=5 GROUP=com.github.pedrovgs POM_DESCRIPTION=Android library created to create a draggable user interface similar to the last YouTube draggable video component. @@ -13,7 +13,7 @@ POM_LICENCE_DIST=repo POM_DEVELOPER_ID=pedrovgs POM_DEVELOPER_NAME=Pedro Vicente Gómez Sánchez -ANDROID_BUILD_TOOLS_VERSION=19.0.3 +ANDROID_BUILD_TOOLS_VERSION=19.1 ANDROID_COMPILE_SDK_VERSION=19 ANDROID_TARGET_SDK_VERSION=19 ANDROID_MIN_SDK=8 \ No newline at end of file diff --git a/pom.xml b/pom.xml deleted file mode 100755 index 8bee227..0000000 --- a/pom.xml +++ /dev/null @@ -1,231 +0,0 @@ - - - 4.0.0 - - com.github.pedrovgs - draggablepanel-parent - 1.0.4-SNAPSHOT - pom - - - org.sonatype.oss - oss-parent - 7 - - - DRAGGABLE PANEL - PARENT - Library to work with draggable panels. - http://github.com/pedrovgs/DraggablePanel/ - 2014 - - - - Pedro Vicente Gómez Sánchez - pedrovicente.gomez@gmail.com - pedrovgs - http://github.pedrovgs.com - - developer - - - - - - draggablepanel - sample - - - - UTF-8 - - - - - - junit - junit - 4.8.2 - test - - - - com.google.android - android - 4.1.1.4 - provided - - - - com.google.android - android-test - 4.1.1.4 - - - - - org.robolectric - robolectric - 2.2 - test - - - - - org.mockito - mockito-all - 1.9.5 - test - - - - com.android.support - support-v4 - 19.1.0 - - - - com.nineoldandroids - library - 2.4.0 - - - - com.github.pedrovgs - renderers - 1.0.9 - - - - com.github.pedrovgs - draggablepanel - 1.0.4-SNAPSHOT - apklib - - - - com.squareup.picasso - picasso - 2.1.1 - - - - com.jakewharton - butterknife - 4.0.1 - - - - com.squareup.dagger - dagger - 1.2.1 - - - com.squareup.dagger - dagger-compiler - 1.2.1 - true - - - - com.youtube.player - youtube-player-api - 1 - - - - com.google.gms - google-play-services-jar - 7 - - - - com.actionbarsherlock - actionbarsherlock - 4.4.0 - apklib - - - - - - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - 3.8.0 - - - 19 - - true - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - - - - coverage-per-test - - - - org.apache.maven.plugins - maven-surefire-plugin - - 2.13 - - - - listener - org.sonar.java.jacoco.JUnitListener - - - - - - - - - - org.codehaus.sonar-plugins.java - sonar-jacoco-listeners - 1.2 - test - - - - - - - - Apache 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - https://github.com/pedrovgs/DraggablePanel/ - scm:git:git://github.com/pedrovgs/DraggablePanel.git - scm:git:git@github.com:pedrovgs/DraggablePanel.git - 1.0.0 - - - diff --git a/sample/build.gradle b/sample/build.gradle index 0f113f3..436b63f 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -32,7 +32,7 @@ android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src'] + java.srcDirs = ['src/main/java'] res.srcDirs = ['res'] } } diff --git a/sample/pom.xml b/sample/pom.xml deleted file mode 100755 index 6be79bc..0000000 --- a/sample/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - 4.0.0 - - - com.github.pedrovgs - draggablepanel-parent - 1.0.4-SNAPSHOT - - - sample - 1.0.4-SNAPSHOT - apk - - DRAGGABLE PANEL - SAMPLE - - - - com.google.android - android - - - - com.github.pedrovgs - draggablepanel - apklib - - - - com.squareup.picasso - picasso - - - - com.jakewharton - butterknife - - - - com.squareup.dagger - dagger - - - com.squareup.dagger - dagger-compiler - - - - com.youtube.player - youtube-player-api - - - - com.github.pedrovgs - renderers - - - - com.google.gms - google-play-services-jar - - - - com.actionbarsherlock - actionbarsherlock - apklib - - - com.google.android - support-v4 - - - - - - - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - true - - - - - diff --git a/sample/res/layout/activity_video_sample.xml b/sample/res/layout/activity_video_sample.xml index d3b872d..95168df 100644 --- a/sample/res/layout/activity_video_sample.xml +++ b/sample/res/layout/activity_video_sample.xml @@ -28,6 +28,7 @@ draggable_view:top_view_margin_right="@dimen/top_fragment_margin" draggable_view:top_view_margin_bottom="@dimen/top_fragment_margin" draggable_view:enable_minimized_horizontal_alpha_effect="false" + draggable_view:top_view_resize="true" android:background="@color/black"> diff --git a/sample/src/main/java/com/github/pedrovgs/sample/activity/VideoSampleActivity.java b/sample/src/main/java/com/github/pedrovgs/sample/activity/VideoSampleActivity.java index b7d25eb..2e9486d 100644 --- a/sample/src/main/java/com/github/pedrovgs/sample/activity/VideoSampleActivity.java +++ b/sample/src/main/java/com/github/pedrovgs/sample/activity/VideoSampleActivity.java @@ -135,8 +135,6 @@ private void startVideo() { */ private void initializeVideoView() { Uri path = Uri.parse(APPLICATION_RAW_PATH + R.raw.video); - MediaController mediaController = new MediaController(this); - videoView.setMediaController(mediaController); videoView.setVideoURI(path); videoView.start(); } diff --git a/sample/src/main/java/com/github/pedrovgs/sample/activity/YoutubeSampleActivity.java b/sample/src/main/java/com/github/pedrovgs/sample/activity/YoutubeSampleActivity.java index fc5d5c2..64fce8d 100644 --- a/sample/src/main/java/com/github/pedrovgs/sample/activity/YoutubeSampleActivity.java +++ b/sample/src/main/java/com/github/pedrovgs/sample/activity/YoutubeSampleActivity.java @@ -39,7 +39,7 @@ public class YoutubeSampleActivity extends FragmentActivity { private static final String YOUTUBE_API_KEY = "AIzaSyC1rMU-mkhoyTvBIdTnYU0dss0tU9vtK48"; - private static final String VIDEO_KEY = "pK2zYHWDZKo"; + private static final String VIDEO_KEY = "gsjtg7m1MMM"; private static final String VIDEO_POSTER_THUMBNAIL = "http://4.bp.blogspot.com/-BT6IshdVsoA/UjfnTo_TkBI/AAAAAAAAMWk/JvDCYCoFRlQ/s1600/xmenDOFP.wobbly.1.jpg"; private static final String SECOND_VIDEO_POSTER_THUMBNAIL = "http://media.comicbook.com/wp-content/uploads/2013/07/x-men-days-of-future-past-wolverine-poster.jpg"; private static final String VIDEO_POSTER_TITLE = "X-Men: Days of Future Past";