Skip to content

Commit 38699c0

Browse files
committed
Update Bandwagoner to use new APIs.
1 parent a381226 commit 38699c0

File tree

1 file changed

+22
-10
lines changed
  • firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner

1 file changed

+22
-10
lines changed

firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/ApiFragment.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void onCreate(Bundle savedInstanceState) {
6464
super.onCreate(savedInstanceState);
6565

6666
frc = FirebaseRemoteConfig.getInstance();
67-
frc.setConfigSettings(
68-
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(true).build());
67+
frc.setConfigSettingsAsync(
68+
new FirebaseRemoteConfigSettings.Builder().setFetchTimeoutInSeconds(0L).build());
6969

7070
firebaseInstallations = FirebaseApp.getInstance().get(FirebaseInstallationsApi.class);
7171
}
@@ -133,11 +133,14 @@ private void addListenerToButton(@IdRes int buttonResourceId, OnClickListener on
133133

134134
/** Sets the version of the FRC server the SDK fetches from. */
135135
@SuppressWarnings("FirebaseUseExplicitDependencies")
136-
private void onDevModeToggle(boolean isChecked) {
136+
private Task<Void> onDevModeToggle(boolean isChecked) {
137137
hideSoftKeyboard();
138138

139-
frc.setConfigSettings(
140-
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(isChecked).build());
139+
String minimumFetchIntervalString = minimumFetchIntervalText.getText().toString();
140+
long fetchTimeout = isChecked ? 0L : Integer.valueOf(minimumFetchIntervalString);
141+
142+
return frc.setConfigSettingsAsync(
143+
new FirebaseRemoteConfigSettings.Builder().setFetchTimeoutInSeconds(fetchTimeout).build());
141144
}
142145

143146
/**
@@ -196,11 +199,20 @@ private void onFetch(View unusedView) {
196199
private void onActivateFetched(View unusedView) {
197200
hideSoftKeyboard();
198201

199-
boolean activated = frc.activateFetched();
200-
apiCallResultsText.setText(
201-
String.format(
202-
"%s - activateFetched %s!",
203-
getCurrentTimeString(), activated ? "was successful" : "returned false"));
202+
frc.activate()
203+
.addOnCompleteListener(
204+
activateTask -> {
205+
if (activateTask.isSuccessful()) {
206+
apiCallResultsText.setText(
207+
String.format(
208+
"%s - activate %s!",
209+
getCurrentTimeString(),
210+
activateTask.getResult() ? "was successful" : "returned false"));
211+
} else {
212+
apiCallResultsText.setText(
213+
String.format("%s - activate failed!", getCurrentTimeString()));
214+
}
215+
});
204216
}
205217

206218
/**

0 commit comments

Comments
 (0)