diff --git a/build.gradle b/build.gradle index ae2c936..15e49ff 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ buildscript { plugins { id 'maven-publish' + id 'org.jetbrains.kotlin.jvm' version '1.6.20' apply false } allprojects { diff --git a/settings.gradle b/settings.gradle index b34b56a..85bd304 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,3 +2,4 @@ include ':sample' include ':vbpd:vbpd-full' include ':vbpd:vbpd-noreflection' rootProject.name = "View Binding Delegate" +include ':vbpd:vbpd-core' diff --git a/vbpd/vbpd-core/.gitignore b/vbpd/vbpd-core/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/vbpd/vbpd-core/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/vbpd/vbpd-core/build.gradle b/vbpd/vbpd-core/build.gradle new file mode 100644 index 0000000..223e870 --- /dev/null +++ b/vbpd/vbpd-core/build.gradle @@ -0,0 +1,38 @@ +plugins { + id 'com.android.library' + id 'kotlin-android' +} + +ext { + groupId = 'com.github.kirich1409' + artifactId = "viewbindingpropertydelegate-core" +} + +apply from: rootProject.file('publishing.gradle') + +android { + compileSdkVersion rootProject.ext.compileSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion + + defaultConfig { + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // For Kotlin projects + kotlinOptions { + jvmTarget = "1.8" + kotlinOptions.freeCompilerArgs += + ['-module-name', "com.github.kirich1409.ViewBindingPropertyDelegate.core"] + } +} + +dependencies { + compileOnly rootProject.ext.dependencies.viewBinding + implementation rootProject.ext.dependencies.lifecycleCommonJava8 +} diff --git a/vbpd/vbpd-core/src/main/AndroidManifest.xml b/vbpd/vbpd-core/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8498b30 --- /dev/null +++ b/vbpd/vbpd-core/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/vbpd/vbpd-noreflection/src/main/java/by/kirich1409/viewbindingdelegate/ViewBindingProperty.kt b/vbpd/vbpd-core/src/main/kotlin/by/kirich1409/viewbindingdelegate/ViewBindingProperty.kt similarity index 97% rename from vbpd/vbpd-noreflection/src/main/java/by/kirich1409/viewbindingdelegate/ViewBindingProperty.kt rename to vbpd/vbpd-core/src/main/kotlin/by/kirich1409/viewbindingdelegate/ViewBindingProperty.kt index f38a2be..6f838f1 100644 --- a/vbpd/vbpd-noreflection/src/main/java/by/kirich1409/viewbindingdelegate/ViewBindingProperty.kt +++ b/vbpd/vbpd-core/src/main/kotlin/by/kirich1409/viewbindingdelegate/ViewBindingProperty.kt @@ -13,7 +13,7 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.viewbinding.ViewBinding -import by.kirich1409.viewbindingdelegate.internal.checkMainThread +import by.kirich1409.viewbindingdelegate.internal.core.checkMainThread import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty @@ -133,7 +133,8 @@ public abstract class LifecycleViewBindingProperty Unit = { _ -> } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun emptyVbCallback():(T) -> Unit { return EMPTY_VB_CALLBACK -} - -internal fun checkMainThread() { - check(Looper.getMainLooper() === Looper.myLooper()) { - "The method must be called on the main thread" - } -} - -internal fun checkMainThread(reason: String) { - check(Looper.getMainLooper() === Looper.myLooper()) { - "The method must be called on the main thread. Reason: $reason." - } } \ No newline at end of file