From be6d07edd16c78bcd474426f5440387ac88117bb Mon Sep 17 00:00:00 2001 From: Daniil Shevtsov Date: Tue, 20 Aug 2019 15:36:11 +0300 Subject: [PATCH 1/2] Fix recyclerview-calendar not using rootDir --- modules.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules.gradle b/modules.gradle index 616064a..28a1838 100644 --- a/modules.gradle +++ b/modules.gradle @@ -34,7 +34,7 @@ project(':lifecycle-rx').projectDir = new File(rootDir, 'lifecycle-rx') project(':views').projectDir = new File(rootDir, 'views') project(':recyclerview-adapters').projectDir = new File(rootDir, 'recyclerview-adapters') project(':kotlin-extensions').projectDir = new File(rootDir, 'kotlin-extensions') -project(':recyclerview-calendar').projectDir = new File(gradle.ext.componentsRoot, 'recyclerview-calendar') +project(':recyclerview-calendar').projectDir = new File(rootDir, 'recyclerview-calendar') project(':tabbar-navigation').projectDir = new File(rootDir, 'tabbar-navigation') project(':base-map').projectDir = new File(rootDir, 'base-map') project(':yandex-map').projectDir = new File(rootDir, 'yandex-map') From ffab47c3b987bf12d76063127b9cde60a20b4d5a Mon Sep 17 00:00:00 2001 From: Daniil Shevtsov Date: Tue, 20 Aug 2019 15:42:38 +0300 Subject: [PATCH 2/2] Resolve #57 Add support of SingleLiveEvent --- .../livedata/EmptySingleLiveEvent.kt | 28 +++++++++++++++++++ .../lifecycle/livedata/SingleLiveEvent.kt | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lifecycle/src/main/java/ru/touchin/lifecycle/livedata/EmptySingleLiveEvent.kt diff --git a/lifecycle/src/main/java/ru/touchin/lifecycle/livedata/EmptySingleLiveEvent.kt b/lifecycle/src/main/java/ru/touchin/lifecycle/livedata/EmptySingleLiveEvent.kt new file mode 100644 index 0000000..cd16acf --- /dev/null +++ b/lifecycle/src/main/java/ru/touchin/lifecycle/livedata/EmptySingleLiveEvent.kt @@ -0,0 +1,28 @@ +package ru.touchin.lifecycle.livedata + +import androidx.annotation.MainThread + +/** + * A lifecycle-aware observable that sends only new updates after subscription, used for events like + * navigation and Snackbar messages. + * + * + * This avoids a common problem with events: on configuration change (like rotation) an update + * can be emitted if the observer is active. This LiveData only calls the observable if there's an + * explicit call to setValue() or call(). + * + * + * Note that only one observer is going to be notified of changes. + * + * This version of SingleLiveEvent supports empty events + */ +class EmptySingleLiveEvent : SingleLiveEvent() { + @MainThread + fun call() { + value = null + } + + fun postCall() { + super.postValue(null) + } +} diff --git a/lifecycle/src/main/java/ru/touchin/lifecycle/livedata/SingleLiveEvent.kt b/lifecycle/src/main/java/ru/touchin/lifecycle/livedata/SingleLiveEvent.kt index 073e310..fc13075 100644 --- a/lifecycle/src/main/java/ru/touchin/lifecycle/livedata/SingleLiveEvent.kt +++ b/lifecycle/src/main/java/ru/touchin/lifecycle/livedata/SingleLiveEvent.kt @@ -5,7 +5,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Observer import java.util.concurrent.atomic.AtomicBoolean -class SingleLiveEvent : MutableLiveData() { +open class SingleLiveEvent : MutableLiveData() { private val pending = AtomicBoolean(false)