-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#278 [refactor] deprecated된 함수 수정 및 네트워크 에러 분기처리 #279
Changes from all commits
d23dfb5
8d87928
90062a2
8f13494
64a4bf9
cc82cf4
fd80174
672e955
ba0bd6e
cc3d8d5
ee4226f
a29c458
358def2
df2d48a
edcbdc2
e106e7c
10c7547
8d266ea
fce48a3
6022103
1324263
3fe1591
c1b94a3
e44d503
31523c6
b4d8d46
d5c0243
706e935
50bc9d2
9d42312
389edc7
ddfdef4
43e3e69
1248dde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sopt.peekabookaos.data.entity.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ForcedUpdateResponse( | ||
val imageUrl: String, | ||
val androidForceVersion: String, | ||
val text: String | ||
) |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.sopt.peekabookaos.data.repository | ||
|
||
import com.sopt.peekabookaos.data.source.remote.ForcedUpdateDataSource | ||
import com.sopt.peekabookaos.domain.entity.ForcedUpdate | ||
import com.sopt.peekabookaos.domain.entity.UpdateInformation | ||
import com.sopt.peekabookaos.domain.entity.Version | ||
import com.sopt.peekabookaos.domain.repository.ForcedUpdateRepository | ||
import javax.inject.Inject | ||
|
||
class ForcedUpdateRepositoryImpl @Inject constructor( | ||
private val forcedUpdateDataSource: ForcedUpdateDataSource | ||
) : ForcedUpdateRepository { | ||
override suspend fun hasForceUpdateVersion( | ||
currentVersion: String | ||
): Result<ForcedUpdate> = kotlin.runCatching { | ||
forcedUpdateDataSource.getForcedUpdateVersion() | ||
}.map { response -> | ||
val (imageUrl, androidForceVersion, text) = requireNotNull(response.data) | ||
if (Version.of(androidForceVersion).greaterThan(Version.of(currentVersion))) { | ||
return@map ForcedUpdate.Need(UpdateInformation(imageUrl, text)) | ||
} else { | ||
return@map ForcedUpdate.None | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sopt.peekabookaos.data.service | ||
|
||
import com.sopt.peekabookaos.data.entity.BaseResponse | ||
import com.sopt.peekabookaos.data.entity.response.ForcedUpdateResponse | ||
import retrofit2.http.GET | ||
|
||
interface ForcedUpdateService { | ||
@GET("user/v1/version") | ||
suspend fun getVersion(): BaseResponse<ForcedUpdateResponse> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.sopt.peekabookaos.data.source.local | ||
|
||
import android.content.SharedPreferences | ||
import androidx.core.content.edit | ||
import javax.inject.Inject | ||
|
||
class LocalSignedUpDataSource @Inject constructor( | ||
private val prefs: SharedPreferences | ||
) { | ||
var isSignedUp: Boolean | ||
set(value) = prefs.edit { putBoolean(SIGNED_UP, value) } | ||
get() = prefs.getBoolean(SIGNED_UP, false) | ||
|
||
companion object { | ||
private const val SIGNED_UP = "signed up" | ||
} | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.sopt.peekabookaos.data.source.remote | ||
|
||
import com.sopt.peekabookaos.data.entity.BaseResponse | ||
import com.sopt.peekabookaos.data.entity.response.ForcedUpdateResponse | ||
import com.sopt.peekabookaos.data.service.ForcedUpdateService | ||
import javax.inject.Inject | ||
|
||
class ForcedUpdateDataSource @Inject constructor( | ||
private val forcedUpdateService: ForcedUpdateService | ||
) { | ||
suspend fun getForcedUpdateVersion(): BaseResponse<ForcedUpdateResponse> = | ||
forcedUpdateService.getVersion() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
sealed class ForcedUpdate { | ||
data object None : ForcedUpdate() | ||
data class Need(val updateInformation: UpdateInformation) : ForcedUpdate() | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
sealed class SplashUiState { | ||
data object Idle : SplashUiState() | ||
data object Error : SplashUiState() | ||
data object ShowSplash : SplashUiState() | ||
data object CanStartOnboarding : SplashUiState() | ||
data object CanStartMain : SplashUiState() | ||
data class ForceUpdate(val data: UpdateInformation) : SplashUiState() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class UpdateInformation( | ||
val imageUrl: String = "", | ||
val text: String = "" | ||
) : Parcelable |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package com.sopt.peekabookaos.domain.entity | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
class Version private constructor( | ||
private val major: Int, | ||
private val minor: Int | ||
) { | ||
|
||
@Parcelize | ||
data class Version( | ||
val imageUrl: String = "", | ||
val androidForceVersion: String = "", | ||
val versionText: String = "" | ||
) : Parcelable | ||
fun greaterThan(other: Version): Boolean = other.major < major || other.minor < minor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. boolean 을 반환하는 경우는 isGreaterThan처럼 보통 쓴다고 알고 있는데 혹시 어떤가요!? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
모든 boolean에 is 접두사를 붙일 필요는 없어요! |
||
|
||
companion object { | ||
private const val VERSION_SPLIT_SIGN = "." | ||
private const val MAJOR_POSITION = 0 | ||
private const val MINOR_POSITION = 1 | ||
fun of(version: String) = version.split(VERSION_SPLIT_SIGN).map { | ||
it.toInt() | ||
}.let { | ||
Version(it[MAJOR_POSITION], it[MINOR_POSITION]) | ||
} | ||
} | ||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍👍