diff --git a/app/build.gradle b/app/build.gradle
index a339499..74677df 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.2"
+ compileSdkVersion 28
+ //buildToolsVersion "26.0.2"
defaultConfig {
applicationId "ds.bindingtools.demo"
minSdkVersion 19
- targetSdkVersion 26
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -24,8 +24,8 @@ android {
dependencies {
implementation project(path: ':lib')
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
- implementation 'com.android.support:appcompat-v7:26.1.0'
- implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation("androidx.appcompat:appcompat:1.1.0")
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
}
diff --git a/app/src/main/java/ds/bindingtools/demo/MainActivity.kt b/app/src/main/java/ds/bindingtools/demo/MainActivity.kt
index af9bf1f..0d55197 100644
--- a/app/src/main/java/ds/bindingtools/demo/MainActivity.kt
+++ b/app/src/main/java/ds/bindingtools/demo/MainActivity.kt
@@ -1,8 +1,9 @@
package ds.bindingtools.demo
+import android.content.Context
import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
import ds.bindingtools.bundle
import ds.bindingtools.startActivity
import ds.bindingtools.withBindable
@@ -55,10 +56,10 @@ class MainActivity : AppCompatActivity() {
private fun bindViews() = withBindable(viewModel) {
bind(::text, helloLabel::setText, helloLabel::getText)
- bind(::buttonText, { it: String -> navigateButton.text = it }, { navigateButton.text.toString() })
+ bind(::buttonText, { navigateButton.text = it }, { navigateButton.text.toString() })
withBindable(nestedViewModel) {
- bind(::secondaryText, { Toast.makeText(this@MainActivity, it, Toast.LENGTH_SHORT).show() })
+ bind(::secondaryText, { text -> Toast.makeText(this@MainActivity, text, Toast.LENGTH_SHORT).show() })
}
}
diff --git a/app/src/main/java/ds/bindingtools/demo/SecondActivity.kt b/app/src/main/java/ds/bindingtools/demo/SecondActivity.kt
index 5a5bc45..a7d08b4 100644
--- a/app/src/main/java/ds/bindingtools/demo/SecondActivity.kt
+++ b/app/src/main/java/ds/bindingtools/demo/SecondActivity.kt
@@ -1,7 +1,7 @@
package ds.bindingtools.demo
import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
+import androidx.appcompat.app.AppCompatActivity
import ds.bindingtools.arg
import ds.bindingtools.res
diff --git a/app/src/main/res/layout/activity_second.xml b/app/src/main/res/layout/activity_second.xml
index b2b3aca..326d52d 100644
--- a/app/src/main/res/layout/activity_second.xml
+++ b/app/src/main/res/layout/activity_second.xml
@@ -1,5 +1,5 @@
-
-
+
diff --git a/build.gradle b/build.gradle
index 2b0a7fb..21d019a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,11 +1,11 @@
buildscript {
- ext.kotlin_version = '1.2.10'
+ ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.1'
+ classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' // for jitpack
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 6087331..a306d69 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-4.4-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
diff --git a/lib/build.gradle b/lib/build.gradle
index fded1fc..cf90be1 100644
--- a/lib/build.gradle
+++ b/lib/build.gradle
@@ -5,14 +5,14 @@ apply plugin: 'com.github.dcendents.android-maven'
group='com.github.deviant-studio'
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.2"
+ compileSdkVersion 28
+ //buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 19
- targetSdkVersion 26
+ targetSdkVersion 28
versionCode 15
- versionName "0.15"
+ versionName "0.16"
}
@@ -28,11 +28,16 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
- implementation 'com.android.support:appcompat-v7:26.1.0'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation("androidx.appcompat:appcompat:1.1.0")
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+
+ def lifecycle_version = "2.2.0"
+ def arch_version = "2.1.0"
+ implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
+
}
// build a jar with source files
diff --git a/lib/src/main/java/ds/bindingtools/ArgsBindings.kt b/lib/src/main/java/ds/bindingtools/ArgsBindings.kt
index f28ef65..c4ea1fa 100644
--- a/lib/src/main/java/ds/bindingtools/ArgsBindings.kt
+++ b/lib/src/main/java/ds/bindingtools/ArgsBindings.kt
@@ -5,9 +5,9 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Parcelable
-import android.support.annotation.IdRes
-import android.support.v4.app.Fragment
-import android.support.v4.app.FragmentActivity
+import androidx.annotation.IdRes
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentActivity
import java.io.Serializable
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KClass
@@ -52,7 +52,9 @@ inline fun Activity.startActivityForResult(requestCode: I
}
inline fun FragmentActivity.replaceFragment(@IdRes layoutId: Int, args: Bundle? = null) {
- val fragment = Fragment.instantiate(this, T::class.java.name, args)
+ val fragment = supportFragmentManager.fragmentFactory.instantiate(classLoader, T::class.java.name)
+ fragment.arguments = args
+ //val fragment = Fragment.instantiate(this, T::class.java.name, args)
supportFragmentManager
.beginTransaction()
.replace(layoutId, fragment)
@@ -60,7 +62,8 @@ inline fun FragmentActivity.replaceFragment(@IdRes layout
}
inline fun FragmentActivity.replaceFragment(@IdRes layoutId: Int, f: BundleBuilder.(T) -> Unit) {
- val fragment = Fragment.instantiate(this, T::class.java.name) as T
+ val fragment = supportFragmentManager.fragmentFactory.instantiate(classLoader, T::class.java.name) as T
+ //val fragment = Fragment.instantiate(this, T::class.java.name) as T
val builder = BundleBuilder()
f(builder, fragment)
fragment.arguments = builder.build()
@@ -74,22 +77,21 @@ inline fun FragmentActivity.replaceFragment(@IdRes layout
@Suppress("unchecked_cast")
class ActivityArgsDelegate(private val default: T, private val cls: KClass<*>) : ReadOnlyProperty {
- override fun getValue(thisRef: Activity, property: KProperty<*>): T {
- if (thisRef.intent?.extras == null)
- return default
+ override fun getValue(thisRef: Activity, property: KProperty<*>): T = thisRef
+ .intent
+ ?.extras
+ ?.let { extras -> parseExtras(property.name, extras, cls, default) }
+ ?: default
- return parseExtras(property.name, thisRef.intent.extras, cls, default)
- }
}
class FragmentArgsDelegate(private val default: T, private val cls: KClass<*>) : ReadOnlyProperty {
- override fun getValue(thisRef: Fragment, property: KProperty<*>): T {
- if (thisRef.arguments == null)
- return default
+ override fun getValue(thisRef: Fragment, property: KProperty<*>): T = thisRef
+ .arguments
+ ?.let { args -> parseExtras(property.name, args, cls, default) }
+ ?: default
- return parseExtras(property.name, thisRef.arguments, cls, default)
- }
}
@Suppress("unchecked_cast")
diff --git a/lib/src/main/java/ds/bindingtools/ResBindings.kt b/lib/src/main/java/ds/bindingtools/ResBindings.kt
index 4fb8227..276c6bd 100644
--- a/lib/src/main/java/ds/bindingtools/ResBindings.kt
+++ b/lib/src/main/java/ds/bindingtools/ResBindings.kt
@@ -4,15 +4,15 @@ import android.app.Activity
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
-import android.support.annotation.AnyRes
-import android.support.v4.app.Fragment
-import android.support.v4.content.ContextCompat
+import androidx.annotation.AnyRes
+import androidx.core.content.ContextCompat
+import androidx.fragment.app.Fragment
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KClass
import kotlin.reflect.KProperty
inline fun Context.res(@AnyRes id: Int): ReadOnlyProperty = ResourcesDelegate(this, id, T::class)
-inline fun Fragment.res(@AnyRes id: Int): ReadOnlyProperty = ResourcesDelegate(this.context, id, T::class)
+inline fun Fragment.res(@AnyRes id: Int): ReadOnlyProperty = ResourcesDelegate(this.context!!, id, T::class)
class ResourcesDelegate(private val context: Context, private val id: Int, private val cls: KClass) : ReadOnlyProperty {
private lateinit var type: String
diff --git a/lib/src/main/java/ds/bindingtools/ViewBindings.kt b/lib/src/main/java/ds/bindingtools/ViewBindings.kt
index 3e67bdd..999c26e 100644
--- a/lib/src/main/java/ds/bindingtools/ViewBindings.kt
+++ b/lib/src/main/java/ds/bindingtools/ViewBindings.kt
@@ -3,11 +3,11 @@
*/
package ds.bindingtools
-import android.arch.lifecycle.Lifecycle
-import android.arch.lifecycle.LifecycleOwner
import android.util.Log
import android.widget.CompoundButton
import android.widget.TextView
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleOwner
import java.lang.ref.WeakReference
import java.util.*
import kotlin.properties.ReadWriteProperty