diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/util/Event.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/util/Event.kt deleted file mode 100644 index e9298dfbb..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/util/Event.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.festago.festago.presentation.util - -/** - * Used as a wrapper for data that is exposed via a LiveData that represents an event. - */ -open class Event(private val content: T) { - - var hasBeenHandled = false - private set // Allow external read but not write - - /** - * Returns the content and prevents its use again. - */ - fun getContentIfNotHandled(): T? { - return if (hasBeenHandled) { - null - } else { - hasBeenHandled = true - content - } - } - - /** - * Returns the content, even if it's already been handled. - */ - fun peekContent(): T = content -} diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/util/MutableSingleLiveData.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/util/MutableSingleLiveData.kt deleted file mode 100644 index 68236a79c..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/util/MutableSingleLiveData.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.festago.festago.presentation.util - -class MutableSingleLiveData : SingleLiveData { - - constructor() : super() - - constructor(value: T) : super(value) - - public override fun postValue(value: T) { - super.postValue(value) - } - - public override fun setValue(value: T) { - super.setValue(value) - } -} diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleLiveData.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleLiveData.kt deleted file mode 100644 index 434744392..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleLiveData.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.festago.festago.presentation.util - -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.MutableLiveData - -abstract class SingleLiveData { - - private val liveData = MutableLiveData>() - - protected constructor() - - protected constructor(value: T) { - liveData.value = Event(value) - } - - protected open fun setValue(value: T) { - liveData.value = Event(value) - } - - protected open fun postValue(value: T) { - liveData.postValue(Event(value)) - } - - fun getValue() = liveData.value?.peekContent() - - fun observe(owner: LifecycleOwner, onResult: (T) -> Unit) { - liveData.observe(owner) { it.getContentIfNotHandled()?.let(onResult) } - } - - fun observePeek(owner: LifecycleOwner, onResult: (T) -> Unit) { - liveData.observe(owner) { onResult(it.peekContent()) } - } -}