mirror of
https://github.com/InsanusMokrassar/PsychomatrixBase.git
synced 2024-11-14 04:13:57 +00:00
add DI and rename (again) use cases
This commit is contained in:
parent
b1d752bfa1
commit
0a2f095f46
@ -0,0 +1,4 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di
|
||||
|
||||
interface EntitiesDI {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter
|
||||
|
||||
interface PresentationLayerDI : UseCasesDI {
|
||||
|
||||
val datePickerPresenter: DatePickerPresenter
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter
|
||||
|
||||
interface UIDI : PresentationLayerDI {
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate
|
||||
|
||||
interface UseCasesDI : EntitiesDI {
|
||||
val calculatePsychomatrixByDate: CalculatePsychomatrixByDate
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di.realisations
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.di.EntitiesDI
|
||||
|
||||
open class EntitiesDIImpl : EntitiesDI {
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di.realisations
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.di.PresentationLayerDI
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations.DatePickerPresenterImpl
|
||||
|
||||
open class PresentationLayerDIImpl : PresentationLayerDI, UseCasesDIImpl() {
|
||||
|
||||
override val datePickerPresenter: DatePickerPresenter by lazy {
|
||||
DatePickerPresenterImpl(
|
||||
calculatePsychomatrixByDate
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di.realisations
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.di.UIDI
|
||||
|
||||
class UIDIImpl : UIDI, PresentationLayerDIImpl() {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.di.realisations
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.di.UseCasesDI
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.interactors.CalculatePsychomatrixByDateInteractor
|
||||
|
||||
open class UseCasesDIImpl : UseCasesDI, EntitiesDIImpl() {
|
||||
|
||||
override val calculatePsychomatrixByDate: CalculatePsychomatrixByDate by lazy {
|
||||
CalculatePsychomatrixByDateInteractor()
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
|
||||
interface UserCalculatePsychomatrixByDate {
|
||||
interface CalculatePsychomatrixByDate {
|
||||
suspend fun calculate(date: Long): Deferred<Psychomatrix>
|
||||
suspend fun calculate(date: DateTime): Deferred<Psychomatrix>
|
||||
suspend fun calculate(date: Date): Deferred<Psychomatrix>
|
@ -1,6 +1,6 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.domain.interactors
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.UserCalculatePsychomatrixByDate
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.Psychomatrix
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM
|
||||
import kotlinx.coroutines.experimental.Deferred
|
||||
@ -10,7 +10,7 @@ import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
|
||||
class UserCalculatePsychomatrixByDateInteractor : UserCalculatePsychomatrixByDate {
|
||||
class CalculatePsychomatrixByDateInteractor : CalculatePsychomatrixByDate {
|
||||
private val psychomatrixCreatedBroadcast = BroadcastChannel<Psychomatrix>(SUBSCRIPTIONS_MEDIUM)
|
||||
|
||||
override suspend fun calculate(date: Long): Deferred<Psychomatrix> {
|
@ -1,6 +1,6 @@
|
||||
package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations
|
||||
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.UserCalculatePsychomatrixByDate
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.Psychomatrix
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter
|
||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM
|
||||
@ -10,7 +10,7 @@ import kotlinx.coroutines.experimental.launch
|
||||
import org.joda.time.DateTime
|
||||
|
||||
class DatePickerPresenterImpl(
|
||||
private val userCalculatePsychomatrixByDate: UserCalculatePsychomatrixByDate
|
||||
private val CalculatePsychomatrixByDate: CalculatePsychomatrixByDate
|
||||
) : DatePickerPresenter {
|
||||
private val psychomatrixCreateBroadcastChannel = BroadcastChannel<Psychomatrix>(SUBSCRIPTIONS_MEDIUM)
|
||||
|
||||
@ -24,7 +24,7 @@ class DatePickerPresenterImpl(
|
||||
|
||||
override fun userPickDate(date: DateTime) {
|
||||
launch {
|
||||
userCalculatePsychomatrixByDate.calculate(date).await().also {
|
||||
CalculatePsychomatrixByDate.calculate(date).await().also {
|
||||
psychomatrixCreateBroadcastChannel.send(it)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user