Skip to content

Commit 2ed76bd

Browse files
authored
Merge pull request #14 from wada811/release/5.0.1
Release 5.0.1
2 parents ecb5a09 + 6a050b5 commit 2ed76bd

File tree

7 files changed

+31
-113
lines changed

7 files changed

+31
-113
lines changed

DataBinding-ktx/src/main/java/com/wada811/databinding/ActivityDataBinding.kt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@ import androidx.databinding.DataBindingUtil
88
import androidx.databinding.ViewDataBinding
99
import androidx.fragment.app.FragmentActivity
1010

11-
fun <T : ViewDataBinding> FragmentActivity.dataBinding(): Lazy<T> = object : Lazy<T> {
12-
private var binding: T? = null
13-
override fun isInitialized(): Boolean = binding != null
14-
override val value: T
15-
get() = binding ?: bind<T>(getContentView()).also {
16-
it.lifecycleOwner = this@dataBinding
17-
binding = it
18-
}
19-
20-
private fun FragmentActivity.getContentView(): View {
21-
return checkNotNull(findViewById<ViewGroup>(android.R.id.content).getChildAt(0)) {
22-
"Call setContentView or Use Activity's secondary constructor passing layout res id."
23-
}
11+
fun <T : ViewDataBinding> FragmentActivity.dataBinding(): Lazy<T> = lazy(LazyThreadSafetyMode.NONE) {
12+
bind<T>(getContentView()).also {
13+
it.lifecycleOwner = this@dataBinding
2414
}
15+
}
2516

26-
private fun <T : ViewDataBinding> bind(view: View): T = DataBindingUtil.bind(view)!!
17+
private fun <T : ViewDataBinding> bind(view: View): T = DataBindingUtil.bind(view)!!
18+
private fun FragmentActivity.getContentView(): View {
19+
return checkNotNull(findViewById<ViewGroup>(android.R.id.content).getChildAt(0)) {
20+
"Call setContentView or Use Activity's secondary constructor passing layout res id."
21+
}
2722
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.72'
2+
ext.kotlin_version = '1.4.31'
33
repositories {
44
google()
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.0.1'
8+
classpath 'com.android.tools.build:gradle:4.1.2'
99
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1010
}
1111
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Apr 25 16:47:20 JST 2020
1+
#Sat Feb 27 23:00:16 JST 2021
22
distributionBase=GRADLE_USER_HOME
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
34
distributionPath=wrapper/dists
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
6+
zipStoreBase=GRADLE_USER_HOME

sample/build.gradle

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,28 @@ android {
3131

3232
dependencies {
3333
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34-
implementation 'androidx.appcompat:appcompat:1.1.0'
34+
implementation 'androidx.appcompat:appcompat:1.2.0'
3535
implementation project(':DataBinding-ktx')
36-
implementation 'com.squareup.leakcanary:leakcanary-android:2.2'
36+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
37+
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-release:2.6'
38+
3739

3840
// Core library
39-
androidTestImplementation 'androidx.test:core:1.2.0'
41+
androidTestImplementation 'androidx.test:core:1.3.0'
4042
// AndroidJUnitRunner and JUnit Rules
41-
androidTestImplementation 'androidx.test:runner:1.2.0'
42-
androidTestImplementation 'androidx.test:rules:1.2.0'
43+
androidTestImplementation 'androidx.test:runner:1.3.0'
44+
androidTestImplementation 'androidx.test:rules:1.3.0'
4345
// Assertions
44-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
45-
androidTestImplementation 'androidx.test.ext:truth:1.2.0'
46-
androidTestImplementation 'com.google.truth:truth:1.0'
46+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
47+
androidTestImplementation 'androidx.test.ext:truth:1.3.0'
48+
androidTestImplementation 'com.google.truth:truth:1.0.1'
4749
// Espresso dependencies
48-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
49-
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
50-
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
51-
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.2.0'
52-
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
53-
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.2.0'
50+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
51+
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
52+
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
53+
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.3.0'
54+
androidTestImplementation 'androidx.test.espresso:espresso-web:3.3.0'
55+
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.3.0'
5456
// LeakCanary
55-
androidTestImplementation "com.squareup.leakcanary:leakcanary-android-instrumentation:2.2"
57+
androidTestImplementation "com.squareup.leakcanary:leakcanary-android-instrumentation:2.6"
5658
}

sample/src/main/java/com/wada811/databindingktx/viewbinding/ViewBindingActivity.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

sample/src/main/java/com/wada811/databindingktx/viewbinding/ViewBindingFragment.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.

sample/src/main/res/layout/view_stub.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)