Skip to content

Commit 5e7c4ed

Browse files
committed
Migrate to AndroidX.
1 parent 7720af7 commit 5e7c4ed

File tree

15 files changed

+48
-46
lines changed

15 files changed

+48
-46
lines changed
Binary file not shown.

app/build.gradle

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ apply plugin: 'kotlin-android'
55
apply plugin: 'kotlin-android-extensions'
66

77
android {
8-
compileSdkVersion 27
8+
compileSdkVersion 28
99
defaultConfig {
1010
applicationId "com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide"
1111
minSdkVersion 16
1212
//noinspection OldTargetApi
13-
targetSdkVersion 27
13+
targetSdkVersion 28
1414
versionCode 1
1515
versionName "1.0"
16-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1717
}
1818
buildTypes {
1919
release {
@@ -30,20 +30,20 @@ dependencies {
3030
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3131

3232
//Support
33-
implementation 'com.android.support:appcompat-v7:27.1.1'
34-
implementation 'com.android.support:design:27.1.1'
35-
implementation 'com.android.support:recyclerview-v7:27.1.1'
36-
implementation 'com.android.support:cardview-v7:27.1.1'
33+
implementation 'androidx.appcompat:appcompat:1.0.2'
34+
implementation 'com.google.android.material:material:1.0.0'
35+
implementation 'androidx.recyclerview:recyclerview:1.0.0'
36+
implementation 'androidx.cardview:cardview:1.0.0'
3737

3838
//Architecture Components
39-
implementation "android.arch.lifecycle:extensions:1.1.1"
39+
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
4040

4141
//Paging
42-
implementation "android.arch.paging:runtime:1.0.1"
42+
implementation 'androidx.paging:paging-runtime:2.1.0'
4343

4444
//Networking
45-
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
46-
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
45+
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
46+
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
4747
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
4848

4949
//Rx
@@ -55,6 +55,6 @@ dependencies {
5555

5656
//Testing
5757
testImplementation 'junit:junit:4.12'
58-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
59-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
58+
androidTestImplementation 'androidx.test:runner:1.2.0'
59+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
6060
}

app/src/androidTest/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/ExampleInstrumentedTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.support.test.InstrumentationRegistry
4-
import android.support.test.runner.AndroidJUnit4
3+
import androidx.test.InstrumentationRegistry
4+
import androidx.test.runner.AndroidJUnit4
55

66
import org.junit.Test
77
import org.junit.runner.RunWith

app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/ListFooterViewHolder.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.support.v7.widget.RecyclerView
3+
import androidx.recyclerview.widget.RecyclerView
44
import android.view.LayoutInflater
55
import android.view.View
66
import android.view.View.VISIBLE
77
import android.view.ViewGroup
88
import kotlinx.android.synthetic.main.item_list_footer.view.*
99

10-
class ListFooterViewHolder(view: View) : RecyclerView.ViewHolder(view) {
10+
class ListFooterViewHolder(view: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(view) {
1111

1212
fun bind(status: State?) {
1313
itemView.progress_bar.visibility = if (status == State.LOADING) VISIBLE else View.INVISIBLE

app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/NewsDataSource.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.arch.lifecycle.MutableLiveData
4-
import android.arch.paging.PageKeyedDataSource
3+
import androidx.lifecycle.MutableLiveData
4+
import androidx.paging.PageKeyedDataSource
55
import io.reactivex.Completable
66
import io.reactivex.android.schedulers.AndroidSchedulers
77
import io.reactivex.disposables.CompositeDisposable

app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/NewsDataSourceFactory.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.arch.lifecycle.MutableLiveData
4-
import android.arch.paging.DataSource
3+
import androidx.lifecycle.MutableLiveData
4+
import androidx.paging.DataSource
55
import io.reactivex.disposables.CompositeDisposable
66

77
class NewsDataSourceFactory(

app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/NewsListActivity.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.arch.lifecycle.Observer
4-
import android.arch.lifecycle.ViewModelProviders
3+
import androidx.lifecycle.Observer
4+
import androidx.lifecycle.ViewModelProviders
55
import android.os.Bundle
6-
import android.support.v7.app.AppCompatActivity
7-
import android.support.v7.widget.LinearLayoutManager
6+
import androidx.appcompat.app.AppCompatActivity
7+
import androidx.recyclerview.widget.LinearLayoutManager
88
import android.view.View
99
import android.widget.LinearLayout
1010
import kotlinx.android.synthetic.main.activity_news_list.*
@@ -26,7 +26,7 @@ class NewsListActivity : AppCompatActivity() {
2626

2727
private fun initAdapter() {
2828
newsListAdapter = NewsListAdapter { viewModel.retry() }
29-
recycler_view.layoutManager = LinearLayoutManager(this, LinearLayout.VERTICAL, false)
29+
recycler_view.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this, LinearLayout.VERTICAL, false)
3030
recycler_view.adapter = newsListAdapter
3131
viewModel.newsList.observe(this, Observer {
3232
newsListAdapter.submitList(it)

app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/NewsListAdapter.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.arch.paging.PagedListAdapter
4-
import android.support.v7.util.DiffUtil
5-
import android.support.v7.widget.RecyclerView
3+
import androidx.paging.PagedListAdapter
4+
import androidx.recyclerview.widget.DiffUtil
5+
import androidx.recyclerview.widget.RecyclerView
66
import android.view.ViewGroup
77

88
class NewsListAdapter(private val retry: () -> Unit)
9-
: PagedListAdapter<News, RecyclerView.ViewHolder>(NewsDiffCallback) {
9+
: PagedListAdapter<News, androidx.recyclerview.widget.RecyclerView.ViewHolder>(NewsDiffCallback) {
1010

1111
private val DATA_VIEW_TYPE = 1
1212
private val FOOTER_VIEW_TYPE = 2
1313

1414
private var state = State.LOADING
1515

16-
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
16+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder {
1717
return if (viewType == DATA_VIEW_TYPE) NewsViewHolder.create(parent) else ListFooterViewHolder.create(retry, parent)
1818
}
1919

20-
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
20+
override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
2121
if (getItemViewType(position) == DATA_VIEW_TYPE)
2222
(holder as NewsViewHolder).bind(getItem(position))
2323
else (holder as ListFooterViewHolder).bind(state)

app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/NewsListViewModel.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.arch.lifecycle.LiveData
4-
import android.arch.lifecycle.Transformations
5-
import android.arch.lifecycle.ViewModel
6-
import android.arch.paging.LivePagedListBuilder
7-
import android.arch.paging.PagedList
3+
import androidx.lifecycle.LiveData
4+
import androidx.lifecycle.Transformations
5+
import androidx.lifecycle.ViewModel
6+
import androidx.paging.LivePagedListBuilder
7+
import androidx.paging.PagedList
88
import io.reactivex.disposables.CompositeDisposable
99

1010
class NewsListViewModel : ViewModel() {

app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/NewsViewHolder.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide
22

3-
import android.support.v7.widget.RecyclerView
3+
import androidx.recyclerview.widget.RecyclerView
44
import android.view.LayoutInflater
55
import android.view.View
66
import android.view.ViewGroup
77
import com.squareup.picasso.Picasso
88
import kotlinx.android.synthetic.main.item_news.view.*
99

10-
class NewsViewHolder(view: View) : RecyclerView.ViewHolder(view) {
10+
class NewsViewHolder(view: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(view) {
1111

1212
fun bind(news: News?) {
1313
if (news != null) {

app/src/main/res/layout/activity_news_list.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:gravity="center"
1818
android:text="ERROR !! Tap to retry." />
1919

20-
<android.support.v7.widget.RecyclerView
20+
<androidx.recyclerview.widget.RecyclerView
2121
android:id="@+id/recycler_view"
2222
android:layout_width="match_parent"
2323
android:layout_height="wrap_content"

app/src/main/res/layout/item_news.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:card_view="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/card_view"
@@ -33,4 +33,4 @@
3333

3434
</LinearLayout>
3535

36-
</android.support.v7.widget.CardView>
36+
</androidx.cardview.widget.CardView>

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.2.51'
4+
ext.kotlin_version = '1.3.41'
55
repositories {
66
google()
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.1.3'
10+
classpath 'com.android.tools.build:gradle:3.4.2'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
77
# Specifies the JVM arguments used for the daemon process.
88
# The setting is particularly useful for tweaking memory settings.
9+
android.enableJetifier=true
10+
android.useAndroidX=true
911
org.gradle.jvmargs=-Xmx1536m
1012
# When configured, Gradle will run in incubating parallel mode.
1113
# This option should only be used with decoupled projects. More details, visit
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Aug 02 15:05:56 NPT 2018
1+
#Tue Jul 30 14:59:45 NPT 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

0 commit comments

Comments
 (0)