From 71ea754ca67f8bc760959413575cef0e8b2bbc6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Vicente=20G=C3=B3mez=20S=C3=A1nchez?= Date: Wed, 20 May 2020 16:49:03 +0200 Subject: [PATCH] Migrate to Android X (#55) * Migrate to android x * Update travis configuration --- .travis.yml | 2 ++ README.md | 2 +- build.gradle | 2 +- gradle.properties | 7 +++++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- renderers/build.gradle | 20 +++++++++---------- .../DefaultDiffUtilItemCallback.java | 4 ++-- .../pedrogomez/renderers/DiffCallback.java | 2 +- .../renderers/RVListRendererAdapter.java | 10 +++++----- .../renderers/RVRendererAdapter.java | 4 ++-- .../com/pedrogomez/renderers/Renderer.java | 4 ++-- .../renderers/RendererViewHolder.java | 2 +- .../renderers/VPRendererAdapter.java | 2 +- .../renderers/RVListRendererAdapterTest.java | 2 +- sample/build.gradle | 16 +++++++++------ .../ui/RecyclerViewAdapterActivity.java | 8 +++++--- .../ui/RecyclerViewListAdapterActivity.java | 4 ++-- .../sample/ui/ViewPagerActivity.java | 6 ++++-- .../ui/diffing/VideoItemDiffCallback.java | 5 +++-- .../res/layout/activity_recycler_view.xml | 2 +- .../main/res/layout/activity_view_pager.xml | 2 +- 21 files changed, 62 insertions(+), 48 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4832e16..98ff990 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,10 @@ language: android android: components: - tools + - build-tools-29.0.2 - build-tools-28.0.3 - android-28 + - android-29 - extra-android-support - extra-google-m2repository - extra-android-m2repository diff --git a/README.md b/README.md index b243b59..82afe7f 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Add this dependency to your ``build.gradle``: ```groovy dependencies{ - compile 'com.github.pedrovgs:renderers:3.4.0' + implementation 'com.github.pedrovgs:renderers:4.0.0' } ``` diff --git a/build.gradle b/build.gradle index be5a9ae..8aaec63 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.2' + classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.github.pedrovgs:kuronometer:0.1.1' } } diff --git a/gradle.properties b/gradle.properties index 3801bd3..e5e99c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,8 +2,8 @@ POM_NAME=Renderers POM_ARTIFACT_ID=renderers POM_PACKAGING=aar -VERSION_NAME=3.5.1-SNAPSHOT -VERSION_CODE=030501 +VERSION_NAME=4.0.0 +VERSION_CODE=040000 GROUP=com.github.pedrovgs POM_DESCRIPTION=Android library to avoid duplicated adapters code @@ -16,3 +16,6 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo POM_DEVELOPER_ID=pedrovgs POM_DEVELOPER_NAME=Pedro Vicente Gómez Sánchez + +android.useAndroidX=true +android.enableJetifier=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5417487..92736ab 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Apr 08 16:06:53 CEST 2019 +#Wed May 20 13:56:23 CEST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/renderers/build.gradle b/renderers/build.gradle index 8caf87c..ddc7fe8 100644 --- a/renderers/build.gradle +++ b/renderers/build.gradle @@ -1,25 +1,25 @@ apply plugin: 'com.android.library' apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' - apply plugin: 'com.github.pedrovgs.kuronometer' + kuronometer { platformName = 'Android' //This value can be true or false. //It's used to remove the project sensitive information before to being reported. By default is true. - reportProjectInfo = true + reportProjectInfo = false //This value can be true or false. //It's used to send or not the build report to the kuronometer server. By default is true. - reportDataRemotely = true + reportDataRemotely = false //This value can be true or false. //It's used to show a message after the build execution showing the report execution result. By default is false. - verbose = true + verbose = false } android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { - minSdkVersion 10 - targetSdkVersion 28 + minSdkVersion 14 + targetSdkVersion 29 versionCode 1 versionName "1.0" } @@ -35,9 +35,9 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:recyclerview-v7:28.0.0' - implementation 'com.android.support:support-v4:28.0.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.viewpager:viewpager:1.0.0' testImplementation 'junit:junit:4.12' - testImplementation "org.mockito:mockito-core:2.26.0" + testImplementation 'org.mockito:mockito-core:2.26.0' testImplementation 'org.robolectric:robolectric:4.2' } diff --git a/renderers/src/main/java/com/pedrogomez/renderers/DefaultDiffUtilItemCallback.java b/renderers/src/main/java/com/pedrogomez/renderers/DefaultDiffUtilItemCallback.java index e507735..6c4d40d 100644 --- a/renderers/src/main/java/com/pedrogomez/renderers/DefaultDiffUtilItemCallback.java +++ b/renderers/src/main/java/com/pedrogomez/renderers/DefaultDiffUtilItemCallback.java @@ -1,7 +1,7 @@ package com.pedrogomez.renderers; -import android.support.annotation.NonNull; -import android.support.v7.util.DiffUtil; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.DiffUtil; public class DefaultDiffUtilItemCallback extends DiffUtil.ItemCallback { diff --git a/renderers/src/main/java/com/pedrogomez/renderers/DiffCallback.java b/renderers/src/main/java/com/pedrogomez/renderers/DiffCallback.java index d235a09..be76c03 100644 --- a/renderers/src/main/java/com/pedrogomez/renderers/DiffCallback.java +++ b/renderers/src/main/java/com/pedrogomez/renderers/DiffCallback.java @@ -15,7 +15,7 @@ */ package com.pedrogomez.renderers; -import android.support.v7.util.DiffUtil; +import androidx.recyclerview.widget.DiffUtil; import java.util.List; diff --git a/renderers/src/main/java/com/pedrogomez/renderers/RVListRendererAdapter.java b/renderers/src/main/java/com/pedrogomez/renderers/RVListRendererAdapter.java index 428b0df..900bd84 100644 --- a/renderers/src/main/java/com/pedrogomez/renderers/RVListRendererAdapter.java +++ b/renderers/src/main/java/com/pedrogomez/renderers/RVListRendererAdapter.java @@ -1,10 +1,10 @@ package com.pedrogomez.renderers; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.recyclerview.extensions.AsyncDifferConfig; -import android.support.v7.recyclerview.extensions.ListAdapter; -import android.support.v7.util.DiffUtil; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.AsyncDifferConfig; +import androidx.recyclerview.widget.ListAdapter; +import androidx.recyclerview.widget.DiffUtil; import android.view.LayoutInflater; import android.view.ViewGroup; diff --git a/renderers/src/main/java/com/pedrogomez/renderers/RVRendererAdapter.java b/renderers/src/main/java/com/pedrogomez/renderers/RVRendererAdapter.java index 6d6532f..d80b3aa 100644 --- a/renderers/src/main/java/com/pedrogomez/renderers/RVRendererAdapter.java +++ b/renderers/src/main/java/com/pedrogomez/renderers/RVRendererAdapter.java @@ -15,8 +15,8 @@ */ package com.pedrogomez.renderers; -import android.support.v7.util.DiffUtil; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.DiffUtil; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.ViewGroup; diff --git a/renderers/src/main/java/com/pedrogomez/renderers/Renderer.java b/renderers/src/main/java/com/pedrogomez/renderers/Renderer.java index b0ca06d..e9ff9d4 100644 --- a/renderers/src/main/java/com/pedrogomez/renderers/Renderer.java +++ b/renderers/src/main/java/com/pedrogomez/renderers/Renderer.java @@ -113,14 +113,14 @@ protected void setContent(T content) { * * @param rootView inflated using previously. */ - protected abstract void setUpView(View rootView); + protected void setUpView(View rootView) { } /** * Set all the listeners to members mapped in setUpView method. * * @param rootView inflated using previously. */ - protected abstract void hookListeners(View rootView); + protected void hookListeners(View rootView) { } /** * Inflate renderer layout. The view inflated can't be null. If this method returns a null view a diff --git a/renderers/src/main/java/com/pedrogomez/renderers/RendererViewHolder.java b/renderers/src/main/java/com/pedrogomez/renderers/RendererViewHolder.java index 1d3c142..4f4e527 100644 --- a/renderers/src/main/java/com/pedrogomez/renderers/RendererViewHolder.java +++ b/renderers/src/main/java/com/pedrogomez/renderers/RendererViewHolder.java @@ -15,7 +15,7 @@ */ package com.pedrogomez.renderers; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; /** * RecyclerView.ViewHolder extension created to be able to use Renderer classes in RecyclerView diff --git a/renderers/src/main/java/com/pedrogomez/renderers/VPRendererAdapter.java b/renderers/src/main/java/com/pedrogomez/renderers/VPRendererAdapter.java index 35151a4..31be684 100644 --- a/renderers/src/main/java/com/pedrogomez/renderers/VPRendererAdapter.java +++ b/renderers/src/main/java/com/pedrogomez/renderers/VPRendererAdapter.java @@ -15,7 +15,7 @@ */ package com.pedrogomez.renderers; -import android.support.v4.view.PagerAdapter; +import androidx.viewpager.widget.PagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/renderers/src/test/java/com/pedrogomez/renderers/RVListRendererAdapterTest.java b/renderers/src/test/java/com/pedrogomez/renderers/RVListRendererAdapterTest.java index b7f3ede..1d19f5c 100644 --- a/renderers/src/test/java/com/pedrogomez/renderers/RVListRendererAdapterTest.java +++ b/renderers/src/test/java/com/pedrogomez/renderers/RVListRendererAdapterTest.java @@ -1,6 +1,6 @@ package com.pedrogomez.renderers; -import android.support.v7.util.DiffUtil; +import androidx.recyclerview.widget.DiffUtil; import android.view.LayoutInflater; import android.view.ViewGroup; import com.pedrogomez.renderers.exception.NullRendererBuiltException; diff --git a/sample/build.gradle b/sample/build.gradle index f8ec78d..914163c 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { applicationId "com.github.pedrovgs.renderers.sample" minSdkVersion 14 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 1 versionName "1.0" } @@ -18,14 +18,18 @@ android { lintOptions { abortOnError false } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support:recyclerview-v7:28.0.0' - implementation 'com.jakewharton:butterknife:8.8.1' - annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' + implementation 'com.jakewharton:butterknife:10.1.0' + annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0' implementation 'com.squareup.picasso:picasso:2.71828' implementation project(':renderers') + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.viewpager:viewpager:1.0.0' } diff --git a/sample/src/main/java/com/pedrogomez/renderers/sample/ui/RecyclerViewAdapterActivity.java b/sample/src/main/java/com/pedrogomez/renderers/sample/ui/RecyclerViewAdapterActivity.java index dbd6b2a..8552a48 100644 --- a/sample/src/main/java/com/pedrogomez/renderers/sample/ui/RecyclerViewAdapterActivity.java +++ b/sample/src/main/java/com/pedrogomez/renderers/sample/ui/RecyclerViewAdapterActivity.java @@ -16,8 +16,9 @@ package com.pedrogomez.renderers.sample.ui; import android.os.Bundle; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.pedrogomez.renderers.AdapteeCollection; import com.pedrogomez.renderers.RVRendererAdapter; @@ -41,7 +42,8 @@ public class RecyclerViewAdapterActivity extends BaseActivity { private static final int VIDEO_COUNT = 100; - @BindView(R.id.rv_renderers) RecyclerView recyclerView; + @BindView(R.id.rv_renderers) + RecyclerView recyclerView; private RVRendererAdapter