diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..e0cdd4a Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/benj.xml b/.idea/dictionaries/benj.xml new file mode 100644 index 0000000..f2bbd42 --- /dev/null +++ b/.idea/dictionaries/benj.xml @@ -0,0 +1,8 @@ + + + + scrollchoice + webianks + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..80b5fcb --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3378229 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fd675aa --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 15108da..5b0221f 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ Scrollable view which can be used to give different choices to user with nice ui # Add With Gradle Dependency ```groovy -compile 'com.webianks.library:scroll-choice:1.0.1' +implementation 'com.webianks.library:scroll-choice:1.0.2' ``` **Maven:** ```xml com.webianks.library scroll-choice - 1.0.1 + 1.0.2 pom ``` @@ -26,7 +26,7 @@ compile 'com.webianks.library:scroll-choice:1.0.1' 15 # Compile SDK -25 +29 # Add ScrollChoice to layout ```xml @@ -61,7 +61,7 @@ data.add("France"); **Add to the ScrollChoice object with default selected item index** ```java -scrollChoice.addItems(data,5); +scrollChoice.addItems(data, 5); ``` **Attach listener to listen to know which item was selected** diff --git a/app/build.gradle b/app/build.gradle index e8bd8bf..22a375f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.0" + compileSdkVersion 29 + buildToolsVersion "29.0.2" defaultConfig { applicationId "com.webianks.library.scrollchoice" minSdkVersion 15 - targetSdkVersion 25 + targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -20,6 +20,6 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:25.1.0' - compile project(':scroll-choice'); + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation project(':scroll-choice') } diff --git a/app/src/main/res/drawable/border_background.xml b/app/src/main/res/drawable/border_background.xml deleted file mode 100644 index 3e89280..0000000 --- a/app/src/main/res/drawable/border_background.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/gradient_background.xml b/app/src/main/res/drawable/gradient_background.xml deleted file mode 100644 index 2202d93..0000000 --- a/app/src/main/res/drawable/gradient_background.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 47c8224..0000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 16dp - 16dp - diff --git a/build.gradle b/build.gradle index 4f657f0..0f4d96e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,10 +3,11 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.4.0-alpha5' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' + classpath 'com.android.tools.build:gradle:4.1.1' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' // NOTE: Do not place your application dependencies here; they belong @@ -17,6 +18,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a9642ac..e2c1afc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Apr 13 21:32:38 IST 2017 +#Fri Dec 11 16:53:01 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/scroll-choice/build.gradle b/scroll-choice/build.gradle index 7506ec3..ced6eac 100644 --- a/scroll-choice/build.gradle +++ b/scroll-choice/build.gradle @@ -13,7 +13,7 @@ ext { siteUrl = 'http://www.webianks.com/scrollchoice' gitUrl = 'https://github.com/webianks/ScrollChoice.git' - libraryVersion = '1.0.1' + libraryVersion = '1.0.2' developerId = 'webianks' developerName = 'Ramankit Singh' @@ -25,12 +25,12 @@ ext { } android { - compileSdkVersion 25 - buildToolsVersion "25.0.0" + compileSdkVersion 29 + buildToolsVersion "29.0.2" defaultConfig { minSdkVersion 15 - targetSdkVersion 25 + targetSdkVersion 29 versionCode 2 versionName "1.1" @@ -46,7 +46,7 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:25.1.0' + implementation 'com.android.support:appcompat-v7:28.0.0' } apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' \ No newline at end of file diff --git a/scroll-choice/src/main/java/com/webianks/library/scroll_choice/ScrollChoice.java b/scroll-choice/src/main/java/com/webianks/library/scroll_choice/ScrollChoice.java index e48c7b2..ad835ca 100644 --- a/scroll-choice/src/main/java/com/webianks/library/scroll_choice/ScrollChoice.java +++ b/scroll-choice/src/main/java/com/webianks/library/scroll_choice/ScrollChoice.java @@ -1,18 +1,17 @@ package com.webianks.library.scroll_choice; -/** - * Created by R Ankit on 17-02-2017. - */ - import android.content.Context; import android.util.AttributeSet; import java.util.List; +/** + * Created by R Ankit on 17-02-2017. + */ public class ScrollChoice extends WheelPicker { private OnItemSelectedListener onItemSelectedListener; - WheelPicker.Adapter adapter; + final WheelPicker.Adapter adapter; private int defaultIndex; public ScrollChoice(Context context) { diff --git a/scroll-choice/src/main/java/com/webianks/library/scroll_choice/WheelPicker.java b/scroll-choice/src/main/java/com/webianks/library/scroll_choice/WheelPicker.java index 7d37654..c5678fa 100644 --- a/scroll-choice/src/main/java/com/webianks/library/scroll_choice/WheelPicker.java +++ b/scroll-choice/src/main/java/com/webianks/library/scroll_choice/WheelPicker.java @@ -1,9 +1,5 @@ package com.webianks.library.scroll_choice; -/** - * Created by R Ankit on 17-02-2017. - */ - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; @@ -28,6 +24,9 @@ import java.util.List; import java.util.Locale; +/** + * Created by R Ankit on 17-02-2017. + */ public abstract class WheelPicker extends View { public static final int SCROLL_STATE_IDLE = 0; @@ -41,16 +40,17 @@ public abstract class WheelPicker extends View { private final Handler handler = new Handler(); private final Paint paintBackground; - private Paint paint; - private Scroller scroller; + private final Paint paint; + private final Scroller scroller; private VelocityTracker tracker; private OnItemSelectedListener onItemSelectedListener; private OnWheelChangeListener onWheelChangeListener; - private Rect rectDrawn; - private Rect rectIndicatorHead, rectIndicatorFoot; - private Rect rectCurrentItem; + private final Rect rectDrawn; + private final Rect rectIndicatorHead; + private final Rect rectIndicatorFoot; + private final Rect rectCurrentItem; private BaseAdapter adapter; private String maxWidthText; @@ -84,10 +84,10 @@ public abstract class WheelPicker extends View { private boolean isClick; private boolean isForceFinishScroll; - private int backgroundColor; - private int backgroundOfSelectedItem; + private final int backgroundColor; + private final int backgroundOfSelectedItem; - private Runnable runnable = new Runnable() { + private final Runnable runnable = new Runnable() { @Override public void run() { if (null == adapter) return; @@ -354,7 +354,7 @@ protected void onDraw(Canvas canvas) { if (hasAtmospheric) { int alpha = (int) ((drawnCenterY - Math.abs(drawnCenterY - mDrawnItemCenterY)) * 1.0F / drawnCenterY * 255); - alpha = alpha < 0 ? 0 : alpha; + alpha = Math.max(alpha, 0); paint.setAlpha(alpha); } // Correct item's drawn centerY base on curved state @@ -375,9 +375,7 @@ protected void onDraw(Canvas canvas) { canvas.clipRect(rectCurrentItem); canvas.drawText(data, drawnCenterX, drawnCenterY, paint); canvas.restore(); - } else { - canvas.save(); canvas.clipRect(rectDrawn); canvas.drawText(data, drawnCenterX, drawnCenterY, paint); @@ -516,7 +514,7 @@ public void onAnimationEnd(Animator animation) { } } - private final void onItemSelected() { + private void onItemSelected() { int position = currentItemPosition; final Object item = this.adapter.getItem(position); if (null != onItemSelectedListener) { @@ -785,7 +783,7 @@ public interface OnWheelChangeListener { } public static class Adapter implements BaseAdapter { - private List data; + private final List data; public Adapter() { this(new ArrayList());