mirror of
https://github.com/InsanusMokrassar/PsychomatrixBase.git
synced 2024-11-14 12:23:57 +00:00
add DatePickerPresenterImpl, rename UserCanCalculatePsychomatrixByDate -> UserCalculatePsychomatrixByDate
This commit is contained in:
parent
d3b9f88985
commit
b1d752bfa1
@ -6,7 +6,7 @@ import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
|||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
interface UserCanCalculatePsychomatrixByDate {
|
interface UserCalculatePsychomatrixByDate {
|
||||||
suspend fun calculate(date: Long): Deferred<Psychomatrix>
|
suspend fun calculate(date: Long): Deferred<Psychomatrix>
|
||||||
suspend fun calculate(date: DateTime): Deferred<Psychomatrix>
|
suspend fun calculate(date: DateTime): Deferred<Psychomatrix>
|
||||||
suspend fun calculate(date: Date): Deferred<Psychomatrix>
|
suspend fun calculate(date: Date): Deferred<Psychomatrix>
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.PsychomatrixBase.domain.interactors
|
package com.github.insanusmokrassar.PsychomatrixBase.domain.interactors
|
||||||
|
|
||||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.UserCanCalculatePsychomatrixByDate
|
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.UserCalculatePsychomatrixByDate
|
||||||
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.Psychomatrix
|
import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.Psychomatrix
|
||||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM
|
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM
|
||||||
import kotlinx.coroutines.experimental.Deferred
|
import kotlinx.coroutines.experimental.Deferred
|
||||||
@ -10,7 +10,7 @@ import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
|||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class UserCanCalculatePsychomatrixByDateInteractor : UserCanCalculatePsychomatrixByDate {
|
class UserCalculatePsychomatrixByDateInteractor : UserCalculatePsychomatrixByDate {
|
||||||
private val psychomatrixCreatedBroadcast = BroadcastChannel<Psychomatrix>(SUBSCRIPTIONS_MEDIUM)
|
private val psychomatrixCreatedBroadcast = BroadcastChannel<Psychomatrix>(SUBSCRIPTIONS_MEDIUM)
|
||||||
|
|
||||||
override suspend fun calculate(date: Long): Deferred<Psychomatrix> {
|
override suspend fun calculate(date: Long): Deferred<Psychomatrix> {
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.UserCalculatePsychomatrixByDate
|
||||||
|
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
|
||||||
|
import kotlinx.coroutines.experimental.channels.BroadcastChannel
|
||||||
|
import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
||||||
|
import kotlinx.coroutines.experimental.launch
|
||||||
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
|
class DatePickerPresenterImpl(
|
||||||
|
private val userCalculatePsychomatrixByDate: UserCalculatePsychomatrixByDate
|
||||||
|
) : DatePickerPresenter {
|
||||||
|
private val psychomatrixCreateBroadcastChannel = BroadcastChannel<Psychomatrix>(SUBSCRIPTIONS_MEDIUM)
|
||||||
|
|
||||||
|
override suspend fun openPsychomatrixCreatedSubscription(): ReceiveChannel<Psychomatrix> {
|
||||||
|
return psychomatrixCreateBroadcastChannel.openSubscription()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun userPickDate(date: Long) {
|
||||||
|
userPickDate(DateTime(date))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun userPickDate(date: DateTime) {
|
||||||
|
launch {
|
||||||
|
userCalculatePsychomatrixByDate.calculate(date).await().also {
|
||||||
|
psychomatrixCreateBroadcastChannel.send(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user