update PsychomatrixCeilDescriptionRepositoryImpl

This commit is contained in:
InsanusMokrassar 2018-09-14 16:17:42 +08:00
parent a21003fa78
commit c6df4dae25

View File

@ -2,19 +2,34 @@ package com.github.insanusmokrassar.PsychomatrixBase.data.repository.realisation
import com.github.insanusmokrassar.PsychomatrixBase.data.repository.PsychomatrixCeilDescriptionRepository import com.github.insanusmokrassar.PsychomatrixBase.data.repository.PsychomatrixCeilDescriptionRepository
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CeilDescriptionUseCase import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CeilDescriptionUseCase
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models.CeilsDescriptionsRoot
import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.resolveCeilsDescriptionsByLanguage
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribe import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribe
abstract class PsychomatrixCeilDescriptionRepositoryImpl( const val CEILS_DESCRIPTION_ENGLISH="en_US"
ceilDescriptionUseCase: CeilDescriptionUseCase
class PsychomatrixCeilDescriptionRepositoryImpl(
ceilDescriptionUseCase: CeilDescriptionUseCase,
language: String = CEILS_DESCRIPTION_ENGLISH
) : PsychomatrixCeilDescriptionRepository { ) : PsychomatrixCeilDescriptionRepository {
private val ceilsDescriptionsRoot: CeilsDescriptionsRoot = resolveCeilsDescriptionsByLanguage(language)
init { init {
ceilDescriptionUseCase.openCeilDescriptionRequestedSubscription().subscribe { ceilDescriptionUseCase.openCeilDescriptionRequestedSubscription().subscribe {
getCeilDescription(it).also { getCeilDescription(it).also {
description -> description ->
ceilDescriptionUseCase.descriptionReady( ceilDescriptionUseCase.descriptionReady(
it, description it,
description
) )
} }
} }
} }
override fun getCeilDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo): CeilDescription {
return ceilsDescriptionsRoot.resolveCeilDescription(psychomatrixCeilInfo)
}
} }