GalleryDetailViewModel

class GalleryDetailViewModel(val itemId: Long, val dispatchersProvider: DispatchersProvider, val buildInfoProvider: BuildInfoProvider, val getGenerationResultUseCase: GetGenerationResultUseCase, val getAllGalleryUseCase: GetAllGalleryUseCase, val getLastResultFromCacheUseCase: GetLastResultFromCacheUseCase, val deleteGalleryItemUseCase: DeleteGalleryItemUseCase, val toggleImageVisibilityUseCase: ToggleImageVisibilityUseCase, val toggleImageLikeUseCase: ToggleImageLikeUseCase, val generationFormUpdateEvent: GenerationFormUpdateEvent, val router: GalleryDetailRouter, val platformActions: GalleryDetailPlatformActions, val pagerBuffer: Int = GALLERY_DETAIL_PAGER_BUFFER, val onError: (Throwable) -> Unit = {}) : BaseMviViewModel<GalleryDetailState, GalleryDetailIntent, EmptyEffect> (source)

Coordinates GalleryDetailViewModel behavior in the SDAI presentation layer.

Author

Dmitriy Moroz

Constructors

Link copied to clipboard
constructor(itemId: Long, dispatchersProvider: DispatchersProvider, buildInfoProvider: BuildInfoProvider, getGenerationResultUseCase: GetGenerationResultUseCase, getAllGalleryUseCase: GetAllGalleryUseCase, getLastResultFromCacheUseCase: GetLastResultFromCacheUseCase, deleteGalleryItemUseCase: DeleteGalleryItemUseCase, toggleImageVisibilityUseCase: ToggleImageVisibilityUseCase, toggleImageLikeUseCase: ToggleImageLikeUseCase, generationFormUpdateEvent: GenerationFormUpdateEvent, router: GalleryDetailRouter, platformActions: GalleryDetailPlatformActions, pagerBuffer: Int = GALLERY_DETAIL_PAGER_BUFFER, onError: (Throwable) -> Unit = {})

Types

Link copied to clipboard
private data class GalleryDetailPagerWindow(val contents: List<GalleryDetailContent>, val startIndex: Int, val currentIndex: Int)

Properties

Link copied to clipboard
private val _effect: Channel<E>
Link copied to clipboard
private val _state: MutableStateFlow<S>
Link copied to clipboard

Exposes the buildInfoProvider value used by the SDAI presentation layer.

Link copied to clipboard
Link copied to clipboard
private var currentItemId: Long
Link copied to clipboard
Link copied to clipboard

Exposes the deleteGalleryItemUseCase value used by the SDAI presentation layer.

Link copied to clipboard

Exposes the dispatchersProvider value used by the SDAI presentation layer.

Link copied to clipboard
open override val effect: Flow<EmptyEffect>
Link copied to clipboard
private val effectDispatcher: CoroutineDispatcher
Link copied to clipboard
private var galleryItemIds: List<Long>
Link copied to clipboard

Exposes the generationFormUpdateEvent value used by the SDAI presentation layer.

Link copied to clipboard

Exposes the getAllGalleryUseCase value used by the SDAI presentation layer.

Link copied to clipboard

Exposes the getGenerationResultUseCase value used by the SDAI presentation layer.

Link copied to clipboard

Exposes the getLastResultFromCacheUseCase value used by the SDAI presentation layer.

Link copied to clipboard
private val itemId: Long

Exposes the itemId value used by the SDAI presentation layer.

Link copied to clipboard
private val onError: (Throwable) -> Unit

Exposes the onError value used by the SDAI presentation layer.

Link copied to clipboard
private val pagerBuffer: Int

Exposes the pagerBuffer value used by the SDAI presentation layer.

Link copied to clipboard

Exposes the platformActions value used by the SDAI presentation layer.

Link copied to clipboard

Exposes the router value used by the SDAI presentation layer.

Link copied to clipboard
private val safePagerBuffer: Int
Link copied to clipboard
Link copied to clipboard
open override val state: StateFlow<GalleryDetailState>
Link copied to clipboard

Exposes the toggleImageLikeUseCase value used by the SDAI presentation layer.

Link copied to clipboard

Exposes the toggleImageVisibilityUseCase value used by the SDAI presentation layer.

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
Link copied to clipboard
internal expect fun clear()
Link copied to clipboard
private fun copyToClipboard(text: String)
Link copied to clipboard
private fun createPagerWindow(galleryItemIds: List<Long>, itemIndex: Int, content: GalleryDetailContent, decodeMissing: Boolean): GalleryDetailViewModel.GalleryDetailPagerWindow
Link copied to clipboard
private fun delete()
Link copied to clipboard
protected fun emitEffect(effect: EmptyEffect)
Link copied to clipboard
protected fun emitState(state: GalleryDetailState)
Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
private suspend fun getGalleryItemIds(): List<Long>
Link copied to clipboard
private suspend fun getGenerationResult(id: Long): AiGenerationResult
Link copied to clipboard
private fun handleFailure(t: Throwable)
Link copied to clipboard
Link copied to clipboard
protected fun launch(dispatcher: CoroutineDispatcher, start: CoroutineStart, block: suspend CoroutineScope.() -> Unit): Job
Link copied to clipboard
private fun load()
Link copied to clipboard
private fun loadPage(page: Int, id: Long)
Link copied to clipboard
private fun navigateToAdjacent(delta: Int)
Link copied to clipboard
private fun navigateToPage(page: Int)
Link copied to clipboard
protected expect open fun onCleared()
Link copied to clipboard
private fun prefetchPagerWindow(itemIndex: Int)
Link copied to clipboard
open override fun processIntent(intent: GalleryDetailIntent)
Link copied to clipboard
private fun saveImage()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
private fun setCurrentContent(content: GalleryDetailContent, itemIndex: Int, decodeMissing: Boolean)
Link copied to clipboard
private fun setHidden(id: Long, hidden: Boolean)
Link copied to clipboard
private fun setLiked(id: Long, liked: Boolean)
Link copied to clipboard
private fun shareImage()
Link copied to clipboard
private fun shareParams()
Link copied to clipboard
private fun toggleLike()
Link copied to clipboard
private fun toggleVisibility()
Link copied to clipboard
Link copied to clipboard
protected fun updateState(mutation: (GalleryDetailState) -> GalleryDetailState)