forked from FoKE-Developers/FourCutTogether
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Session data [FoKE-Developers#121]
- 기존에 단순하게 세션 키만 담고 있었음 - 세션 키, 화면 상태, 프레임 정보 및 상태 정보를 담도록 변경
- Loading branch information
Showing
34 changed files
with
345 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 16 additions & 23 deletions
39
domain/src/main/java/com/foke/together/domain/interactor/entity/CutFrameType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
package com.foke.together.domain.interactor.entity | ||
|
||
enum class CutFrameType { | ||
MAKER_FAIRE, | ||
FOURCUT_LIGHT, | ||
FOURCUT_DARK; | ||
import androidx.annotation.DrawableRes | ||
import com.foke.together.domain.R | ||
|
||
companion object { | ||
fun findBy(name: String): CutFrameType { | ||
return when (name) { | ||
MAKER_FAIRE.name -> MAKER_FAIRE | ||
FOURCUT_LIGHT.name -> FOURCUT_LIGHT | ||
FOURCUT_DARK.name -> FOURCUT_DARK | ||
else -> throw IllegalArgumentException("Unknown value: $name") | ||
} | ||
} | ||
fun findBy(ordinal: Int): CutFrameType { | ||
return when (ordinal) { | ||
MAKER_FAIRE.ordinal -> MAKER_FAIRE | ||
FOURCUT_LIGHT.ordinal -> FOURCUT_LIGHT | ||
FOURCUT_DARK.ordinal -> FOURCUT_DARK | ||
else -> throw IllegalArgumentException("Unknown value: $ordinal") | ||
} | ||
} | ||
} | ||
} | ||
sealed class CutFrame ( | ||
@DrawableRes val frameImageSrc: Int, // TODO: asset 에 추가 및 src 값을 넣어서 처리 | ||
val additionalFrameImageSrc: List<String>, | ||
val photoPosition: List<PhotoPosition> | ||
) | ||
|
||
// TODO: add information of frames | ||
class FourCutLightFrame: CutFrame(R.drawable.fourcut_frame_medium_light, emptyList(), emptyList()) | ||
class FourCurDarkFrame: CutFrame(R.drawable.fourcut_frame_medium_dark, emptyList(), emptyList()) | ||
class MakerFaireFrame: CutFrame(R.drawable.maker_faire_frame, emptyList(), emptyList()) | ||
class WeddingFrame1: CutFrame(R.drawable.maker_faire_frame, emptyList(), emptyList()) | ||
class WeddingFrame2: CutFrame(R.drawable.maker_faire_frame, emptyList(), emptyList()) | ||
|
||
class NoneFrame: CutFrame(0, emptyList(), emptyList()) |
26 changes: 26 additions & 0 deletions
26
domain/src/main/java/com/foke/together/domain/interactor/entity/CutFrameTypeV1.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.foke.together.domain.interactor.entity | ||
|
||
enum class CutFrameTypeV1 { | ||
MAKER_FAIRE, | ||
FOURCUT_LIGHT, | ||
FOURCUT_DARK; | ||
|
||
companion object { | ||
fun findBy(name: String): CutFrameTypeV1 { | ||
return when (name) { | ||
MAKER_FAIRE.name -> MAKER_FAIRE | ||
FOURCUT_LIGHT.name -> FOURCUT_LIGHT | ||
FOURCUT_DARK.name -> FOURCUT_DARK | ||
else -> throw IllegalArgumentException("Unknown value: $name") | ||
} | ||
} | ||
fun findBy(ordinal: Int): CutFrameTypeV1 { | ||
return when (ordinal) { | ||
MAKER_FAIRE.ordinal -> MAKER_FAIRE | ||
FOURCUT_LIGHT.ordinal -> FOURCUT_LIGHT | ||
FOURCUT_DARK.ordinal -> FOURCUT_DARK | ||
else -> throw IllegalArgumentException("Unknown value: $ordinal") | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/com/foke/together/domain/interactor/entity/PhotoPosition.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.foke.together.domain.interactor.entity | ||
|
||
data class PhotoPosition ( | ||
val x: Int, | ||
val y: Int, | ||
val height: Int, | ||
val width: Int, | ||
) |
15 changes: 15 additions & 0 deletions
15
domain/src/main/java/com/foke/together/domain/interactor/entity/SessionData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.foke.together.domain.interactor.entity | ||
|
||
data class SessionData ( | ||
val sessionId: SessionId? = null, | ||
val cutFrame: CutFrame, | ||
val status: Status | ||
) | ||
|
||
enum class Status { | ||
INIT, | ||
SELECT_FRAME, | ||
CAPTURE, | ||
GENERATE_PHOTO, | ||
SHARE | ||
} |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/foke/together/domain/interactor/entity/SessionId.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.foke.together.domain.interactor.entity | ||
|
||
data class SessionId ( | ||
val startAt: Long | ||
) { | ||
override fun toString(): String { | ||
return startAt.toString() | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
domain/src/main/java/com/foke/together/domain/interactor/session/ClearSessionUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.foke.together.domain.interactor.session | ||
|
||
import com.foke.together.domain.output.SessionRepositoryInterface | ||
import javax.inject.Inject | ||
|
||
class ClearSessionUseCase @Inject constructor( | ||
private val sessionRepository: SessionRepositoryInterface | ||
) { | ||
operator fun invoke() { | ||
sessionRepository.clearSession() | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
domain/src/main/java/com/foke/together/domain/interactor/session/CreateNewSessionUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.foke.together.domain.interactor.session | ||
|
||
import com.foke.together.domain.output.SessionRepositoryInterface | ||
import javax.inject.Inject | ||
|
||
class CreateNewSessionUseCase @Inject constructor( | ||
private val sessionRepository: SessionRepositoryInterface | ||
) { | ||
operator fun invoke() { | ||
sessionRepository.createSession() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
domain/src/main/java/com/foke/together/domain/interactor/session/GetCurrentSessionUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.foke.together.domain.interactor.session | ||
|
||
import com.foke.together.domain.interactor.entity.SessionData | ||
import com.foke.together.domain.output.SessionRepositoryInterface | ||
import javax.inject.Inject | ||
|
||
class GetCurrentSessionUseCase @Inject constructor( | ||
private val sessionRepository: SessionRepositoryInterface | ||
) { | ||
operator fun invoke(): SessionData? { | ||
return sessionRepository.getSession() | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...n/src/main/java/com/foke/together/domain/interactor/session/UpdateSessionStatusUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.foke.together.domain.interactor.session | ||
|
||
import com.foke.together.domain.interactor.entity.CutFrame | ||
import com.foke.together.domain.interactor.entity.Status | ||
import com.foke.together.domain.output.SessionRepositoryInterface | ||
import javax.inject.Inject | ||
|
||
class UpdateSessionStatusUseCase @Inject constructor( | ||
private val sessionRepository: SessionRepositoryInterface | ||
) { | ||
operator fun invoke(status: Status) { | ||
sessionRepository.updateSession(status) | ||
} | ||
|
||
operator fun invoke(cutFrame: CutFrame) { | ||
sessionRepository.updateSession(cutFrame) | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
domain/src/main/java/com/foke/together/domain/interactor/web/SessionKeyUseCase.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
domain/src/main/java/com/foke/together/domain/output/SessionRepositoryInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
package com.foke.together.domain.output | ||
|
||
import com.foke.together.domain.interactor.entity.CutFrame | ||
import com.foke.together.domain.interactor.entity.SessionData | ||
import com.foke.together.domain.interactor.entity.Status | ||
|
||
interface SessionRepositoryInterface { | ||
suspend fun setSessionKey() | ||
fun getSessionKey(): String | ||
fun createSession() | ||
|
||
fun getSession(): SessionData? | ||
|
||
fun updateSession(cutFrame: CutFrame) | ||
fun updateSession(status: Status) | ||
fun updateSession(cutFrame: CutFrame, status: Status) | ||
|
||
fun clearSession() | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 61 additions & 5 deletions
66
external/src/main/java/com/foke/together/external/repository/SessionRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,72 @@ | ||
package com.foke.together.external.repository | ||
|
||
import com.foke.together.domain.interactor.entity.CutFrame | ||
import com.foke.together.domain.interactor.entity.NoneFrame | ||
import com.foke.together.domain.interactor.entity.SessionData | ||
import com.foke.together.domain.interactor.entity.SessionId | ||
import com.foke.together.domain.interactor.entity.Status | ||
import com.foke.together.domain.output.SessionRepositoryInterface | ||
import com.foke.together.util.AppLog | ||
import com.foke.together.util.TimeUtil | ||
import javax.inject.Inject | ||
|
||
class SessionRepository @Inject constructor(): SessionRepositoryInterface { | ||
private var sessionKey: String = "" | ||
override suspend fun setSessionKey() { | ||
sessionKey = TimeUtil.getCurrentTimeSec() | ||
|
||
private var sessionData: SessionData? = null | ||
|
||
override fun createSession() { | ||
sessionData = SessionData( | ||
SessionId(startAt = TimeUtil.getCurrentTimestamp()), | ||
cutFrame = NoneFrame(), | ||
status = Status.INIT | ||
) | ||
AppLog.i(TAG, "createSession", "sessionData: $sessionData") | ||
|
||
// TODO: save session data to Pref. | ||
} | ||
|
||
override fun getSession(): SessionData? { | ||
AppLog.i(TAG, "getSession", "sessionData: $sessionData") | ||
|
||
return sessionData | ||
// TODO: read session data to Pref. | ||
} | ||
|
||
override fun updateSession(cutFrame: CutFrame) { | ||
sessionData = sessionData?.let { | ||
SessionData(it.sessionId, cutFrame, it.status) | ||
} | ||
AppLog.i(TAG, "updateSession", "sessionData: $sessionData") | ||
|
||
// TODO: save session data to Pref. | ||
} | ||
|
||
override fun updateSession(status: Status) { | ||
sessionData = sessionData?.let { | ||
SessionData(it.sessionId, it.cutFrame, status) | ||
} | ||
AppLog.i(TAG, "updateSession", "sessionData: $sessionData") | ||
|
||
// TODO: save session data to Pref. | ||
} | ||
|
||
override fun updateSession(cutFrame: CutFrame, status: Status) { | ||
sessionData = sessionData?.let { | ||
SessionData(it.sessionId, cutFrame, status) | ||
} | ||
AppLog.i(TAG, "updateSession", "sessionData: $sessionData") | ||
|
||
// TODO: save session data to Pref. | ||
} | ||
|
||
override fun clearSession() { | ||
sessionData = null | ||
AppLog.i(TAG, "clearSession", "sessionData: $sessionData") | ||
|
||
// TODO: clear session data to Pref. | ||
} | ||
|
||
override fun getSessionKey(): String { | ||
return sessionKey | ||
companion object { | ||
private val TAG = SessionRepository::class.java.simpleName | ||
} | ||
} |
Oops, something went wrong.