mirror of
https://github.com/InsanusMokrassar/PsychomatrixBase.git
synced 2024-11-25 03:28:54 +00:00
much renames
This commit is contained in:
parent
a9b370d3bf
commit
4fc2e39451
@ -1,8 +1,8 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.data.repository
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
|
||||
|
||||
interface PsychomatrixCeilDescriptionRepository {
|
||||
fun getCeilDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo): CeilDescription
|
||||
fun getCeilDescription(ceilState: CeilState): CeilInfo
|
||||
}
|
||||
|
@ -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.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.domain.entities.CeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.models.CeilsInfosRoot
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.CeilDescriptions.resolveCeilsDescriptionsByLanguage
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribe
|
||||
|
||||
@ -15,7 +15,7 @@ class PsychomatrixCeilDescriptionRepositoryImpl(
|
||||
language: String = CEILS_DESCRIPTION_ENGLISH
|
||||
) : PsychomatrixCeilDescriptionRepository {
|
||||
|
||||
private val ceilsDescriptionsRoot: CeilsDescriptionsRoot = resolveCeilsDescriptionsByLanguage(language)
|
||||
private val ceilsInfosRoot: CeilsInfosRoot = resolveCeilsDescriptionsByLanguage(language)
|
||||
|
||||
init {
|
||||
ceilDescriptionUseCase.openCeilDescriptionRequestedSubscription().subscribe {
|
||||
@ -29,7 +29,7 @@ class PsychomatrixCeilDescriptionRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCeilDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo): CeilDescription {
|
||||
return ceilsDescriptionsRoot.resolveCeilDescription(psychomatrixCeilInfo)
|
||||
override fun getCeilDescription(ceilState: CeilState): CeilInfo {
|
||||
return ceilsInfosRoot.resolveCeilDescription(ceilState)
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
|
||||
import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
||||
|
||||
typealias CeilDescriptionReady = Pair<PsychomatrixCeilInfo, CeilDescription>
|
||||
typealias CeilDescriptionReady = Pair<CeilState, CeilInfo>
|
||||
|
||||
interface CeilDescriptionUseCase {
|
||||
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)
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.domain.entities
|
||||
|
||||
data class CeilDescription(
|
||||
data class CeilInfo(
|
||||
val title: String,
|
||||
val description: String,
|
||||
val characteristicDescription: String,
|
@ -1,6 +1,6 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.domain.entities
|
||||
|
||||
data class PsychomatrixCeilInfo(
|
||||
data class CeilState(
|
||||
val x: Int,
|
||||
val y: Int,
|
||||
val count: Int?
|
@ -65,7 +65,7 @@ open class Psychomatrix(val date: DateTime) {
|
||||
* Always array 4*5 of values. In rows was put columns
|
||||
*
|
||||
*/
|
||||
val asMatrix: Array<Array<PsychomatrixCeilInfo>>
|
||||
val asMatrix: Array<Array<CeilState>>
|
||||
get() = arrayOf(
|
||||
arrayOf(
|
||||
null,
|
||||
@ -99,7 +99,7 @@ open class Psychomatrix(val date: DateTime) {
|
||||
x, yArray ->
|
||||
yArray.mapIndexed {
|
||||
y, value ->
|
||||
PsychomatrixCeilInfo(
|
||||
CeilState(
|
||||
x,
|
||||
y,
|
||||
value ?.toInt()
|
||||
|
@ -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.CeilDescriptionUseCase
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
|
||||
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_SMALL
|
||||
import kotlinx.coroutines.experimental.channels.BroadcastChannel
|
||||
@ -14,7 +14,7 @@ class CeilDescriptionInteractor : CeilDescriptionUseCase {
|
||||
private val ceilDescriptionReadyBroadcastChannel = BroadcastChannel<CeilDescriptionReady>(
|
||||
SUBSCRIPTIONS_SMALL
|
||||
)
|
||||
private val ceilDescriptionRequestedBroadcastChannel = BroadcastChannel<PsychomatrixCeilInfo>(
|
||||
private val ceilDescriptionRequestedBroadcastChannel = BroadcastChannel<CeilState>(
|
||||
SUBSCRIPTIONS_EXTRA_SMALL
|
||||
)
|
||||
|
||||
@ -22,20 +22,20 @@ class CeilDescriptionInteractor : CeilDescriptionUseCase {
|
||||
return ceilDescriptionReadyBroadcastChannel.openSubscription()
|
||||
}
|
||||
|
||||
override fun openCeilDescriptionRequestedSubscription(): ReceiveChannel<PsychomatrixCeilInfo> {
|
||||
override fun openCeilDescriptionRequestedSubscription(): ReceiveChannel<CeilState> {
|
||||
return ceilDescriptionRequestedBroadcastChannel.openSubscription()
|
||||
}
|
||||
|
||||
override fun descriptionReady(psychomatrixCeilInfo: PsychomatrixCeilInfo, ceilDescription: CeilDescription) {
|
||||
override fun descriptionReady(ceilState: CeilState, ceilInfo: CeilInfo) {
|
||||
launch {
|
||||
ceilDescriptionReadyBroadcastChannel.send(psychomatrixCeilInfo to ceilDescription)
|
||||
ceilDescriptionReadyBroadcastChannel.send(ceilState to ceilInfo)
|
||||
}
|
||||
}
|
||||
|
||||
override fun requestDescription(psychomatrixCeilInfo: PsychomatrixCeilInfo) {
|
||||
override fun requestDescription(ceilState: CeilState) {
|
||||
launch {
|
||||
ceilDescriptionRequestedBroadcastChannel.send(
|
||||
psychomatrixCeilInfo
|
||||
ceilState
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilDescription
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.PsychomatrixCeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
|
||||
import kotlinx.coroutines.experimental.Deferred
|
||||
|
||||
interface CeilDescriptionPresenter {
|
||||
fun onUserChooseCeil(ceilInfo: PsychomatrixCeilInfo): Deferred<CeilDescription>
|
||||
fun onUserChooseCeil(ceilState: CeilState): Deferred<CeilInfo>
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations
|
||||
|
||||
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.domain.entities.CeilInfo
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.CeilState
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.CeilDescriptionPresenter
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.Container
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.subscribeChecking
|
||||
@ -11,16 +11,16 @@ import kotlinx.coroutines.experimental.*
|
||||
class CeilDescriptionPresenterImpl(
|
||||
private val ceilDescriptionUseCase: CeilDescriptionUseCase
|
||||
) : CeilDescriptionPresenter {
|
||||
override fun onUserChooseCeil(ceilInfo: PsychomatrixCeilInfo): Deferred<CeilDescription> {
|
||||
override fun onUserChooseCeil(ceilState: CeilState): Deferred<CeilInfo> {
|
||||
return async {
|
||||
val container = Container<CeilDescription>()
|
||||
val container = Container<CeilInfo>()
|
||||
val subscription = ceilDescriptionUseCase.openCeilDescriptionReadySubscription().subscribeChecking(
|
||||
{
|
||||
container.throwable = it
|
||||
false
|
||||
}
|
||||
) {
|
||||
if (it.first == ceilInfo) {
|
||||
if (it.first == ceilState) {
|
||||
container.value = it.second
|
||||
false
|
||||
} else {
|
||||
@ -28,7 +28,7 @@ class CeilDescriptionPresenterImpl(
|
||||
}
|
||||
}
|
||||
|
||||
ceilDescriptionUseCase.requestDescription(ceilInfo)
|
||||
ceilDescriptionUseCase.requestDescription(ceilState)
|
||||
|
||||
subscription.join()
|
||||
container.value ?: throw container.throwable ?: throw IllegalStateException("Strange state - must be set value or error")
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
@ -10,8 +10,8 @@ const val characteristicsFolder = "characteristics"
|
||||
|
||||
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 {
|
||||
gson.fromJson(InputStreamReader(it), CeilsDescriptionsRoot::class.java)
|
||||
gson.fromJson(InputStreamReader(it), CeilsInfosRoot::class.java)
|
||||
}
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
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 description: String = "",
|
||||
val note: String? = null,
|
||||
val characteristics: List<CeilCharacteristic> = emptyList()
|
||||
) {
|
||||
fun toCeilDescription(countOfCharacteristic: Int): CeilDescription {
|
||||
return CeilDescription(
|
||||
fun toCeilDescription(countOfCharacteristic: Int): CeilInfo {
|
||||
return CeilInfo(
|
||||
title,
|
||||
description,
|
||||
countOfCharacteristic.let {
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user