Skip to content

Commit

Permalink
Extract core artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
kirich1409 committed May 28, 2022
1 parent 599eb89 commit 3a5757c
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 14 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ buildscript {

plugins {
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.6.20' apply false
}

allprojects {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ include ':sample'
include ':vbpd:vbpd-full'
include ':vbpd:vbpd-noreflection'
rootProject.name = "View Binding Delegate"
include ':vbpd:vbpd-core'
1 change: 1 addition & 0 deletions vbpd/vbpd-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions vbpd/vbpd-core/build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions vbpd/vbpd-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="by.kirich1409.viewbindingdelegate.core" />
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -133,7 +133,8 @@ public abstract class LifecycleViewBindingProperty<in R : Any, out T : ViewBindi
}
}

internal fun postClear() {
@RestrictTo(LIBRARY_GROUP)
protected fun postClear() {
if (!mainHandler.post { clear() }) {
clear()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package by.kirich1409.viewbindingdelegate.internal.core

import android.os.Looper

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."
}
}
1 change: 1 addition & 0 deletions vbpd/vbpd-noreflection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ dependencies {
compileOnly rootProject.ext.dependencies.viewBinding
implementation rootProject.ext.dependencies.lifecycleCommonJava8
implementation rootProject.ext.dependencies.recyclerview
api project(':vbpd:vbpd-core')
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,4 @@ internal val EMPTY_VB_CALLBACK: (ViewBinding) -> Unit = { _ -> }
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun <T : ViewBinding> 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."
}
}

0 comments on commit 3a5757c

Please sign in to comment.