-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Flag API Use flag value LOCAL_STOPS_ENABLED (#650)
Use flag value LOCAL_STOPS_ENABLED to either call api or use local stops data for feching stops
- Loading branch information
1 parent
4bb50c6
commit 305b1e6
Showing
8 changed files
with
85 additions
and
26 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
5 changes: 5 additions & 0 deletions
5
core/remote-config/src/commonMain/kotlin/xyz/ksharma/krail/core/remote_config/flag/Flag.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,5 @@ | ||
package xyz.ksharma.krail.core.remote_config.flag | ||
|
||
interface Flag { | ||
fun getFlagValue(key: String): FlagValue | ||
} |
5 changes: 5 additions & 0 deletions
5
...remote-config/src/commonMain/kotlin/xyz/ksharma/krail/core/remote_config/flag/FlagKeys.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,5 @@ | ||
package xyz.ksharma.krail.core.remote_config.flag | ||
|
||
enum class FlagKeys(val key: String) { | ||
LOCAL_STOPS_ENABLED("local_stops_enabled") | ||
} |
13 changes: 13 additions & 0 deletions
13
...emote-config/src/commonMain/kotlin/xyz/ksharma/krail/core/remote_config/flag/FlagValue.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 xyz.ksharma.krail.core.remote_config.flag | ||
|
||
sealed class FlagValue { | ||
data class BooleanValue(val value: Boolean) : FlagValue() | ||
data class StringValue(val value: String) : FlagValue() | ||
} | ||
|
||
fun FlagValue.asBoolean(): Boolean { | ||
return when (this) { | ||
is FlagValue.BooleanValue -> this.value | ||
is FlagValue.StringValue -> this.value.toBoolean() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...onfig/src/commonMain/kotlin/xyz/ksharma/krail/core/remote_config/flag/RemoteConfigFlag.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,17 @@ | ||
package xyz.ksharma.krail.core.remote_config.flag | ||
|
||
import xyz.ksharma.krail.core.log.log | ||
import xyz.ksharma.krail.core.remote_config.RemoteConfig | ||
|
||
internal class RemoteConfigFlag(private val remoteConfig: RemoteConfig) : Flag { | ||
|
||
override fun getFlagValue(key: String): FlagValue { | ||
val configValue = remoteConfig.getConfigValue(key) | ||
log("RemoteConfigFlag: getFlagValue: key=$key, configValue=$configValue") | ||
|
||
return when (configValue.asString().toBooleanStrictOrNull()) { | ||
true, false -> FlagValue.BooleanValue(configValue.asBoolean()) | ||
else -> FlagValue.StringValue(configValue.asString()) | ||
} | ||
} | ||
} |
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