From 3f8f4b2da98fe2f0f7f134bfb784376407e05e39 Mon Sep 17 00:00:00 2001 From: linweijia <1421797481@qq.com> Date: Mon, 26 Aug 2019 22:33:46 +0800 Subject: [PATCH] 0.3.0 support for androidx --- README.md | 11 +++++++- README_EN.md | 10 ++++++- build.gradle | 4 ++- demo/build.gradle | 26 +++++++++---------- .../ExampleInstrumentedTest.java | 4 +-- .../BannerViewActivity.java | 5 ++-- .../BlankFragment.java | 2 +- .../CarouseActivity.java | 10 +++---- .../viewpagerindicator_demo/DemoActivity.java | 4 +-- .../NotCarouselActivity.java | 11 ++++---- .../main/res/layout/activity_banner_view.xml | 4 +-- demo/src/main/res/layout/activity_demo.xml | 4 +-- demo/src/main/res/layout/activity_main.xml | 2 +- .../main/res/layout/activity_not_carousel.xml | 2 +- gradle.properties | 2 ++ gradle/wrapper/gradle-wrapper.properties | 2 +- viewpagerindicator/build.gradle | 20 +++++++------- .../ExampleInstrumentedTest.java | 4 +-- .../ViewPagerIndicator.java | 3 +-- 19 files changed, 74 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 9432d7b..21c6922 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,18 @@ allprojects { ### 然后在module的build.gradle 添加: +#### support for androidx: + +``` +dependencies { + implementation 'com.github.LinweiJ:ViewPagerIndicator:0.3.0' + } +``` +#### support for support: + ``` dependencies { - compile 'com.github.LinweiJ:ViewPagerIndicator:0.2.0' + implementation 'com.github.LinweiJ:ViewPagerIndicator:0.2.0' } ``` diff --git a/README_EN.md b/README_EN.md index 740d63a..18ee0bd 100644 --- a/README_EN.md +++ b/README_EN.md @@ -26,12 +26,20 @@ allprojects { Add the dependency in your module build.gradle : +support for androidx: + ``` dependencies { - compile 'com.github.LinweiJ:ViewPagerIndicator:0.2.0' + implementation 'com.github.LinweiJ:ViewPagerIndicator:0.3.0' } ``` +support for support: +``` +dependencies { + implementation 'com.github.LinweiJ:ViewPagerIndicator:0.2.0' + } +``` ## Usage diff --git a/build.gradle b/build.gradle index d9b961b..2302f3a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:3.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -16,6 +17,7 @@ allprojects { repositories { jcenter() maven { url "https://jitpack.io" } + google() } } diff --git a/demo/build.gradle b/demo/build.gradle index f0db178..f3b7210 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.lwj.widget.viewpagerindicator_demo" minSdkVersion 14 - targetSdkVersion 25 + targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -20,20 +20,20 @@ android { } dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(include: ['*.jar'], dir: 'libs') + androidTestImplementation('androidx.test.espresso:espresso-core:3.3.0-alpha02', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile project(':viewpagerindicator') - compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.android.support:support-v4:25.3.1' - testCompile 'junit:junit:4.12' - compile 'com.android.support.constraint:constraint-layout:1.0.2' + implementation project(':viewpagerindicator') + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + testImplementation 'junit:junit:4.12' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' //BannerView - compile('com.github.LinweiJ:BannerView:0.0.1', { + implementation('com.github.LinweiJ:BannerView:0.0.1', { exclude group: 'com.android.support' }) //Glide - compile "com.github.bumptech.glide:glide:3.7.0" + implementation "com.github.bumptech.glide:glide:3.7.0" } diff --git a/demo/src/androidTest/java/com/lwj/widget/viewpagerindicator_demo/ExampleInstrumentedTest.java b/demo/src/androidTest/java/com/lwj/widget/viewpagerindicator_demo/ExampleInstrumentedTest.java index db8d24c..76c6dac 100644 --- a/demo/src/androidTest/java/com/lwj/widget/viewpagerindicator_demo/ExampleInstrumentedTest.java +++ b/demo/src/androidTest/java/com/lwj/widget/viewpagerindicator_demo/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.lwj.widget.viewpagerindicator_demo; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BannerViewActivity.java b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BannerViewActivity.java index 825f465..56ed869 100644 --- a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BannerViewActivity.java +++ b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BannerViewActivity.java @@ -1,9 +1,8 @@ package com.lwj.widget.viewpagerindicator_demo; -import android.support.v4.app.Fragment; -import android.support.v7.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.view.View; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; diff --git a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BlankFragment.java b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BlankFragment.java index f6d3d1e..dc1577f 100644 --- a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BlankFragment.java +++ b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/BlankFragment.java @@ -2,7 +2,7 @@ import android.os.Bundle; -import android.support.v4.app.Fragment; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/CarouseActivity.java b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/CarouseActivity.java index 6b458a9..e11ea18 100644 --- a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/CarouseActivity.java +++ b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/CarouseActivity.java @@ -1,11 +1,11 @@ package com.lwj.widget.viewpagerindicator_demo; import android.content.Intent; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.ViewPager; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; diff --git a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/DemoActivity.java b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/DemoActivity.java index d22a42b..76e5ddd 100644 --- a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/DemoActivity.java +++ b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/DemoActivity.java @@ -1,8 +1,8 @@ package com.lwj.widget.viewpagerindicator_demo; import android.content.Intent; -import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.app.AppCompatActivity; + +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; diff --git a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/NotCarouselActivity.java b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/NotCarouselActivity.java index 5aa3760..9d56319 100644 --- a/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/NotCarouselActivity.java +++ b/demo/src/main/java/com/lwj/widget/viewpagerindicator_demo/NotCarouselActivity.java @@ -1,11 +1,10 @@ package com.lwj.widget.viewpagerindicator_demo; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import com.lwj.widget.viewpagerindicator.ViewPagerIndicator; diff --git a/demo/src/main/res/layout/activity_banner_view.xml b/demo/src/main/res/layout/activity_banner_view.xml index 3ad2f83..436579c 100644 --- a/demo/src/main/res/layout/activity_banner_view.xml +++ b/demo/src/main/res/layout/activity_banner_view.xml @@ -1,5 +1,5 @@ - - + diff --git a/demo/src/main/res/layout/activity_demo.xml b/demo/src/main/res/layout/activity_demo.xml index 67bb6e7..ec3efd9 100644 --- a/demo/src/main/res/layout/activity_demo.xml +++ b/demo/src/main/res/layout/activity_demo.xml @@ -1,5 +1,5 @@ - - + diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 61e1b6b..994002c 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -16,7 +16,7 @@ android:layout_height="match_parent" android:layout_alignParentBottom="true"> - diff --git a/demo/src/main/res/layout/activity_not_carousel.xml b/demo/src/main/res/layout/activity_not_carousel.xml index c7b01f7..05d004a 100644 --- a/demo/src/main/res/layout/activity_not_carousel.xml +++ b/demo/src/main/res/layout/activity_not_carousel.xml @@ -16,7 +16,7 @@ android:layout_alignParentBottom="true" tools:layout_editor_absoluteY="8dp" tools:layout_editor_absoluteX="8dp"> - diff --git a/gradle.properties b/gradle.properties index 869e8ce..40edf30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1024m # When configured, Gradle will run in incubating parallel mode. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 04e285f..c3510d6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/viewpagerindicator/build.gradle b/viewpagerindicator/build.gradle index 61945f6..6c91135 100644 --- a/viewpagerindicator/build.gradle +++ b/viewpagerindicator/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { minSdkVersion 14 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" + targetSdkVersion 28 + versionCode 5 + versionName "0.3.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -22,10 +22,10 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(include: ['*.jar'], dir: 'libs') + androidTestImplementation('androidx.test.espresso:espresso-core:3.3.0-alpha02', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:25.3.1' - testCompile 'junit:junit:4.12' + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' + testImplementation 'junit:junit:4.12' } diff --git a/viewpagerindicator/src/androidTest/java/com/lwj/widget/viewpagerindicator/ExampleInstrumentedTest.java b/viewpagerindicator/src/androidTest/java/com/lwj/widget/viewpagerindicator/ExampleInstrumentedTest.java index b289e08..411db5a 100644 --- a/viewpagerindicator/src/androidTest/java/com/lwj/widget/viewpagerindicator/ExampleInstrumentedTest.java +++ b/viewpagerindicator/src/androidTest/java/com/lwj/widget/viewpagerindicator/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.lwj.widget.viewpagerindicator; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/viewpagerindicator/src/main/java/com/lwj/widget/viewpagerindicator/ViewPagerIndicator.java b/viewpagerindicator/src/main/java/com/lwj/widget/viewpagerindicator/ViewPagerIndicator.java index b00bff9..4210a05 100644 --- a/viewpagerindicator/src/main/java/com/lwj/widget/viewpagerindicator/ViewPagerIndicator.java +++ b/viewpagerindicator/src/main/java/com/lwj/widget/viewpagerindicator/ViewPagerIndicator.java @@ -6,9 +6,8 @@ import android.graphics.Paint; import android.graphics.Path; import android.graphics.RectF; -import android.support.v4.view.ViewPager; +import androidx.viewpager.widget.ViewPager; import android.util.AttributeSet; -import android.util.Log; import android.view.View;