-
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 #909 from TeamHavit/release
[RELEASE] v1.0.11 배포
- Loading branch information
Showing
23 changed files
with
422 additions
and
89 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
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
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
31 changes: 31 additions & 0 deletions
31
app/src/main/java/org/sopt/havit/data/repository/SystemMaintenanceRepositoryImpl.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 org.sopt.havit.data.repository | ||
|
||
import org.sopt.havit.data.source.remote.RemoteConfigDataSource | ||
import org.sopt.havit.domain.repository.SystemMaintenanceRepository | ||
import javax.inject.Inject | ||
|
||
class SystemMaintenanceRepositoryImpl @Inject constructor( | ||
private val systemMaintenanceRemoteDataSource: RemoteConfigDataSource, | ||
) : SystemMaintenanceRepository { | ||
override suspend fun isSystemMaintenance(): Boolean { | ||
val isSystemUnderMaintenance = systemMaintenanceRemoteDataSource.fetchRemoteConfig( | ||
IS_SYSTEM_UNDER_MAINTENANCE, | ||
Boolean::class.java | ||
) as? Boolean | ||
return isSystemUnderMaintenance ?: false | ||
} | ||
|
||
override suspend fun getSystemMaintenanceMessage(): String { | ||
val message = systemMaintenanceRemoteDataSource.fetchRemoteConfig( | ||
SYSTEM_MAINTENANCE_MESSAGE, | ||
String::class.java | ||
).toString() | ||
return message.ifEmpty { DEFAULT_MESSAGE } | ||
} | ||
|
||
companion object { | ||
private const val IS_SYSTEM_UNDER_MAINTENANCE = "isSystemUnderMaintenance" | ||
private const val SYSTEM_MAINTENANCE_MESSAGE = "systemMaintenanceMessage" | ||
private const val DEFAULT_MESSAGE = "현재 시스템 점검중입니다.\\n불편을 끼쳐드려 죄송합니다." | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/org/sopt/havit/data/source/remote/RemoteConfigDataSource.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,7 @@ | ||
package org.sopt.havit.data.source.remote | ||
|
||
import java.lang.reflect.Type | ||
|
||
interface RemoteConfigDataSource { | ||
suspend fun fetchRemoteConfig(configKey: String, valueType: Type): Any | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/org/sopt/havit/data/source/remote/RemoteConfigDataSourceImpl.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,34 @@ | ||
package org.sopt.havit.data.source.remote | ||
|
||
import com.google.firebase.ktx.Firebase | ||
import com.google.firebase.remoteconfig.FirebaseRemoteConfig | ||
import com.google.firebase.remoteconfig.ktx.remoteConfig | ||
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings | ||
import kotlinx.coroutines.suspendCancellableCoroutine | ||
import java.lang.reflect.Type | ||
import javax.inject.Inject | ||
|
||
class RemoteConfigDataSourceImpl @Inject constructor() : RemoteConfigDataSource { | ||
|
||
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig.apply { | ||
setConfigSettingsAsync(remoteConfigSettings { minimumFetchIntervalInSeconds = 60 }) | ||
} | ||
|
||
override suspend fun fetchRemoteConfig(configKey: String, valueType: Type): Any { | ||
return suspendCancellableCoroutine { continuation -> | ||
remoteConfig.fetchAndActivate().addOnCompleteListener { task -> | ||
if (task.isSuccessful) { | ||
val remoteConfigValue = when (valueType) { | ||
String::class.java -> remoteConfig.getString(configKey) | ||
Boolean::class.java -> remoteConfig.getBoolean(configKey) | ||
Long::class.java -> remoteConfig.getLong(configKey) | ||
else -> throw IllegalArgumentException("Not supported type. Please check valueType") | ||
} | ||
continuation.resumeWith(Result.success(remoteConfigValue)) | ||
} else continuation.resumeWith( | ||
Result.failure(task.exception ?: Exception("fetchRemoteConfig failed")) | ||
) | ||
} | ||
} | ||
} | ||
} |
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
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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/havit/domain/repository/SystemMaintenanceRepository.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 org.sopt.havit.domain.repository | ||
|
||
interface SystemMaintenanceRepository { | ||
|
||
suspend fun isSystemMaintenance(): Boolean | ||
|
||
suspend fun getSystemMaintenanceMessage(): String | ||
} |
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
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,27 @@ | ||
package org.sopt.havit.ui.base | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.launch | ||
import org.sopt.havit.domain.repository.SystemMaintenanceRepository | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
open class BaseViewModel @Inject constructor( | ||
private val systemMaintenanceRepository: SystemMaintenanceRepository, | ||
) : ViewModel() { | ||
|
||
|
||
private val _isSystemMaintenance: MutableLiveData<Boolean> = MutableLiveData() | ||
val isSystemMaintenance: LiveData<Boolean> = _isSystemMaintenance | ||
|
||
|
||
fun fetchIsSystemMaintenance() { | ||
viewModelScope.launch { | ||
_isSystemMaintenance.postValue(systemMaintenanceRepository.isSystemMaintenance()) | ||
} | ||
} | ||
} |
Oops, something went wrong.