Improving build speed

This commit is contained in:
2021-10-28 01:05:38 +02:00
parent 0fef475482
commit 4f76b20937
22 changed files with 113 additions and 36 deletions
+2
View File
@@ -31,6 +31,8 @@ android {
dependencies {
api(project(":i18n"))
api("org.reduxkotlin:redux-kotlin-threadsafe:0.5.5")
implementation(Libs.core_ktx)
api(Libs.androidx_lifecycle_viewmodel_ktx)
@@ -54,7 +54,7 @@ private fun Context.shareFile(filePath: String) {
)
val shareIntent = ShareCompat.IntentBuilder(this)
.setChooserTitle(getString(R.string.txt_share_lottie_file))
.setChooserTitle(getString(org.zxconnect.android.beserve.i18n.R.string.txt_share_lottie_file))
.setStream(fileUri)
.setType("application/pdf")
.createChooserIntent()
@@ -4,8 +4,11 @@ import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.reduxkotlin.Reducer
import org.reduxkotlin.Store
import org.reduxkotlin.createThreadSafeStore
abstract class BaseViewModel<S : MavericksState, A>(
abstract class BViewModel<S : MavericksState, A>(
initialState: S
) : MavericksViewModel<S>(initialState) {
protected val pendingAction = MutableSharedFlow<A>()
@@ -0,0 +1,6 @@
package com.ericampire.android.androidstudycase.util.mvi.core
/**
*
*/
interface Action
@@ -0,0 +1,14 @@
package com.ericampire.android.androidstudycase.util.mvi.core
interface Reducer<S: State, A: Action> {
/**
* Given a [currentState] and some [action] that user took, produce a new [State].
*
* This will give us and predictable state management, that ensures each state is associated
* with some specific user intent or action
*/
fun reduce(currentState: S, action: A): S
}
@@ -0,0 +1,6 @@
package com.ericampire.android.androidstudycase.util.mvi.core
/**
*
*/
interface State
@@ -0,0 +1,25 @@
package com.ericampire.android.androidstudycase.util.mvi.core
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
/**
* A [Store] is our state container for a given screen
*
* @param[initialState] this is the initial state of the screen when it is first creates
* @param[reducer] A system for taking in the current state, and a new action, and outputting the
* updated state
*/
abstract class Store<S: State, A: Action>(
initialState: S,
private val reducer: Reducer<S, A>
) {
private val _state = MutableStateFlow(initialState)
val state: StateFlow<S> = _state
fun dispatch(action: A) {
val currentState = _state.value
_state.value = reducer.reduce(currentState, action)
}
}