Skip to content

Instantly share code, notes, and snippets.

@huewu
Created November 5, 2016 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huewu/8cb89364aefab484ba918c5a2bc511f5 to your computer and use it in GitHub Desktop.
Save huewu/8cb89364aefab484ba918c5a2bc511f5 to your computer and use it in GitHub Desktop.
Firebase Workshop RemoteConfig 관련 코드 조각
//in SplashActivity.java
@Override
protected void onResume() {
super.onResume();
FirebaseRemoteConfig.getInstance().fetch(60)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
//MessageListTheme is a simple static class to share the color values
//with other activities.
FirebaseRemoteConfig.getInstance().activateFetched();
MessageListTheme.MessageBackgroundColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_background_color"));
MessageListTheme.MessageTextColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_text_color"));
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Map<String, Object> defaultConfig = new HashMap<>();
defaultConfig.put("message_background_color", "#FF000000");
defaultConfig.put("message_text_color", "#FFFFFFFF");
FirebaseRemoteConfig.getInstance().setDefaults(defaultConfig);
MessageListTheme.MessageBackgroundColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_background_color"));
MessageListTheme.MessageTextColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_text_color"));
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment