Skip to content

Commit

Permalink
Merge pull request #14 from wada811/release/5.0.1
Browse files Browse the repository at this point in the history
Release 5.0.1
  • Loading branch information
wada811 committed Mar 7, 2021
2 parents ecb5a09 + 6a050b5 commit 2ed76bd
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.FragmentActivity

fun <T : ViewDataBinding> FragmentActivity.dataBinding(): Lazy<T> = object : Lazy<T> {
private var binding: T? = null
override fun isInitialized(): Boolean = binding != null
override val value: T
get() = binding ?: bind<T>(getContentView()).also {
it.lifecycleOwner = this@dataBinding
binding = it
}

private fun FragmentActivity.getContentView(): View {
return checkNotNull(findViewById<ViewGroup>(android.R.id.content).getChildAt(0)) {
"Call setContentView or Use Activity's secondary constructor passing layout res id."
}
fun <T : ViewDataBinding> FragmentActivity.dataBinding(): Lazy<T> = lazy(LazyThreadSafetyMode.NONE) {
bind<T>(getContentView()).also {
it.lifecycleOwner = this@dataBinding
}
}

private fun <T : ViewDataBinding> bind(view: View): T = DataBindingUtil.bind(view)!!
private fun <T : ViewDataBinding> bind(view: View): T = DataBindingUtil.bind(view)!!
private fun FragmentActivity.getContentView(): View {
return checkNotNull(findViewById<ViewGroup>(android.R.id.content).getChildAt(0)) {
"Call setContentView or Use Activity's secondary constructor passing layout res id."
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.4.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Apr 25 16:47:20 JST 2020
#Sat Feb 27 23:00:16 JST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
32 changes: 17 additions & 15 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,28 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation project(':DataBinding-ktx')
implementation 'com.squareup.leakcanary:leakcanary-android:2.2'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-release:2.6'


// Core library
androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test:core:1.3.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.ext:truth:1.2.0'
androidTestImplementation 'com.google.truth:truth:1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.ext:truth:1.3.0'
androidTestImplementation 'com.google.truth:truth:1.0.1'
// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.3.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.3.0'
// LeakCanary
androidTestImplementation "com.squareup.leakcanary:leakcanary-android-instrumentation:2.2"
androidTestImplementation "com.squareup.leakcanary:leakcanary-android-instrumentation:2.6"
}

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions sample/src/main/res/layout/view_stub.xml

This file was deleted.

0 comments on commit 2ed76bd

Please sign in to comment.