diff --git a/CarouselLayoutManager/build.gradle b/CarouselLayoutManager/build.gradle
index f15f61f..1cefbe2 100644
--- a/CarouselLayoutManager/build.gradle
+++ b/CarouselLayoutManager/build.gradle
@@ -5,7 +5,7 @@ buildscript {
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.2'
+ classpath 'com.android.tools.build:gradle:4.1.1'
}
}
diff --git a/CarouselLayoutManager/carousel/build.gradle b/CarouselLayoutManager/carousel/build.gradle
index 1c8a512..482fbbf 100644
--- a/CarouselLayoutManager/carousel/build.gradle
+++ b/CarouselLayoutManager/carousel/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.2'
+ classpath 'com.android.tools.build:gradle:4.1.1'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
classpath "com.github.dcendents:android-maven-plugin:1.2"
@@ -22,7 +22,7 @@ group = "com.azoft.carousellayoutmanager"
final def siteUrl = 'https://github.com/Azoft/CarouselLayoutManager'
final def gitUrl = "https://github.com/Azoft/CarouselLayoutManager.git"
// This is the library version used when deploying the artifact
-version = "1.2.4"
+version = "1.3.0"
final Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
@@ -76,14 +76,12 @@ install {
//////////////////////////////// Upload to BinTray ////////////////////////////////
android {
- compileSdkVersion 27
- buildToolsVersion "27.0.3"
- buildToolsVersion '27.0.3'
+ compileSdkVersion 30
resourcePrefix "carousellayoutmanager__"
defaultConfig {
minSdkVersion 11
- targetSdkVersion 27
+ targetSdkVersion 30
versionCode 1
versionName version
}
@@ -100,11 +98,10 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
- def supportVersion = "27.1.1"
- implementation "com.android.support:recyclerview-v7:$supportVersion"
- javadocDeps "com.android.support:support-annotations:$supportVersion"
- javadocDeps "com.android.support:recyclerview-v7:$supportVersion"
+ implementation 'androidx.recyclerview:recyclerview:1.1.0'
+ javadocDeps 'androidx.annotation:annotation:1.1.0'
+ javadocDeps 'androidx.recyclerview:recyclerview:1.1.0'
}
task sourcesJar(type: Jar) {
@@ -130,6 +127,6 @@ artifacts {
// Excluding aar artifacts from uploading
configurations.archives.artifacts.with { archives ->
for (def iter = archives.iterator(); iter.hasNext();) {
- if (iter.next().file =~ 'aar') iter.remove();
+ if (iter.next().file =~ 'aar') iter.remove()
}
}
\ No newline at end of file
diff --git a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselChildSelectionListener.java b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselChildSelectionListener.java
index 9fad919..1f5389d 100644
--- a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselChildSelectionListener.java
+++ b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselChildSelectionListener.java
@@ -1,7 +1,7 @@
package com.azoft.carousellayoutmanager;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
public abstract class CarouselChildSelectionListener {
@@ -31,12 +31,12 @@ protected CarouselChildSelectionListener(@NonNull final RecyclerView recyclerVie
mRecyclerView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {
@Override
- public void onChildViewAttachedToWindow(final View view) {
+ public void onChildViewAttachedToWindow(@NonNull final View view) {
view.setOnClickListener(mOnClickListener);
}
@Override
- public void onChildViewDetachedFromWindow(final View view) {
+ public void onChildViewDetachedFromWindow(@NonNull final View view) {
view.setOnClickListener(null);
}
});
diff --git a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselLayoutManager.java b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselLayoutManager.java
index 4d45085..80ff76c 100644
--- a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselLayoutManager.java
+++ b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselLayoutManager.java
@@ -5,13 +5,13 @@
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
-import android.support.annotation.CallSuper;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.widget.LinearSmoothScroller;
-import android.support.v7.widget.OrientationHelper;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.CallSuper;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.LinearSmoothScroller;
+import androidx.recyclerview.widget.OrientationHelper;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
@@ -36,7 +36,6 @@
* So like layout_height is not {@link ViewGroup.LayoutParams#MATCH_PARENT} for {@link CarouselLayoutManager#VERTICAL}
*
*/
-@SuppressWarnings({"ClassWithTooManyMethods", "OverlyComplexClass", "unused", "WeakerAccess"})
public class CarouselLayoutManager extends RecyclerView.LayoutManager implements RecyclerView.SmoothScroller.ScrollVectorProvider {
public static final int HORIZONTAL = OrientationHelper.HORIZONTAL;
@@ -312,7 +311,7 @@ protected int scrollBy(final int diff, @NonNull final RecyclerView.Recycler recy
}
@Override
- public void onMeasure(final RecyclerView.Recycler recycler, final RecyclerView.State state, final int widthSpec, final int heightSpec) {
+ public void onMeasure(@NonNull final RecyclerView.Recycler recycler, @NonNull final RecyclerView.State state, final int widthSpec, final int heightSpec) {
mDecoratedChildSizeInvalid = true;
super.onMeasure(recycler, state, widthSpec, heightSpec);
@@ -672,12 +671,7 @@ protected int getOffsetForCurrentView(@NonNull final View view) {
final int targetPosition = getPosition(view);
final float directionDistance = getScrollDirection(targetPosition);
- final int distance = Math.round(directionDistance * getScrollItemSize());
- if (mCircleLayout) {
- return distance;
- } else {
- return distance;
- }
+ return Math.round(directionDistance * getScrollItemSize());
}
/**
diff --git a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselSmoothScroller.java b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselSmoothScroller.java
index a89cee8..f05ed10 100644
--- a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselSmoothScroller.java
+++ b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselSmoothScroller.java
@@ -1,12 +1,12 @@
package com.azoft.carousellayoutmanager;
import android.graphics.PointF;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
/**
- * Custom implementation of {@link android.support.v7.widget.RecyclerView.SmoothScroller} that can work only with {@link CarouselLayoutManager}.
+ * Custom implementation of {@link RecyclerView.SmoothScroller} that can work only with {@link CarouselLayoutManager}.
*
* @see CarouselLayoutManager
*/
diff --git a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselZoomPostLayoutListener.java b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselZoomPostLayoutListener.java
index d39a339..ac5fc79 100644
--- a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselZoomPostLayoutListener.java
+++ b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselZoomPostLayoutListener.java
@@ -1,6 +1,6 @@
package com.azoft.carousellayoutmanager;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import android.view.View;
/**
@@ -10,9 +10,19 @@
*/
public class CarouselZoomPostLayoutListener implements CarouselLayoutManager.PostLayoutListener {
+ private final float mScaleMultiplier;
+
+ public CarouselZoomPostLayoutListener() {
+ this(0.17f);
+ }
+
+ public CarouselZoomPostLayoutListener(final float scaleMultiplier) {
+ mScaleMultiplier = scaleMultiplier;
+ }
+
@Override
public ItemTransformation transformChild(@NonNull final View child, final float itemPositionToCenterDiff, final int orientation) {
- final float scale = (float) (2 * (2 * -StrictMath.atan(Math.abs(itemPositionToCenterDiff) + 1.0) / Math.PI + 1));
+ final float scale = 1.0f - mScaleMultiplier * Math.abs(itemPositionToCenterDiff);
// because scaling will make view smaller in its center, then we should move this item to the top or bottom to make it visible
final float translateY;
diff --git a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CenterScrollListener.java b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CenterScrollListener.java
index 6587702..10396bf 100644
--- a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CenterScrollListener.java
+++ b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CenterScrollListener.java
@@ -1,6 +1,7 @@
package com.azoft.carousellayoutmanager;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
/**
* Class for centering items after scroll event.
@@ -11,7 +12,7 @@ public class CenterScrollListener extends RecyclerView.OnScrollListener {
private boolean mAutoSet = true;
@Override
- public void onScrollStateChanged(final RecyclerView recyclerView, final int newState) {
+ public void onScrollStateChanged(@NonNull final RecyclerView recyclerView, final int newState) {
super.onScrollStateChanged(recyclerView, newState);
final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (!(layoutManager instanceof CarouselLayoutManager)) {
diff --git a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/DefaultChildSelectionListener.java b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/DefaultChildSelectionListener.java
index 434e485..e11e17c 100644
--- a/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/DefaultChildSelectionListener.java
+++ b/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/DefaultChildSelectionListener.java
@@ -1,7 +1,7 @@
package com.azoft.carousellayoutmanager;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
public class DefaultChildSelectionListener extends CarouselChildSelectionListener {
diff --git a/CarouselLayoutManager/gradle.properties b/CarouselLayoutManager/gradle.properties
index bb8adec..1917227 100644
--- a/CarouselLayoutManager/gradle.properties
+++ b/CarouselLayoutManager/gradle.properties
@@ -10,7 +10,9 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
- org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+ android.enableJetifier=true
+android.useAndroidX=true
+org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
diff --git a/CarouselLayoutManager/gradle/wrapper/gradle-wrapper.properties b/CarouselLayoutManager/gradle/wrapper/gradle-wrapper.properties
index 7f6f200..6072135 100644
--- a/CarouselLayoutManager/gradle/wrapper/gradle-wrapper.properties
+++ b/CarouselLayoutManager/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Apr 18 08:55:54 NOVT 2018
+#Mon Jan 18 09:06:02 NOVT 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
diff --git a/CarouselLayoutManager/sample/build.gradle b/CarouselLayoutManager/sample/build.gradle
index a9835a4..11b6d4d 100644
--- a/CarouselLayoutManager/sample/build.gradle
+++ b/CarouselLayoutManager/sample/build.gradle
@@ -1,13 +1,14 @@
-apply plugin: 'com.android.application'
+plugins {
+ id 'com.android.application'
+}
android {
- compileSdkVersion 27
- buildToolsVersion '27.0.3'
+ compileSdkVersion 30
defaultConfig {
applicationId "com.azoft.carousellayoutmanager.sample"
minSdkVersion 14
- targetSdkVersion 27
+ targetSdkVersion 30
versionCode 1
versionName "1.0"
}
@@ -17,18 +18,17 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
- dataBinding {
- enabled = true
+ buildFeatures {
+ viewBinding true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
- def supportVersion = "27.1.1"
- implementation "com.android.support:appcompat-v7:$supportVersion"
- implementation "com.android.support:design:$supportVersion"
- implementation "com.android.support:recyclerview-v7:$supportVersion"
- implementation 'com.azoft.carousellayoutmanager:carousel:1.2.4'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'com.google.android.material:material:1.2.1'
+ implementation 'androidx.recyclerview:recyclerview:1.1.0'
+ implementation 'com.azoft.carousellayoutmanager:carousel:1.3.0'
// implementation project(':carousel')
}
diff --git a/CarouselLayoutManager/sample/src/main/AndroidManifest.xml b/CarouselLayoutManager/sample/src/main/AndroidManifest.xml
index bcb1cd4..dbd5b02 100644
--- a/CarouselLayoutManager/sample/src/main/AndroidManifest.xml
+++ b/CarouselLayoutManager/sample/src/main/AndroidManifest.xml
@@ -1,13 +1,15 @@
-
+
+ android:theme="@style/AppTheme"
+ tools:ignore="AllowBackup">
{
- @SuppressWarnings("UnsecureRandomNumberGeneration")
- private final Random mRandom = new Random();
private final int[] mColors;
private final int[] mPosition;
- private int mItemsCount = 100;
+ private final int mItemsCount = 100;
TestAdapter() {
mColors = new int[mItemsCount];
mPosition = new int[mItemsCount];
for (int i = 0; mItemsCount > i; ++i) {
//noinspection MagicNumber
- mColors[i] = Color.argb(255, mRandom.nextInt(256), mRandom.nextInt(256), mRandom.nextInt(256));
+ final Random random = new Random();
+ mColors[i] = Color.argb(255, random.nextInt(256), random.nextInt(256), random.nextInt(256));
mPosition[i] = i;
}
}
diff --git a/CarouselLayoutManager/sample/src/main/res/layout/activity_carousel_preview.xml b/CarouselLayoutManager/sample/src/main/res/layout/activity_carousel_preview.xml
index 9d33e46..d2ae084 100644
--- a/CarouselLayoutManager/sample/src/main/res/layout/activity_carousel_preview.xml
+++ b/CarouselLayoutManager/sample/src/main/res/layout/activity_carousel_preview.xml
@@ -1,104 +1,95 @@
-
-
+
+
+
-
-
+
-
+ android:layout_marginTop="?attr/actionBarSize"
+ android:orientation="vertical">
-
+ android:layout_height="250dp"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin">
+
+
-
+ android:layout_height="1dp"
+ android:layout_centerInParent="true"
+ android:background="#f00" />
-
+
-
-
-
+
+
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+ android:layout_height="1dp"
+ android:layout_centerInParent="true"
+ android:background="#f00" />
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CarouselLayoutManager/sample/src/main/res/layout/item_view.xml b/CarouselLayoutManager/sample/src/main/res/layout/item_view.xml
index c432812..c058802 100644
--- a/CarouselLayoutManager/sample/src/main/res/layout/item_view.xml
+++ b/CarouselLayoutManager/sample/src/main/res/layout/item_view.xml
@@ -1,45 +1,33 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+ android:layout_height="1dp"
+ android:layout_centerInParent="true"
+ android:background="#0f0" />
-
+
-
\ No newline at end of file
+
\ No newline at end of file