Skip to content

Commit

Permalink
Migrate to AndroidX, update dependencies, convert few classes to objects
Browse files Browse the repository at this point in the history
  • Loading branch information
creati8e committed Sep 26, 2018
1 parent 594bd8f commit 49f306e
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 42 deletions.
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ allprojects {
}
project.ext {
libraryVersion = '1.3.0'
supportVersion = '27.1.1'
}
}
subprojects {

afterEvaluate {

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.2'

defaultConfig {
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 28
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
Expand Down
4 changes: 2 additions & 2 deletions multiviewadapter-kt-extensions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ androidExtensions {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:recyclerview-v7:$supportVersion"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation project(path: ':multiviewadapter')
}
4 changes: 2 additions & 2 deletions multiviewadapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ apply from: '../bintray/bintray.gradle'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:recyclerview-v7:$supportVersion"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package serg.chuprin.adapter

import android.support.v7.recyclerview.extensions.AsyncDifferConfig
import android.support.v7.recyclerview.extensions.AsyncListDiffer
import android.support.v7.util.AdapterListUpdateCallback
import android.support.v7.util.DiffUtil
import androidx.recyclerview.widget.AdapterListUpdateCallback
import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import serg.chuprin.adapter.base.AbsMultiViewAdapter

@Suppress("unused")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package serg.chuprin.adapter

import android.support.v4.util.SparseArrayCompat
import androidx.collection.SparseArrayCompat

@Suppress("UNCHECKED_CAST")
class RendererDelegate<T : Any> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package serg.chuprin.adapter

import android.support.v7.widget.RecyclerView
import android.view.View
import androidx.recyclerview.widget.RecyclerView

typealias Click = ViewHolder.ClickCallback
typealias LongClick = ViewHolder.LongClickCallback
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package serg.chuprin.adapter

import android.support.annotation.LayoutRes
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes

@Suppress("UNCHECKED_CAST")
abstract class ViewRenderer<in M : Any, VH : ViewHolder> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package serg.chuprin.adapter.base

import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import serg.chuprin.adapter.R
import serg.chuprin.adapter.RendererDelegate
import serg.chuprin.adapter.ViewHolder
import serg.chuprin.adapter.ViewRenderer

@Suppress("unused", "MemberVisibilityCanBePrivate")
abstract class AbsMultiViewAdapter<T : Any> : RecyclerView.Adapter<ViewHolder>(),
abstract class AbsMultiViewAdapter<T : Any> :
RecyclerView.Adapter<ViewHolder>(),
ViewHolder.ClickCallback,
ViewHolder.LongClickCallback {

Expand Down
10 changes: 5 additions & 5 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ androidExtensions {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:recyclerview-v7:$supportVersion"
implementation "io.reactivex.rxjava2:rxjava:2.1.10"
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation "io.reactivex.rxjava2:rxjava:2.2.0"
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-recyclerview-v7-kotlin:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-recyclerview-v7-kotlin:2.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation project(path: ':multiviewadapter')
implementation project(path: ':multiviewadapter-kt-extensions')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package serg.chuprin.multiviewadapter.diff

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.util.DiffUtil
import android.support.v7.widget.LinearLayoutManager
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
import io.reactivex.Single
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.activity_diff.*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package serg.chuprin.multiviewadapter.view

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.jakewharton.rxbinding2.support.v7.widget.RecyclerViewScrollEvent
import com.jakewharton.rxbinding2.support.v7.widget.RxRecyclerView
import io.reactivex.Observable
Expand Down Expand Up @@ -61,7 +61,8 @@ fun RecyclerView.paginate(): Observable<ScrollEvent> {
.startWith(RecyclerViewScrollEvent.create(this, 0, 0))
.distinctUntilChanged { t1, t2 -> t1.dy() == t2.dy() }
.map {
val pos = (layoutManager as LinearLayoutManager).findLastVisibleItemPosition()
val pos =
(layoutManager as androidx.recyclerview.widget.LinearLayoutManager).findLastVisibleItemPosition()
ScrollEvent(pos, adapter?.itemCount ?: 0)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package serg.chuprin.multiviewadapter.view.adapter

class NetworkErrorModel
object NetworkErrorModel
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ class PaginationAdapter : MultiViewAdapter() {

fun setLoadingMoreVisibility(visible: Boolean) {
return when (visible) {
true -> addItemIfNotPresent(ProgressModel())
true -> addItemIfNotPresent(ProgressModel)
false -> removeLast(ProgressModel::class.java)
}
}

fun setNetworkErrorVisibility(visible: Boolean) {
return when (visible) {
true -> addItemIfNotPresent(NetworkErrorModel())
true -> addItemIfNotPresent(NetworkErrorModel)
false -> removeLast(NetworkErrorModel::class.java)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package serg.chuprin.multiviewadapter.view.adapter

class ProgressModel
object ProgressModel
2 changes: 1 addition & 1 deletion sample/src/main/res/layout/activity_diff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:textColor="?colorAccent" />
</LinearLayout>

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context="serg.chuprin.multiviewadapter.view.MainActivity">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Expand Down

0 comments on commit 49f306e

Please sign in to comment.