much renames

This commit is contained in:
InsanusMokrassar 2018-09-15 14:09:31 +08:00
parent a9b370d3bf
commit 4fc2e39451
13 changed files with 60 additions and 60 deletions

View File

@ -1,8 +1,8 @@
package com.github.insanusmokrassar.PsychomatrixBase.data.repository package com.github.insanusmokrassar.PsychomatrixBase.data.repository
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
interface PsychomatrixCeilDescriptionRepository { interface PsychomatrixCeilDescriptionRepository {
fun getCeilDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo): CeilDescription fun getCeilDescription(ceilState: CeilState): CeilInfo
} }

View File

@ -2,9 +2,9 @@ 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.CeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models.CeilsDescriptionsRoot import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models.CeilsInfosRoot
import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.resolveCeilsDescriptionsByLanguage import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.resolveCeilsDescriptionsByLanguage
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribe import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribe
@ -15,7 +15,7 @@ class PsychomatrixCeilDescriptionRepositoryImpl(
language: String = CEILS_DESCRIPTION_ENGLISH language: String = CEILS_DESCRIPTION_ENGLISH
) : PsychomatrixCeilDescriptionRepository { ) : PsychomatrixCeilDescriptionRepository {
private val ceilsDescriptionsRoot: CeilsDescriptionsRoot = resolveCeilsDescriptionsByLanguage(language) private val ceilsInfosRoot: CeilsInfosRoot = resolveCeilsDescriptionsByLanguage(language)
init { init {
ceilDescriptionUseCase.openCeilDescriptionRequestedSubscription().subscribe { ceilDescriptionUseCase.openCeilDescriptionRequestedSubscription().subscribe {
@ -29,7 +29,7 @@ class PsychomatrixCeilDescriptionRepositoryImpl(
} }
} }
override fun getCeilDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo): CeilDescription { override fun getCeilDescription(ceilState: CeilState): CeilInfo {
return ceilsDescriptionsRoot.resolveCeilDescription(psychomatrixCeilInfo) return ceilsInfosRoot.resolveCeilDescription(ceilState)
} }
} }

View File

@ -1,17 +1,17 @@
package com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases package com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
import kotlinx.coroutines.experimental.channels.ReceiveChannel import kotlinx.coroutines.experimental.channels.ReceiveChannel
typealias CeilDescriptionReady = Pair<PsychomatrixCeilInfo, CeilDescription> typealias CeilDescriptionReady = Pair<CeilState, CeilInfo>
interface CeilDescriptionUseCase { interface CeilDescriptionUseCase {
fun openCeilDescriptionReadySubscription(): ReceiveChannel<CeilDescriptionReady> fun openCeilDescriptionReadySubscription(): ReceiveChannel<CeilDescriptionReady>
fun openCeilDescriptionRequestedSubscription(): ReceiveChannel<PsychomatrixCeilInfo> fun openCeilDescriptionRequestedSubscription(): ReceiveChannel<CeilState>
fun descriptionReady(psychomatrixCeilInfo: PsychomatrixCeilInfo, ceilDescription: CeilDescription) fun descriptionReady(ceilState: CeilState, ceilInfo: CeilInfo)
fun requestDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo) fun requestDescription(ceilState: CeilState)
} }

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.PsychomatrixBase.domain.entities package com.github.insanusmokrassar.PsychomatrixBase.domain.entities
data class CeilDescription( data class CeilInfo(
val title: String, val title: String,
val description: String, val description: String,
val characteristicDescription: String, val characteristicDescription: String,

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.PsychomatrixBase.domain.entities package com.github.insanusmokrassar.PsychomatrixBase.domain.entities
data class PsychomatrixCeilInfo( data class CeilState(
val x: Int, val x: Int,
val y: Int, val y: Int,
val count: Int? val count: Int?

View File

@ -65,7 +65,7 @@ open class Psychomatrix(val date: DateTime) {
* Always array 4*5 of values. In rows was put columns * Always array 4*5 of values. In rows was put columns
* *
*/ */
val asMatrix: Array<Array<PsychomatrixCeilInfo>> val asMatrix: Array<Array<CeilState>>
get() = arrayOf( get() = arrayOf(
arrayOf( arrayOf(
null, null,
@ -99,7 +99,7 @@ open class Psychomatrix(val date: DateTime) {
x, yArray -> x, yArray ->
yArray.mapIndexed { yArray.mapIndexed {
y, value -> y, value ->
PsychomatrixCeilInfo( CeilState(
x, x,
y, y,
value ?.toInt() value ?.toInt()

View File

@ -2,8 +2,8 @@ package com.github.insanusmokrassar.PsychomatrixBase.domain.interactors
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CeilDescriptionReady import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CeilDescriptionReady
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.CeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_EXTRA_SMALL import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_EXTRA_SMALL
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_SMALL import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_SMALL
import kotlinx.coroutines.experimental.channels.BroadcastChannel import kotlinx.coroutines.experimental.channels.BroadcastChannel
@ -14,7 +14,7 @@ class CeilDescriptionInteractor : CeilDescriptionUseCase {
private val ceilDescriptionReadyBroadcastChannel = BroadcastChannel<CeilDescriptionReady>( private val ceilDescriptionReadyBroadcastChannel = BroadcastChannel<CeilDescriptionReady>(
SUBSCRIPTIONS_SMALL SUBSCRIPTIONS_SMALL
) )
private val ceilDescriptionRequestedBroadcastChannel = BroadcastChannel<PsychomatrixCeilInfo>( private val ceilDescriptionRequestedBroadcastChannel = BroadcastChannel<CeilState>(
SUBSCRIPTIONS_EXTRA_SMALL SUBSCRIPTIONS_EXTRA_SMALL
) )
@ -22,20 +22,20 @@ class CeilDescriptionInteractor : CeilDescriptionUseCase {
return ceilDescriptionReadyBroadcastChannel.openSubscription() return ceilDescriptionReadyBroadcastChannel.openSubscription()
} }
override fun openCeilDescriptionRequestedSubscription(): ReceiveChannel<PsychomatrixCeilInfo> { override fun openCeilDescriptionRequestedSubscription(): ReceiveChannel<CeilState> {
return ceilDescriptionRequestedBroadcastChannel.openSubscription() return ceilDescriptionRequestedBroadcastChannel.openSubscription()
} }
override fun descriptionReady(psychomatrixCeilInfo: PsychomatrixCeilInfo, ceilDescription: CeilDescription) { override fun descriptionReady(ceilState: CeilState, ceilInfo: CeilInfo) {
launch { launch {
ceilDescriptionReadyBroadcastChannel.send(psychomatrixCeilInfo to ceilDescription) ceilDescriptionReadyBroadcastChannel.send(ceilState to ceilInfo)
} }
} }
override fun requestDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo) { override fun requestDescription(ceilState: CeilState) {
launch { launch {
ceilDescriptionRequestedBroadcastChannel.send( ceilDescriptionRequestedBroadcastChannel.send(
psychomatrixCeilInfo ceilState
) )
} }
} }

View File

@ -1,9 +1,9 @@
package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
import kotlinx.coroutines.experimental.Deferred import kotlinx.coroutines.experimental.Deferred
interface CeilDescriptionPresenter { interface CeilDescriptionPresenter {
fun onUserChooseCeil(ceilInfo: PsychomatrixCeilInfo): Deferred<CeilDescription> fun onUserChooseCeil(ceilState: CeilState): Deferred<CeilInfo>
} }

View File

@ -1,8 +1,8 @@
package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations
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.CeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.CeilDescriptionPresenter import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.CeilDescriptionPresenter
import com.github.insanusmokrassar.PsychomatrixBase.utils.Container import com.github.insanusmokrassar.PsychomatrixBase.utils.Container
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribeChecking import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribeChecking
@ -11,16 +11,16 @@ import kotlinx.coroutines.experimental.*
class CeilDescriptionPresenterImpl( class CeilDescriptionPresenterImpl(
private val ceilDescriptionUseCase: CeilDescriptionUseCase private val ceilDescriptionUseCase: CeilDescriptionUseCase
) : CeilDescriptionPresenter { ) : CeilDescriptionPresenter {
override fun onUserChooseCeil(ceilInfo: PsychomatrixCeilInfo): Deferred<CeilDescription> { override fun onUserChooseCeil(ceilState: CeilState): Deferred<CeilInfo> {
return async { return async {
val container = Container<CeilDescription>() val container = Container<CeilInfo>()
val subscription = ceilDescriptionUseCase.openCeilDescriptionReadySubscription().subscribeChecking( val subscription = ceilDescriptionUseCase.openCeilDescriptionReadySubscription().subscribeChecking(
{ {
container.throwable = it container.throwable = it
false false
} }
) { ) {
if (it.first == ceilInfo) { if (it.first == ceilState) {
container.value = it.second container.value = it.second
false false
} else { } else {
@ -28,7 +28,7 @@ class CeilDescriptionPresenterImpl(
} }
} }
ceilDescriptionUseCase.requestDescription(ceilInfo) ceilDescriptionUseCase.requestDescription(ceilState)
subscription.join() subscription.join()
container.value ?: throw container.throwable ?: throw IllegalStateException("Strange state - must be set value or error") container.value ?: throw container.throwable ?: throw IllegalStateException("Strange state - must be set value or error")

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions package com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions
import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models.CeilsDescriptionsRoot import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models.CeilsInfosRoot
import com.github.insanusmokrassar.PsychomatrixBase.utils.FilesLoader.load import com.github.insanusmokrassar.PsychomatrixBase.utils.FilesLoader.load
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
@ -10,8 +10,8 @@ const val characteristicsFolder = "characteristics"
private val gson: Gson = GsonBuilder().create() private val gson: Gson = GsonBuilder().create()
fun resolveCeilsDescriptionsByLanguage(language: String = "en_US"): CeilsDescriptionsRoot { fun resolveCeilsDescriptionsByLanguage(language: String = "en_US"): CeilsInfosRoot {
return load("$characteristicsFolder/$language.json").let { return load("$characteristicsFolder/$language.json").let {
gson.fromJson(InputStreamReader(it), CeilsDescriptionsRoot::class.java) gson.fromJson(InputStreamReader(it), CeilsInfosRoot::class.java)
} }
} }

View File

@ -1,15 +1,15 @@
package com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models package com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
data class CeilDescriptionConfig( data class CeilInfoConfig(
val title: String = "", val title: String = "",
val description: String = "", val description: String = "",
val note: String? = null, val note: String? = null,
val characteristics: List<CeilCharacteristic> = emptyList() val characteristics: List<CeilCharacteristic> = emptyList()
) { ) {
fun toCeilDescription(countOfCharacteristic: Int): CeilDescription { fun toCeilDescription(countOfCharacteristic: Int): CeilInfo {
return CeilDescription( return CeilInfo(
title, title,
description, description,
countOfCharacteristic.let { countOfCharacteristic.let {

View File

@ -1,17 +0,0 @@
package com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo
data class CeilsDescriptionsRoot(
val language: String? = "en_US",
private val descriptionsList: List<List<CeilDescriptionConfig>> = emptyList()
) {
fun resolveCeilDescription(
psychomatrixCeilInfo: PsychomatrixCeilInfo
): CeilDescription {
return descriptionsList[psychomatrixCeilInfo.x][psychomatrixCeilInfo.y].toCeilDescription(
psychomatrixCeilInfo.count ?: 0
)
}
}

View File

@ -0,0 +1,17 @@
package com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
data class CeilsInfosRoot(
val language: String? = "en_US",
private val descriptionsList: List<List<CeilInfoConfig>> = emptyList()
) {
fun resolveCeilDescription(
ceilState: CeilState
): CeilInfo {
return descriptionsList[ceilState.x][ceilState.y].toCeilDescription(
ceilState.count ?: 0
)
}
}