Last active
August 28, 2019 15:45
-
-
Save PetkevichPavel/a73810141f7e6bd08339b93c0125a91a to your computer and use it in GitHub Desktop.
AN_Cloud Function: Code example.
This file contains hidden or 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
fun Context.setDefaultRCFromFile() : Boolean = | |
File(filesDir, LOCAL_RC_JSON).takeIf { it.exists() }?.let {file-> | |
val defaultRC = mutableMapOf<String, Any>() | |
gson.fromJson(file.inputStream().convertLocalJsonToString(), RCModel::class.java)?.let { rcModel -> | |
defaultRC[RemoteConfigConstants.RC_JSON_PARAM_NAME] = file.inputStream().convertLocalJsonToString() | |
remoteConfigManager.updateRc(rcModel) | |
remoteConfigManager.updateFetchState(true, currentDateTimestamp) | |
} | |
app?.firebaseRemoteConfig?.setDefaults(defaultRC) | |
file.inputStream().close() | |
true | |
}?: false | |
fun setDefaultRC() { | |
if (remoteConfigManager.lastFetchedTime == null && !context.setDefaultRCFromFile()) { | |
//the body will be the same as in the old function! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment