\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_cover.xml b/app/src/main/res/layout/item_cover.xml
index ac91f39..6663ce9 100644
--- a/app/src/main/res/layout/item_cover.xml
+++ b/app/src/main/res/layout/item_cover.xml
@@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_overlap_cover.xml b/app/src/main/res/layout/item_overlap_cover.xml
index 93aa816..5389f2d 100644
--- a/app/src/main/res/layout/item_overlap_cover.xml
+++ b/app/src/main/res/layout/item_overlap_cover.xml
@@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 59dcfd7..16bf805 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,10 +2,11 @@
buildscript {
repositories {
+ google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.2'
+ classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -14,6 +15,7 @@ buildscript {
allprojects {
repositories {
+ google()
jcenter()
}
}
@@ -22,12 +24,13 @@ task clean(type: Delete) {
delete rootProject.buildDir
}
-def supportVersion = "23.2.1"
+def androidxVersion = "1.0.0"
+def materialVersion = "1.0.0"
-ext{
- supportV4 = "com.android.support:support-v4:${supportVersion}"
- appCompat = "com.android.support:appcompat-v7:${supportVersion}"
- cardView = "com.android.support:cardview-v7:${supportVersion}"
- designCompat = "com.android.support:design:${supportVersion}"
+ext {
+ legacySupportV4 = "androidx.legacy:legacy-support-v4:${androidxVersion}"
+ appCompat = "androidx.appcompat:appcompat:${androidxVersion}"
+ cardView = "androidx.cardview:cardview:${androidxVersion}"
+ materialDesign = "com.google.android.material:material:${materialVersion}"
}
diff --git a/coverflow/build.gradle b/coverflow/build.gradle
index 35a5f75..1379264 100644
--- a/coverflow/build.gradle
+++ b/coverflow/build.gradle
@@ -1,14 +1,13 @@
apply plugin: 'com.android.library'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
+ compileSdkVersion 28
defaultConfig {
minSdkVersion 15
- targetSdkVersion 23
- versionCode 2
- versionName "1.0.2"
+ targetSdkVersion 28
+ versionCode 200
+ versionName "2.0.0"
}
buildTypes {
release {
@@ -25,7 +24,9 @@ allprojects {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile rootProject.ext.supportV4
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.12'
+ implementation rootProject.ext.legacySupportV4
}
+
+apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
diff --git a/coverflow/gradle.properties b/coverflow/gradle.properties
new file mode 100644
index 0000000..f76f6b0
--- /dev/null
+++ b/coverflow/gradle.properties
@@ -0,0 +1,3 @@
+POM_NAME=Android-Coverflow Library
+POM_ARTIFACT_ID=coverflow
+POM_PACKAGING=aar
\ No newline at end of file
diff --git a/coverflow/src/main/java/android/support/v4/view/LinkagePager.java b/coverflow/src/main/java/androidx/viewpager/widget/LinkagePager.java
similarity index 96%
rename from coverflow/src/main/java/android/support/v4/view/LinkagePager.java
rename to coverflow/src/main/java/androidx/viewpager/widget/LinkagePager.java
index 6f14df4..b6fc8a3 100644
--- a/coverflow/src/main/java/android/support/v4/view/LinkagePager.java
+++ b/coverflow/src/main/java/androidx/viewpager/widget/LinkagePager.java
@@ -1,4 +1,4 @@
-package android.support.v4.view;
+package androidx.viewpager.widget;
import android.content.Context;
import android.content.res.Resources;
@@ -12,14 +12,6 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
-import android.support.annotation.CallSuper;
-import android.support.annotation.DrawableRes;
-import android.support.v4.os.ParcelableCompat;
-import android.support.v4.os.ParcelableCompatCreatorCallbacks;
-import android.support.v4.view.accessibility.AccessibilityEventCompat;
-import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
-import android.support.v4.view.accessibility.AccessibilityRecordCompat;
-import android.support.v4.widget.EdgeEffectCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.FocusFinder;
@@ -36,6 +28,23 @@
import android.view.animation.Interpolator;
import android.widget.Scroller;
+import androidx.annotation.CallSuper;
+import androidx.annotation.DrawableRes;
+import androidx.core.os.ParcelableCompat;
+import androidx.core.os.ParcelableCompatCreatorCallbacks;
+import androidx.core.view.AccessibilityDelegateCompat;
+import androidx.core.view.MotionEventCompat;
+import androidx.core.view.VelocityTrackerCompat;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.ViewConfigurationCompat;
+import androidx.core.view.WindowInsetsCompat;
+import androidx.core.view.accessibility.AccessibilityEventCompat;
+import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
+import androidx.core.view.accessibility.AccessibilityRecordCompat;
+import androidx.core.widget.EdgeEffectCompat;
+import androidx.fragment.app.FragmentPagerAdapter;
+import androidx.fragment.app.FragmentStatePagerAdapter;
+
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
@@ -56,8 +65,8 @@
* which is a convenient way to supply and manage the lifecycle of each page.
* There are standard adapters implemented for using fragments with the ViewPager,
* which cover the most common use cases. These are
- * {@link android.support.v4.app.FragmentPagerAdapter} and
- * {@link android.support.v4.app.FragmentStatePagerAdapter}; each of these
+ * {@link FragmentPagerAdapter} and
+ * {@link FragmentStatePagerAdapter}; each of these
* classes have simple code showing how to build a full user interface
* with them.
*
@@ -68,9 +77,9 @@
* Below is a more complicated example of ViewPager, using it in conjunction
* with {@link android.app.ActionBar} tabs. You can find other examples of using
* ViewPager in the API 4+ Support Demos and API 13+ Support Demos sample code.
- *
+ *
* {@sample development/samples/Support13Demos/src/com/example/android/supportv13/app/ActionBarTabsPager.java
- * complete}
+ * complete}
*/
public class LinkagePager extends ViewGroup {
private static final String TAG = "ViewPager";
@@ -86,7 +95,7 @@ public class LinkagePager extends ViewGroup {
private static final int MIN_FLING_VELOCITY = 400; // dips
- private static final int[] LAYOUT_ATTRS = new int[] {
+ private static final int[] LAYOUT_ATTRS = new int[]{
android.R.attr.layout_gravity
};
@@ -107,7 +116,7 @@ static class ItemInfo {
float offset;
}
- private static final Comparator COMPARATOR = new Comparator(){
+ private static final Comparator COMPARATOR = new Comparator() {
@Override
public int compare(ItemInfo lhs, ItemInfo rhs) {
return lhs.position - rhs.position;
@@ -253,9 +262,9 @@ public interface OnPageChangeListener {
* This method will be invoked when the current page is scrolled, either as part
* of a programmatically initiated smooth scroll or a user initiated touch scroll.
*
- * @param position Position index of the first page currently being displayed.
- * Page position+1 will be visible if positionOffset is nonzero.
- * @param positionOffset Value from [0, 1) indicating the offset from the page at position.
+ * @param position Position index of the first page currently being displayed.
+ * Page position+1 will be visible if positionOffset is nonzero.
+ * @param positionOffset Value from [0, 1) indicating the offset from the page at position.
* @param positionOffsetPixels Value in pixels indicating the offset from position.
*/
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels);
@@ -316,7 +325,7 @@ public interface PageTransformer {
/**
* Apply a property transformation to the given page.
*
- * @param page Apply the transformation to this page
+ * @param page Apply the transformation to this page
* @param position Position of page relative to the current front-and-center
* position of the pager. 0 is front and center. 1 is one full
* page position to the right, and -1 is one page position to the left.
@@ -335,7 +344,8 @@ interface OnAdapterChangeListener {
* Used internally to tag special types of child views that should be added as
* pager decorations by default.
*/
- interface Decor {}
+ interface Decor {
+ }
public LinkagePager(Context context) {
super(context);
@@ -375,7 +385,7 @@ void initViewPager() {
}
ViewCompat.setOnApplyWindowInsetsListener(this,
- new android.support.v4.view.OnApplyWindowInsetsListener() {
+ new androidx.core.view.OnApplyWindowInsetsListener() {
private final Rect mTempRect = new Rect();
@Override
@@ -545,7 +555,7 @@ public void setCurrentItem(int item) {
/**
* Set the currently selected page.
*
- * @param item Item index to select
+ * @param item Item index to select
* @param smoothScroll True to smoothly scroll to the new item, false to transition immediately
*/
public void setCurrentItem(int item, boolean smoothScroll) {
@@ -581,7 +591,7 @@ void setCurrentItemInternal(int item, boolean smoothScroll, boolean always, int
// We are doing a jump by more than one page. To avoid
// glitches, we want to keep all current pages in the view
// until the scroll ends.
- for (int i=0; i= 11) {
@@ -709,7 +718,7 @@ void setChildrenDrawingOrderEnabledCompat(boolean enable) {
if (mSetChildrenDrawingOrderEnabled == null) {
try {
mSetChildrenDrawingOrderEnabled = ViewGroup.class.getDeclaredMethod(
- "setChildrenDrawingOrderEnabled", new Class[] { Boolean.TYPE });
+ "setChildrenDrawingOrderEnabled", new Class[]{Boolean.TYPE});
} catch (NoSuchMethodException e) {
Log.e(TAG, "Can't find setChildrenDrawingOrderEnabled", e);
}
@@ -866,8 +875,8 @@ void smoothScrollTo(int x, int y) {
/**
* Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
*
- * @param x the number of pixels to scroll by on the X axis
- * @param y the number of pixels to scroll by on the Y axis
+ * @param x the number of pixels to scroll by on the X axis
+ * @param y the number of pixels to scroll by on the Y axis
* @param velocity the velocity associated with a fling, if applicable. (0 otherwise)
*/
void smoothScrollTo(int x, int y, int velocity) {
@@ -1050,7 +1059,7 @@ void populate(int newCurrentItem) {
final int pageLimit = mOffscreenPageLimit;
final int startPos = Math.max(0, mCurItem - pageLimit);
final int N = mAdapter.getCount();
- final int endPos = Math.min(N-1, mCurItem + pageLimit);
+ final int endPos = Math.min(N - 1, mCurItem + pageLimit);
if (N != mExpectedAdapterCount) {
String resName;
@@ -1158,7 +1167,7 @@ void populate(int newCurrentItem) {
if (DEBUG) {
Log.i(TAG, "Current page list:");
- for (int i=0; i mTouchSlop && xDiff > yDiff) {
if (DEBUG) Log.v(TAG, "Starting drag!");
mIsBeingDragged = true;
@@ -2163,7 +2174,7 @@ public boolean onTouchEvent(MotionEvent ev) {
int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
totalDelta);
setCurrentItemInternal(nextPage, true, true, initialVelocity);
- if(linkagePager!=null){
+ if (linkagePager != null) {
linkagePager.setCurrentItemInternal(nextPage, true, true, initialVelocity);
}
needsInvalidate = resetTouch();
@@ -2252,9 +2263,9 @@ private boolean performDrag(float x) {
mLastMotionX += scrollX - (int) scrollX;
scrollTo((int) scrollX, getScrollY());
- final float pageOffset = scrollX / width;
- if(linkagePager!=null){
- linkagePager.scrollTo( (int)(pageOffset * linkagePager.getWidth()), linkagePager.getScrollY());
+ final float pageOffset = scrollX / width;
+ if (linkagePager != null) {
+ linkagePager.scrollTo((int) (pageOffset * linkagePager.getWidth()), linkagePager.getScrollY());
}
pageScrolled((int) scrollX);
@@ -2263,7 +2274,7 @@ private boolean performDrag(float x) {
/**
* @return Info about the page at the current scroll position.
- * This can be synthetic for a missing middle page; the 'object' field can be null.
+ * This can be synthetic for a missing middle page; the 'object' field can be null.
*/
private ItemInfo infoForCurrentScrollPosition() {
final int width = getClientWidth();
@@ -2426,7 +2437,6 @@ protected void onDraw(Canvas canvas) {
* is already in progress, this method will return false.
*
* @return true if the fake drag began successfully, false if it could not be started.
- *
* @see #fakeDragBy(float)
* @see #endFakeDrag()
*/
@@ -2538,7 +2548,6 @@ public void fakeDragBy(float xOffset) {
* Returns true if a fake drag is in progress.
*
* @return true if currently in a fake drag, false otherwise.
- *
* @see #beginFakeDrag()
* @see #fakeDragBy(float)
* @see #endFakeDrag()
@@ -2606,12 +2615,12 @@ public boolean canScrollHorizontally(int direction) {
/**
* Tests scrollability within child views of v given a delta of dx.
*
- * @param v View to test for horizontal scrollability
+ * @param v View to test for horizontal scrollability
* @param checkV Whether the view v passed should itself be checked for scrollability (true),
* or just its children (false).
- * @param dx Delta scrolled in pixels
- * @param x X coordinate of the active touch point
- * @param y Y coordinate of the active touch point
+ * @param dx Delta scrolled in pixels
+ * @param x X coordinate of the active touch point
+ * @param y Y coordinate of the active touch point
* @return true if child views of v can be scrolled by delta of dx.
*/
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
@@ -2665,9 +2674,9 @@ public boolean executeKeyEvent(KeyEvent event) {
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
- if (KeyEventCompat.hasNoModifiers(event)) {
+ if (event.hasNoModifiers()) {
handled = arrowScroll(FOCUS_FORWARD);
- } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
+ } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
@@ -2771,15 +2780,15 @@ private Rect getChildRectInPagerCoordinates(Rect outRect, View child) {
boolean pageLeft() {
if (mCurItem > 0) {
- setCurrentItem(mCurItem-1, true);
+ setCurrentItem(mCurItem - 1, true);
return true;
}
return false;
}
boolean pageRight() {
- if (mAdapter != null && mCurItem < (mAdapter.getCount()-1)) {
- setCurrentItem(mCurItem+1, true);
+ if (mAdapter != null && mCurItem < (mAdapter.getCount() - 1)) {
+ setCurrentItem(mCurItem + 1, true);
return true;
}
return false;
@@ -2884,7 +2893,7 @@ protected boolean onRequestFocusInDescendants(int direction,
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
- if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
+ if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
@@ -2933,7 +2942,7 @@ public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event)
final AccessibilityRecordCompat recordCompat =
AccessibilityEventCompat.asRecord(event);
recordCompat.setScrollable(canScroll());
- if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
+ if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED
&& mAdapter != null) {
recordCompat.setItemCount(mAdapter.getCount());
recordCompat.setFromIndex(mCurItem);
@@ -2965,13 +2974,15 @@ public boolean performAccessibilityAction(View host, int action, Bundle args) {
setCurrentItem(mCurItem + 1);
return true;
}
- } return false;
+ }
+ return false;
case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD: {
if (canScrollHorizontally(-1)) {
setCurrentItem(mCurItem - 1);
return true;
}
- } return false;
+ }
+ return false;
}
return false;
}
@@ -2986,6 +2997,7 @@ private class PagerObserver extends DataSetObserver {
public void onChanged() {
dataSetChanged();
}
+
@Override
public void onInvalidated() {
dataSetChanged();
diff --git a/coverflow/src/main/java/me/crosswall/lib/coverflow/CoverFlow.java b/coverflow/src/main/java/me/crosswall/lib/coverflow/CoverFlow.java
index 43a3a11..7fcc7f3 100644
--- a/coverflow/src/main/java/me/crosswall/lib/coverflow/CoverFlow.java
+++ b/coverflow/src/main/java/me/crosswall/lib/coverflow/CoverFlow.java
@@ -1,7 +1,7 @@
package me.crosswall.lib.coverflow;
-import android.support.v4.view.LinkagePager;
-import android.support.v4.view.ViewPager;
+import androidx.viewpager.widget.LinkagePager;
+import androidx.viewpager.widget.ViewPager;
import me.crosswall.lib.coverflow.core.CoverTransformer;
import me.crosswall.lib.coverflow.core.LinkageCoverTransformer;
@@ -11,11 +11,11 @@
*/
public class CoverFlow {
- // public static final float DEFAULT_SCALE_VALUE = 0.3f;
+ // public static final float DEFAULT_SCALE_VALUE = 0.3f;
- // public static final float DEFAULT_PAGER_MARGIN = 0f;
+ // public static final float DEFAULT_PAGER_MARGIN = 0f;
- // public static final float DEFAULT_SPACE_SIZE = 0f;
+ // public static final float DEFAULT_SPACE_SIZE = 0f;
private final ViewPager viewPager;
private final LinkagePager linkagePager;
@@ -24,25 +24,25 @@ public class CoverFlow {
private final float spaceSize;
private final float rotationY;
- public CoverFlow(CoverFlow.Builder builder){
+ public CoverFlow(CoverFlow.Builder builder) {
- if(null==builder){
+ if (null == builder) {
throw new IllegalArgumentException("A non-null CoverFlow.Builde must be provided");
}
this.viewPager = builder.viewPager;
this.linkagePager = builder.linkagePager;
- this.scaleValue = builder.scaleValue;
+ this.scaleValue = builder.scaleValue;
this.pagerMargin = builder.pagerMargin;
- this.spaceSize = builder.spaceSize;
- this.rotationY = builder.rotationY;
+ this.spaceSize = builder.spaceSize;
+ this.rotationY = builder.rotationY;
- if(this.viewPager != null){
+ if (this.viewPager != null) {
this.viewPager.setPageTransformer(false,
- new CoverTransformer(this.scaleValue,this.pagerMargin,this.spaceSize,this.rotationY));
- }else if(this.linkagePager !=null){
+ new CoverTransformer(this.scaleValue, this.pagerMargin, this.spaceSize, this.rotationY));
+ } else if (this.linkagePager != null) {
this.linkagePager.setPageTransformer(false,
- new LinkageCoverTransformer(this.scaleValue,this.pagerMargin,this.spaceSize,this.rotationY));
+ new LinkageCoverTransformer(this.scaleValue, this.pagerMargin, this.spaceSize, this.rotationY));
}
@@ -61,7 +61,7 @@ public CoverFlow.Builder with(ViewPager viewPager) {
return this;
}
- public CoverFlow.Builder withLinkage(LinkagePager linkagePager){
+ public CoverFlow.Builder withLinkage(LinkagePager linkagePager) {
this.linkagePager = linkagePager;
return this;
}
@@ -82,7 +82,7 @@ public CoverFlow.Builder spaceSize(float spaceSize) {
return this;
}
- public CoverFlow.Builder rotationY(float rotationY){
+ public CoverFlow.Builder rotationY(float rotationY) {
this.rotationY = rotationY;
return this;
}
diff --git a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/CoverTransformer.java b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/CoverTransformer.java
index 03e3928..d47676c 100644
--- a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/CoverTransformer.java
+++ b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/CoverTransformer.java
@@ -1,9 +1,10 @@
package me.crosswall.lib.coverflow.core;
-import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
+import androidx.viewpager.widget.ViewPager;
+
/**
* Created by yuweichen on 16/4/29.
*/
@@ -15,33 +16,33 @@ public class CoverTransformer implements ViewPager.PageTransformer {
public static final float SCALE_MAX = 1f;
public static final float MARGIN_MIN = 0f;
public static final float MARGIN_MAX = 50f;
- public float scale = 0f;
+ public float scale = 0f;
private float pagerMargin = 0f;
private float spaceValue = 0f;
- private float rotationX = 0f;
- private float rotationY = 0f;
+ private float rotationX = 0f;
+ private float rotationY = 0f;
- public CoverTransformer(float scale, float pagerMargin,float spaceValue,float rotationY) {
+ public CoverTransformer(float scale, float pagerMargin, float spaceValue, float rotationY) {
this.scale = scale;
this.pagerMargin = pagerMargin;
- this.spaceValue = spaceValue;
- this.rotationY = rotationY;
+ this.spaceValue = spaceValue;
+ this.rotationY = rotationY;
}
@Override
public void transformPage(View page, float position) {
- Log.d(TAG,"position:"+position);
+ Log.d(TAG, "position:" + position);
- if(rotationY!=0){
- float realRotationY = Math.min(rotationY,Math.abs(position * rotationY));
- page.setRotationY(position < 0f ? realRotationY : - realRotationY);
+ if (rotationY != 0) {
+ float realRotationY = Math.min(rotationY, Math.abs(position * rotationY));
+ page.setRotationY(position < 0f ? realRotationY : -realRotationY);
}
if (scale != 0f) {
- float realScale = Utils.getFloat(1 - Math.abs(position * scale),SCALE_MIN,SCALE_MAX);
+ float realScale = Utils.getFloat(1 - Math.abs(position * scale), SCALE_MIN, SCALE_MAX);
page.setScaleX(realScale);
page.setScaleY(realScale);
}
@@ -51,8 +52,8 @@ public void transformPage(View page, float position) {
float realPagerMargin = position * (pagerMargin);
if (spaceValue != 0) {
- float realSpaceValue = Utils.getFloat(Math.abs(position * spaceValue),MARGIN_MIN,MARGIN_MAX);
- realPagerMargin += (position > 0) ? realSpaceValue : - realSpaceValue;
+ float realSpaceValue = Utils.getFloat(Math.abs(position * spaceValue), MARGIN_MIN, MARGIN_MAX);
+ realPagerMargin += (position > 0) ? realSpaceValue : -realSpaceValue;
}
page.setTranslationX(realPagerMargin);
diff --git a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkageCoverTransformer.java b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkageCoverTransformer.java
index 89f7aa2..4539a09 100644
--- a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkageCoverTransformer.java
+++ b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkageCoverTransformer.java
@@ -1,7 +1,9 @@
package me.crosswall.lib.coverflow.core;
-import android.support.v4.view.LinkagePager;
+
import android.view.View;
+import androidx.viewpager.widget.LinkagePager;
+
/**
* Created by yuweichen on 16/4/29.
@@ -14,28 +16,28 @@ public class LinkageCoverTransformer implements LinkagePager.PageTransformer {
public static final float SCALE_MAX = 1f;
public static final float MARGIN_MIN = 0f;
public static final float MARGIN_MAX = 50f;
- public float scale = 0f;
+ public float scale = 0f;
public float pagerMargin = 0f;
public float spaceValue = 0f;
- private float rotationY = 0f;
+ private float rotationY = 0f;
- public LinkageCoverTransformer(float scale, float pagerMargin,float spaceValue,float rotationY) {
+ public LinkageCoverTransformer(float scale, float pagerMargin, float spaceValue, float rotationY) {
this.scale = scale;
this.pagerMargin = pagerMargin;
- this.spaceValue = spaceValue;
- this.rotationY = rotationY;
+ this.spaceValue = spaceValue;
+ this.rotationY = rotationY;
}
@Override
public void transformPage(View page, float position) {
- // Log.d(TAG,"position:"+position);
+ // Log.d(TAG,"position:"+position);
if (scale != 0f) {
- float realScale = Utils.getFloat(1 - Math.abs(position * scale),SCALE_MIN,SCALE_MAX);
+ float realScale = Utils.getFloat(1 - Math.abs(position * scale), SCALE_MIN, SCALE_MAX);
page.setScaleX(realScale);
page.setScaleY(realScale);
}
@@ -45,8 +47,8 @@ public void transformPage(View page, float position) {
float realPagerMargin = position * (pagerMargin);
if (spaceValue != 0) {
- float realSpaceValue = Utils.getFloat(Math.abs(position * spaceValue),MARGIN_MIN,MARGIN_MAX);
- realPagerMargin += (position > 0) ? realSpaceValue : - realSpaceValue;
+ float realSpaceValue = Utils.getFloat(Math.abs(position * spaceValue), MARGIN_MIN, MARGIN_MAX);
+ realPagerMargin += (position > 0) ? realSpaceValue : -realSpaceValue;
}
page.setTranslationX(realPagerMargin);
@@ -54,7 +56,7 @@ public void transformPage(View page, float position) {
//TODO
//rotate status
- if(rotationY!=0){
+ if (rotationY != 0) {
float realRotationY = Math.abs(position * rotationY);
page.setRotationY(position < 0f ? realRotationY : -realRotationY);
}
diff --git a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkagePagerContainer.java b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkagePagerContainer.java
index 1d7a3f4..3685b0c 100644
--- a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkagePagerContainer.java
+++ b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/LinkagePagerContainer.java
@@ -3,10 +3,10 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Point;
-import android.support.v4.app.Fragment;
-import android.support.v4.view.LinkagePager;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPager;
+import androidx.fragment.app.Fragment;
+import androidx.viewpager.widget.LinkagePager;
+import androidx.core.view.ViewCompat;
+import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
diff --git a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/PagerContainer.java b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/PagerContainer.java
index 6d3a41d..5b10195 100644
--- a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/PagerContainer.java
+++ b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/PagerContainer.java
@@ -3,15 +3,16 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Point;
-import android.support.v4.app.Fragment;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import androidx.core.view.ViewCompat;
+import androidx.fragment.app.Fragment;
+import androidx.viewpager.widget.ViewPager;
+
/**
* PagerContainer: A layout that displays a ViewPager with its children that are outside
* the typical pager bounds.
@@ -91,10 +92,10 @@ public boolean onTouchEvent(MotionEvent event) {
// to implement scrolling from a touch outside the pager bounds.
- range = mPager.getWidth() / 2;
+ range = mPager.getWidth() / 2;
middle = this.getWidth() / 2;
- switch(event.getAction()) {
+ switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
pressStartTime = System.currentTimeMillis();
stayedWithinClickDistance = true;
@@ -129,8 +130,6 @@ public boolean onTouchEvent(MotionEvent event) {
}
-
-
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
//Force the container to redraw on scrolling.
diff --git a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/Utils.java b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/Utils.java
index cd0bc8a..8f13742 100644
--- a/coverflow/src/main/java/me/crosswall/lib/coverflow/core/Utils.java
+++ b/coverflow/src/main/java/me/crosswall/lib/coverflow/core/Utils.java
@@ -8,8 +8,8 @@
* Created by yuweichen on 16/4/29.
*/
public class Utils {
-
- public static int isInNonTappableRegion(int containerWidth,int pagerWidth,float oldX, float newX) {
+
+ public static int isInNonTappableRegion(int containerWidth, int pagerWidth, float oldX, float newX) {
int tappableWidth = pagerWidth;
int totalWidth = containerWidth;
int nonTappableWidth = (totalWidth - tappableWidth) / 2;
@@ -23,7 +23,7 @@ public static int isInNonTappableRegion(int containerWidth,int pagerWidth,float
return 0;
}
- public static float getFloat(float value,float minValue,float maxValue){
+ public static float getFloat(float value, float minValue, float maxValue) {
return Math.min(maxValue, Math.max(minValue, value));
}
diff --git a/gradle.properties b/gradle.properties
index 1d3591c..9a35cb2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,4 +15,20 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# org.gradle.parallel=true
+VERSION_NAME=2.0.0
+VERSION_CODE=200
+GROUP=com.github.lizhuogui.android
+POM_DESCRIPTION=A beautiful cover flow for android platform , base on ViewPager.
+POM_URL=https://github.com/lizhuogui/Android-Coverflow
+POM_SCM_URL=https://github.com/lizhuogui/Android-Coverflow
+POM_SCM_CONNECTION=scm:git@github.com:lizhuogui/Android-Coverflow.git
+POM_SCM_DEV_CONNECTION=scm:git@github.com:lizhuogui/Android-Coverflow.git
+POM_LICENCE_NAME=MIT License
+POM_LICENCE_URL=https://github.com/lizhuogui/Android-Coverflow/blob/master/LICENSE
+POM_LICENCE_DIST=repo
+POM_DEVELOPER_ID=lizhuogui
+POM_DEVELOPER_NAME=lizhuogui
+
+android.enableJetifier=true
+android.useAndroidX=true
diff --git a/gradle/gradle-mvn-push.gradle b/gradle/gradle-mvn-push.gradle
new file mode 100644
index 0000000..7b2d95c
--- /dev/null
+++ b/gradle/gradle-mvn-push.gradle
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2013 Chris Banes
+ *
+ * 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.
+ */
+
+apply plugin: 'maven'
+apply plugin: 'signing'
+
+def isReleaseBuild() {
+ return VERSION_NAME.contains("SNAPSHOT") == false
+}
+
+def getReleaseRepositoryUrl() {
+ return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
+ : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
+}
+
+def getSnapshotRepositoryUrl() {
+ return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
+ : "https://oss.sonatype.org/content/repositories/snapshots/"
+}
+
+def getRepositoryUsername() {
+ return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
+}
+
+def getRepositoryPassword() {
+ return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
+}
+
+afterEvaluate { project ->
+ uploadArchives {
+ repositories {
+ mavenDeployer {
+ beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
+
+ pom.groupId = GROUP
+ pom.artifactId = POM_ARTIFACT_ID
+ pom.version = VERSION_NAME
+
+ repository(url: getReleaseRepositoryUrl()) {
+ authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
+ }
+ snapshotRepository(url: getSnapshotRepositoryUrl()) {
+ authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
+ }
+
+ pom.project {
+ name POM_NAME
+ packaging POM_PACKAGING
+ description POM_DESCRIPTION
+ url POM_URL
+
+ scm {
+ url POM_SCM_URL
+ connection POM_SCM_CONNECTION
+ developerConnection POM_SCM_DEV_CONNECTION
+ }
+
+ licenses {
+ license {
+ name POM_LICENCE_NAME
+ url POM_LICENCE_URL
+ distribution POM_LICENCE_DIST
+ }
+ }
+
+ developers {
+ developer {
+ id POM_DEVELOPER_ID
+ name POM_DEVELOPER_NAME
+ }
+ }
+ }
+ }
+ }
+ }
+
+ signing {
+ required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
+ sign configurations.archives
+ }
+
+ task androidJavadocs(type: Javadoc) {
+ source = android.sourceSets.main.java.srcDirs
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+ }
+
+ task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
+ classifier = 'javadoc'
+ from androidJavadocs.destinationDir
+ }
+
+ task androidSourcesJar(type: Jar) {
+ classifier = 'sources'
+ from android.sourceSets.main.java.sourceFiles
+ }
+
+ artifacts {
+ archives androidSourcesJar
+ archives androidJavadocsJar
+ }
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 122a0dc..5a5b2cb 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 28 10:00:20 PST 2015
+#Sat May 25 16:44:34 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip