Created
November 5, 2016 01:59
-
-
Save huewu/8cb89364aefab484ba918c5a2bc511f5 to your computer and use it in GitHub Desktop.
Firebase Workshop RemoteConfig 관련 코드 조각
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
//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