Skip to content

Commit

Permalink
migrate to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
JoosungPark committed Nov 8, 2020
1 parent 7e524d5 commit dfc498e
Show file tree
Hide file tree
Showing 39 changed files with 116 additions and 115 deletions.
16 changes: 8 additions & 8 deletions JoosungLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

buildTypes {
Expand All @@ -30,11 +30,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

api "com.android.support:appcompat-v7:$android_support_version"
api "com.android.support:design:$android_support_version"
api 'androidx.appcompat:appcompat:1.0.0'
api 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation "com.android.support.test:runner:$runner_version"
androidTestImplementation("com.android.support.test.espresso:espresso-core:$espresso_core_version", {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand All @@ -46,9 +46,9 @@ dependencies {
api "com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:$rxbinding_version"
api "com.jakewharton.rxbinding2:rxbinding-design-kotlin:$rxbinding_version"
api 'de.hdodenhof:circleimageview:2.2.0'
implementation "android.arch.lifecycle:extensions:$rootProject.lifecycle_version"
kapt "android.arch.lifecycle:compiler:$rootProject.lifecycle_version"
testImplementation "android.arch.core:core-testing:$rootProject.lifecycle_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
testImplementation 'androidx.arch.core:core-testing:2.0.0'

api 'com.github.akarnokd:rxjava2-interop:0.11.0'
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.joosung.library.rx

import android.annotation.SuppressLint
import android.databinding.Observable.OnPropertyChangedCallback
import android.databinding.ObservableField
import androidx.databinding.Observable.OnPropertyChangedCallback
import androidx.databinding.ObservableField
import android.os.Looper
import io.reactivex.*
import io.reactivex.Observable
Expand All @@ -12,12 +12,13 @@ import io.reactivex.disposables.Disposable
import io.reactivex.functions.*
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import androidx.databinding.Observable as AndroidObservable

object RxUtils {
fun <T> toObservable(observableField: ObservableField<T>, initialData: Boolean = true): Observable<T> {
return Flowable.create<T>({ asyncEmitter ->
val callback = object : OnPropertyChangedCallback() {
override fun onPropertyChanged(dataBindingObservable: android.databinding.Observable, propertyId: Int) {
override fun onPropertyChanged(dataBindingObservable: AndroidObservable, propertyId: Int) {
if (dataBindingObservable === observableField) {
observableField.get()?.let {
asyncEmitter.onNext(observableField.get()!!)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.joosung.library.rx

import android.arch.lifecycle.ViewModel
import android.support.annotation.CallSuper
import androidx.annotation.CallSuper
import androidx.lifecycle.ViewModel
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.library.rx

import android.databinding.ObservableField
import androidx.databinding.ObservableField
import io.reactivex.Observable
import io.reactivex.functions.Consumer
import io.reactivex.subjects.BehaviorSubject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package com.joosung.library.vm

import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.MutableLiveData
import android.arch.lifecycle.Observer
import android.support.annotation.MainThread
import android.util.Log
import androidx.annotation.MainThread
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer

import java.util.concurrent.atomic.AtomicBoolean

Expand All @@ -40,14 +40,14 @@ class SingleLiveEvent<T> : MutableLiveData<T>() {
private val pending = AtomicBoolean(false)

@MainThread
override fun observe(owner: LifecycleOwner, observer: Observer<T>) {
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) {

if (hasActiveObservers()) {
Log.w(TAG, "Multiple observers registered but only one will be notified of changes.")
}

// Observe the internal MutableLiveData
super.observe(owner, Observer<T> { t ->
super.observe(owner, { t ->
if (pending.compareAndSet(true, false)) {
observer.onChanged(t)
}
Expand Down
10 changes: 5 additions & 5 deletions RxRecyclerAdapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

buildTypes {
Expand All @@ -30,11 +30,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

api "com.android.support:appcompat-v7:$android_support_version"
api "com.android.support:design:$android_support_version"
api 'androidx.appcompat:appcompat:1.0.0'
api 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation "com.android.support.test:runner:$runner_version"
androidTestImplementation("com.android.support.test.espresso:espresso-core:$espresso_core_version", {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.joosung.rxrecycleradapter

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import io.reactivex.functions.Consumer

class RxRecyclerAdapter<D : RxRecyclerAdapterData> constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.joosung.rxrecycleradapter

import android.databinding.DataBindingUtil
import android.databinding.ViewDataBinding
import android.support.v7.widget.RecyclerView
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import io.reactivex.disposables.CompositeDisposable

/**
Expand Down
20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

dexOptions {
Expand Down Expand Up @@ -73,14 +73,14 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:appcompat-v7:$android_support_version"
implementation "com.android.support:support-v4:$android_support_version"
implementation "com.android.support.constraint:constraint-layout:$constraint_layout_version"
implementation "com.android.support:design:$android_support_version"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'

androidTestImplementation("com.android.support.test.espresso:espresso-core:$espresso_core_version", {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.google.code.gson:gson:2.8.4'
Expand All @@ -102,9 +102,9 @@ dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"

implementation "android.arch.lifecycle:extensions:$rootProject.lifecycle_version"
kapt "android.arch.lifecycle:compiler:$rootProject.lifecycle_version"
testImplementation "android.arch.core:core-testing:$rootProject.lifecycle_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
testImplementation 'androidx.arch.core:core-testing:2.0.0'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'

implementation project(':JoosungLibrary')
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/joosung/pickme/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.pickme

import android.databinding.DataBindingUtil
import androidx.databinding.DataBindingUtil
import android.os.Bundle
import com.joosung.pickme.common.BaseActivity
import com.joosung.pickme.common.FragmentBundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppRealmMigration : RealmMigration {
.setNullable(AppRealmMedia.kStarred, true)

}
version++
version += 1
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.pickme.common

import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import com.joosung.pickme.R
import io.reactivex.disposables.CompositeDisposable
import java.util.ArrayList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.joosung.pickme.common

import android.app.Activity
import android.content.Intent
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import com.joosung.pickme.util.KeyboardUtils
import com.joosung.pickme.R
import io.reactivex.disposables.CompositeDisposable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.joosung.pickme.common

import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.StaggeredGridLayoutManager
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager

// https://gist.github.com/nesquena/d09dc68ff07e845cc622
abstract class EndlessRecyclerViewScrollListener : RecyclerView.OnScrollListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.joosung.pickme.common.adapter

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.joosung.pickme.common.FragmentBundle
import com.joosung.pickme.common.FragmentFactory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.joosung.pickme.common.view

import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager

/**
*
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/joosung/pickme/di/AppModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.pickme.di

import android.databinding.ObservableField
import androidx.databinding.ObservableField
import com.joosung.pickme.ui.home.HomeViewModel
import com.joosung.library.rx.Variable
import com.joosung.pickme.common.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.joosung.pickme.extensions

import android.content.Context
import android.databinding.BindingAdapter
import androidx.databinding.BindingAdapter
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.joosung.pickme.extensions

import android.arch.lifecycle.*
import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.lifecycle.*

inline fun <reified T : ViewModel> AppCompatActivity.withViewModel(
crossinline factory: () -> T,
Expand All @@ -19,7 +19,7 @@ inline fun <reified T : ViewModel> AppCompatActivity.getViewModel(crossinline fa
override fun <U : ViewModel> create(modelClass: Class<U>): U = factory() as U
}

return android.arch.lifecycle.ViewModelProviders.of(this, vmFactory)[T::class.java]
return ViewModelProviders.of(this, vmFactory)[T::class.java]
}

inline fun <reified T : ViewModel> Fragment.withViewModel(crossinline factory: () -> T, body: T.() -> Unit): T {
Expand All @@ -34,9 +34,9 @@ inline fun <reified T : ViewModel> Fragment.getViewModel(crossinline factory: ()
override fun <U : ViewModel> create(modelClass: Class<U>): U = factory() as U
}

return android.arch.lifecycle.ViewModelProviders.of(this, vmFactory)[T::class.java]
return ViewModelProviders.of(this, vmFactory)[T::class.java]
}

fun <T : Any, L : LiveData<T>> LifecycleOwner.observe(liveData: L, body: (T?) -> Unit) {
liveData.observe(this, android.arch.lifecycle.Observer(body))
liveData.observe(this, Observer(body))
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.pickme.http.model

import android.databinding.ObservableField
import androidx.databinding.ObservableField
import com.google.gson.Gson
import com.google.gson.TypeAdapter
import com.google.gson.TypeAdapterFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.joosung.pickme.http.model

import android.databinding.BaseObservable
import android.databinding.ObservableField
import androidx.databinding.BaseObservable
import androidx.databinding.ObservableField
import com.google.gson.annotations.SerializedName
import com.joosung.pickme.common.AppShared
import com.joosung.pickme.model.AppJsonObject
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/joosung/pickme/model/VarDict.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.pickme.model

import android.databinding.ObservableField
import androidx.databinding.ObservableField
import com.joosung.pickme.common.AppShared
import com.joosung.imagelist.util.LogUtil
import com.joosung.imagelist.util.Tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ abstract class BasePreferences(private val context: Context, private val name: S
}

protected fun getValue(key: String, defaultValue: String): String {
var result = defaultValue
val result: String

synchronized(preferences) {
result = preferences.getString(key, defaultValue)
result = preferences.getString(key, defaultValue) ?: defaultValue
}

return result
Expand Down Expand Up @@ -103,10 +103,10 @@ abstract class BasePreferences(private val context: Context, private val name: S
}

protected fun getValue(key: String, defaultValue: MutableSet<String>): MutableSet<String> {
var result = defaultValue
val result: MutableSet<String>

synchronized(preferences) {
result = preferences.getStringSet(key, defaultValue)
result = preferences.getStringSet(key, defaultValue) ?: defaultValue
}

return result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.pickme.ui.home

import android.databinding.DataBindingUtil
import androidx.databinding.DataBindingUtil
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joosung.pickme.ui.home

import android.databinding.ObservableField
import androidx.databinding.ObservableField
import com.joosung.imagelist.util.LogUtil
import com.joosung.library.rx.RxViewModel
import com.joosung.library.vm.SingleLiveEvent
Expand Down
Loading

0 comments on commit dfc498e

Please sign in to comment.