Logical state | Ui-State | Gesture/Event | Next state | Output |
---|---|---|---|---|
ItemList | ItemList | Back | Terminated | Finishes activity |
ItemClicked | Loading | Loads requested item | ||
Loading | Loading | Back | Item list | Cancels load and returns to list |
onContent | Content | Displays loaded item | ||
onError | Error | Displays load error | ||
Content | Item | Back | Item list | Returns to the item list |
Error | Error | Back | Item list | Returns to the item list |
Retry | Loading | Retries load operation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val db = Room | |
.databaseBuilder(getApplication(), CitiesDb::class.java, "cities.db") | |
.createFromAsset("databases/cities.db") | |
.fallbackToDestructiveMigration() // On version update - just copy over | |
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseActivity: AppCompatActivity(), AppUpdateView { | |
companion object { | |
/** | |
* Request code for ready dialog | |
*/ | |
val REQUEST_CODE_UPDATE = REQUEST_ID_GENERATOR.requestId() | |
/** | |
* Request code for ready dialog | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RxTest { | |
@Test | |
fun throwsAnError() { | |
val source = Observable.create<Int> { emitter -> | |
emitter.onNext(1) | |
throw RuntimeException() | |
} | |
source.test() | |
.assertValue(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Application update manager | |
*/ | |
@Provides | |
@Singleton | |
fun updateManager(context: Context): AppUpdateManager = AppUpdateManagerFactory.create(context) | |
/** | |
* Update wrapper factory | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks if user has already refused to install update and terminates update flow | |
*/ | |
interface UpdateFlowBreaker: TimeCancelledStorage { | |
/** | |
* Checks if enough time has passed since user had explicitly cancelled update | |
*/ | |
fun isEnoughTimePassedSinceLatestCancel(): Boolean | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
defaultConfig { | |
javaCompileOptions { | |
annotationProcessorOptions { | |
arguments += [ | |
"room.schemaLocation": "$projectDir/schemas".toString() | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class CoroutineState<G: Any, U: Any>: CommonMachineState<G, U>() { | |
protected val stateScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate) | |
override fun doClear() { | |
stateScope.cancel() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Common state machine | |
* @param G UI gesture | |
* @param U UI state | |
*/ | |
interface CommonStateMachine<G: Any, U: Any> : MachineInput<G>, MachineOutput<G, U> { | |
/** | |
* Base state-machine implementation | |
* @param init Initial state producer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class LceGesture { | |
/** | |
* Item to load clicked | |
* @property id Item ID to load | |
*/ | |
data class ItemClicked(val id: ItemId) : LceGesture() | |
/** | |
* Retry operation clicked | |
*/ |