SecondViewModel

The MVVM androidx.lifecycle.ViewModel for the second screen in the MVVM with Process Death demo. Loads the image either from the com.grarcht.shuttle.framework.Shuttle warehouse or from the in-memory com.grarcht.shuttle.demo.processdeath.model.ImageCache, and exposes the result as a StateFlow of SecondImageState.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
fun currentImageModel(): ImageModel?

Returns the com.grarcht.shuttle.demo.core.image.ImageModel from the current SecondImageState.Success state, or null if the image has not been loaded successfully.

Link copied to clipboard
Link copied to clipboard

Loads the image from the in-memory com.grarcht.shuttle.demo.processdeath.model.ImageCache and updates imageState. Transitions to SecondImageState.LostToProcessDeath if the cache is empty, demonstrating that in-memory state does not survive process death.

Link copied to clipboard
fun loadFromShuttle(shuttle: Shuttle, cargoId: String)

Picks up cargo from the com.grarcht.shuttle.framework.Shuttle warehouse using cargoId and updates imageState with the result. Transitions to SecondImageState.LostToProcessDeath immediately when cargoId is empty, indicating that the cargo was not preserved.