use of com.google.android.gms.tasks.OnSuccessListener in project RSAndroidApp by RailwayStations.
the class AuthActivity method fetchConfig.
// Fetch the config to determine the allowed length of messages.
public void fetchConfig() {
// 1 hour in seconds
long cacheExpiration = 3600;
// server. This should not be used in release builds.
if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cacheExpiration = 0;
}
mFirebaseRemoteConfig.fetch(cacheExpiration).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// Make the fetched config available via FirebaseRemoteConfig get<type> calls.
mFirebaseRemoteConfig.activateFetched();
applyRetrievedLengthLimit();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// There has been an error fetching the config
Log.w(TAG, "Error fetching config: " + e.getMessage());
applyRetrievedLengthLimit();
}
});
}
use of com.google.android.gms.tasks.OnSuccessListener in project FirebaseUI-Android by firebase.
the class ChatActivity method signInAnonymously.
private void signInAnonymously() {
Toast.makeText(this, "Signing in...", Toast.LENGTH_SHORT).show();
mAuth.signInAnonymously().addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult result) {
attachRecyclerViewAdapter();
}
}).addOnCompleteListener(new SignInResultNotifier(this));
}
use of com.google.android.gms.tasks.OnSuccessListener in project quickstart-android by firebase.
the class MyDownloadService method downloadFromPath.
private void downloadFromPath(final String downloadPath) {
Log.d(TAG, "downloadFromPath:" + downloadPath);
// Mark task started
taskStarted();
showProgressNotification(getString(R.string.progress_downloading), 0, 0);
// Download and get total bytes
mStorageRef.child(downloadPath).getStream(new StreamDownloadTask.StreamProcessor() {
@Override
public void doInBackground(StreamDownloadTask.TaskSnapshot taskSnapshot, InputStream inputStream) throws IOException {
long totalBytes = taskSnapshot.getTotalByteCount();
long bytesDownloaded = 0;
byte[] buffer = new byte[1024];
int size;
while ((size = inputStream.read(buffer)) != -1) {
bytesDownloaded += size;
showProgressNotification(getString(R.string.progress_downloading), bytesDownloaded, totalBytes);
}
// Close the stream at the end of the Task
inputStream.close();
}
}).addOnSuccessListener(new OnSuccessListener<StreamDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(StreamDownloadTask.TaskSnapshot taskSnapshot) {
Log.d(TAG, "download:SUCCESS");
// Send success broadcast with number of bytes downloaded
broadcastDownloadFinished(downloadPath, taskSnapshot.getTotalByteCount());
showDownloadFinishedNotification(downloadPath, (int) taskSnapshot.getTotalByteCount());
// Mark task completed
taskCompleted();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Log.w(TAG, "download:FAILURE", exception);
// Send failure broadcast
broadcastDownloadFinished(downloadPath, -1);
showDownloadFinishedNotification(downloadPath, -1);
// Mark task completed
taskCompleted();
}
});
}
use of com.google.android.gms.tasks.OnSuccessListener in project Tapad by berict.
the class PresetStoreAdapter method onFirebasePresetUpdated.
private void onFirebasePresetUpdated(final String presetName, final Runnable onUpdated) {
StorageReference metadataReference = FirebaseStorage.getInstance().getReferenceFromUrl("gs://tapad-4d342.appspot.com/presets/" + presetName).child("preset.zip");
metadataReference.getMetadata().addOnSuccessListener(new OnSuccessListener<StorageMetadata>() {
@Override
public void onSuccess(StorageMetadata storageMetadata) {
Log.d(TAG, "Successful getting metadata");
if (storageMetadata.getUpdatedTimeMillis() > new File(PROJECT_LOCATION_PRESETS + "/" + presetName + "/about/json.txt").lastModified()) {
// firebase preset is updated since last download
// get the new updated preset
Log.d(TAG, "Preset updated");
onUpdated.run();
} else {
Log.d(TAG, "Preset not updated");
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Failed to get preset metadata");
}
});
}
use of com.google.android.gms.tasks.OnSuccessListener in project Tapad by berict.
the class FirebaseHelper method getStorageMetadata.
public StorageMetadata getStorageMetadata(StorageReference storageReference, Activity activity) {
FirebaseApp.initializeApp(activity);
final StorageMetadata[] mStorageMetadata = { null };
storageReference.getMetadata().addOnSuccessListener(new OnSuccessListener<StorageMetadata>() {
@Override
public void onSuccess(StorageMetadata storageMetadata) {
Log.d(TAG, "Successful getting metadata");
mStorageMetadata[0] = storageMetadata;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Failed to get metadata");
}
});
return mStorageMetadata[0];
}
Aggregations