add DI and rename (again) use cases

This commit is contained in:
InsanusMokrassar 2018-09-04 10:56:43 +08:00
parent b1d752bfa1
commit 0a2f095f46
11 changed files with 75 additions and 6 deletions

View File

@ -0,0 +1,4 @@
package com.github.insanusmokrassar.PsychomatrixBase.di
interface EntitiesDI {
}

View File

@ -0,0 +1,9 @@
package com.github.insanusmokrassar.PsychomatrixBase.di
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter
interface PresentationLayerDI : UseCasesDI {
val datePickerPresenter: DatePickerPresenter
}

View File

@ -0,0 +1,7 @@
package com.github.insanusmokrassar.PsychomatrixBase.di
import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter
interface UIDI : PresentationLayerDI {
}

View File

@ -0,0 +1,7 @@
package com.github.insanusmokrassar.PsychomatrixBase.di
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate
interface UseCasesDI : EntitiesDI {
val calculatePsychomatrixByDate: CalculatePsychomatrixByDate
}

View File

@ -0,0 +1,7 @@
package com.github.insanusmokrassar.PsychomatrixBase.di.realisations
import com.github.insanusmokrassar.PsychomatrixBase.di.EntitiesDI
open class EntitiesDIImpl : EntitiesDI {
}

View File

@ -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
)
}
}

View File

@ -0,0 +1,7 @@
package com.github.insanusmokrassar.PsychomatrixBase.di.realisations
import com.github.insanusmokrassar.PsychomatrixBase.di.UIDI
class UIDIImpl : UIDI, PresentationLayerDIImpl() {
}

View File

@ -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()
}
}

View File

@ -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>

View File

@ -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> {

View File

@ -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)
}
}