-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #349 from Runnect/feature/improve-developer-mode
[Refactor] 개발자 모드 개선 & 네트워크 예외 처리 오류 수정 (FlowCallAdapter)
- Loading branch information
Showing
26 changed files
with
658 additions
and
61 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
10 changes: 10 additions & 0 deletions
10
app/src/debug/java/com/runnect/runnect/developer/data/dto/ResponseServerStatus.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,10 @@ | ||
package com.runnect.runnect.developer.data.dto | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseServerStatus( | ||
@SerialName("status") | ||
val status: String | ||
) |
18 changes: 18 additions & 0 deletions
18
...rc/debug/java/com/runnect/runnect/developer/data/repository/ServerStatusRepositoryImpl.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.runnect.runnect.developer.data.repository | ||
|
||
import com.runnect.runnect.data.network.FlowResult | ||
import com.runnect.runnect.data.network.toEntityResult | ||
import com.runnect.runnect.developer.data.source.remote.ServerStatusDataSource | ||
import com.runnect.runnect.developer.domain.ServerStatusRepository | ||
import javax.inject.Inject | ||
|
||
class ServerStatusRepositoryImpl @Inject constructor( | ||
private val serverStatusDataSource: ServerStatusDataSource | ||
) : ServerStatusRepository { | ||
|
||
override suspend fun checkServerStatus(serverUrl: String): FlowResult<String> { | ||
return serverStatusDataSource.checkServerStatus(serverUrl).toEntityResult { | ||
it.status | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/debug/java/com/runnect/runnect/developer/data/service/ServerStatusService.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,14 @@ | ||
package com.runnect.runnect.developer.data.service | ||
|
||
import com.runnect.runnect.developer.data.dto.ResponseServerStatus | ||
import kotlinx.coroutines.flow.Flow | ||
import retrofit2.http.GET | ||
import retrofit2.http.Url | ||
|
||
interface ServerStatusService { | ||
|
||
@GET | ||
fun checkServerStatus( | ||
@Url url: String | ||
): Flow<Result<ResponseServerStatus>> | ||
} |
15 changes: 15 additions & 0 deletions
15
...src/debug/java/com/runnect/runnect/developer/data/source/remote/ServerStatusDataSource.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.runnect.runnect.developer.data.source.remote | ||
|
||
import com.runnect.runnect.data.network.FlowResult | ||
import com.runnect.runnect.developer.data.dto.ResponseServerStatus | ||
import com.runnect.runnect.developer.data.service.ServerStatusService | ||
import javax.inject.Inject | ||
|
||
class ServerStatusDataSource @Inject constructor( | ||
private val serverStatusService: ServerStatusService, | ||
) { | ||
|
||
fun checkServerStatus(serverUrl: String): FlowResult<ResponseServerStatus> { | ||
return serverStatusService.checkServerStatus(serverUrl) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/debug/java/com/runnect/runnect/developer/domain/ServerStatusRepository.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.runnect.runnect.developer.domain | ||
|
||
import com.runnect.runnect.data.network.FlowResult | ||
|
||
interface ServerStatusRepository { | ||
|
||
suspend fun checkServerStatus(serverUrl: String): FlowResult<String> | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/debug/java/com/runnect/runnect/developer/enum/ServerStatus.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,31 @@ | ||
package com.runnect.runnect.developer.enum | ||
|
||
import androidx.annotation.ColorRes | ||
import androidx.annotation.StringRes | ||
import com.runnect.runnect.R | ||
import com.runnect.runnect.developer.presentation.RunnectDeveloperViewModel.ServerState | ||
|
||
enum class ServerStatus( | ||
@ColorRes val colorRes: Int, | ||
@StringRes val statusRes: Int, | ||
@StringRes val summaryRes: Int, | ||
) { | ||
|
||
CHECKING(R.color.blue, R.string.developer_server_status_checking_title, R.string.developer_server_status_checking_sub), | ||
RUNNING(R.color.green, R.string.developer_server_status_running_title, R.string.developer_server_status_running_sub), | ||
DEGRADED(R.color.orange, R.string.developer_server_status_degraded_title, R.string.developer_server_status_degraded_sub), | ||
ERROR(R.color.red, R.string.developer_server_status_error_title, R.string.developer_server_status_error_sub), | ||
UNKNOWN(R.color.grey, R.string.developer_server_status_unknown_title, R.string.developer_server_status_unknown_sub); | ||
|
||
companion object { | ||
fun getStatus(state: ServerState): ServerStatus { | ||
return when (state) { | ||
ServerState.Running -> RUNNING | ||
ServerState.Degraded -> DEGRADED | ||
ServerState.Error -> ERROR | ||
ServerState.Unknown -> UNKNOWN | ||
ServerState.Checking -> CHECKING | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.