private void fetchconfig() { long cacheExpiration = 3600; if(mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()){ cacheExpiration=0; } mFirebaseRemoteConfig.fetch(cacheExpiration) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { mFirebaseRemoteConfig.activateFetched(); applyRetrievelengthLimit(); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG,"Error Fetching config", e); applyRetrievelengthLimit(); } }); }
public void fetchConfig() { long cacheExpiration = 3600; // 1 hour in seconds // If developer mode is enabled reduce cacheExpiration to 0 so that each fetch goes to the // 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); applyRetrievedLengthLimit(); } }); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == GALLERY_INTENT && resultCode == RESULT_OK){ showProgressDialog(); Uri uri = data.getData(); StorageReference filePath = mStorage.child("fotos").child(uri.getLastPathSegment()); filePath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { hideProgressDialog(); Uri downloadUri = taskSnapshot.getDownloadUrl(); imageUrl = downloadUri; Picasso.with(NewPostActivity.this).load(downloadUri).fit().centerCrop().into(mCriminalPicture); Toast.makeText(NewPostActivity.this, R.string.upload__success, Toast.LENGTH_SHORT).show(); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { hideProgressDialog(); Toast.makeText(NewPostActivity.this, R.string.upload_failure, Toast.LENGTH_SHORT).show(); } }); } }
public void achievement_show_list() { connect(); if (isConnected()) { mAchievementsClient.getAchievementsIntent() .addOnSuccessListener(new OnSuccessListener<Intent>() { @Override public void onSuccess(Intent intent) { activity.startActivityForResult(intent, REQUEST_ACHIEVEMENTS); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(TAG, "Showing::Loaderboard::Failed:: " + e.toString()); } }); } else { Log.i(TAG, "PlayGameServices: Google calling connect"); } }
public void leaderboard_show(final String l_id) { connect(); if (isConnected()) { mLeaderboardsClient.getLeaderboardIntent(l_id) .addOnSuccessListener(new OnSuccessListener<Intent>() { @Override public void onSuccess (Intent intent) { Log.d(TAG, "Showing::Loaderboard::" + l_id); activity.startActivityForResult(intent, REQUEST_LEADERBOARD); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(TAG, "Showing::Loaderboard::Failed:: " + e.toString()); } }); } else { Log.i(TAG, "PlayGameServices: Google not connected calling connect"); } }
public void leaderboard_show_list() { connect(); if (isConnected()) { mLeaderboardsClient.getAllLeaderboardsIntent() .addOnSuccessListener(new OnSuccessListener<Intent>() { @Override public void onSuccess (Intent intent) { Log.d(TAG, "Showing::Loaderboard::List"); activity.startActivityForResult(intent, REQUEST_LEADERBOARD); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(TAG, "Showing::Loaderboard::Failed:: " + e.toString()); } }); } else { Log.i(TAG, "PlayGameServices: Google not connected calling connect"); } }
private void uploadImageToFirebase(Uri file) { imageFilename = UUID.randomUUID().toString().replaceAll("-", "") + ".jpg"; currentUser = mAuth.getCurrentUser(); StorageReference postedImagesRef = mStorageRef.child(currentUser.getUid()).child(imageFilename); postedImagesRef.putFile(file) .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { // Get a URL to the uploaded content imageDownloadUrl = taskSnapshot.getDownloadUrl().toString(); Log.d(TAG, "success: Image upload"); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { Log.d(TAG, "failed: Image upload"); } }); }
private void getAvailableFileName(final FetchDataCallback callback) { Task<Uri> searchTask = mStorage.child(mResources.getString(R.string.storage_template, mFileIndex)).getDownloadUrl(); searchTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { // If failed, that means the file does not exist, so we call callback callback.onDataFetched(); } }).addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { // if successful, that means a file was found, so increment index mFileIndex++; // Recursive call until we fail to find a file getAvailableFileName(callback); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); showProgressDialog(getString(R.string.profile_progress_message)); mAuth.signInWithCredential(credential) .addOnSuccessListener(this, new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult result) { handleFirebaseAuthResult(result); } }) .addOnFailureListener(this, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { FirebaseCrash.logcat(Log.ERROR, TAG, "auth:onFailure:" + e.getMessage()); handleFirebaseAuthResult(null); } }); }
@Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.explore_button: mAuth.signInAnonymously().addOnSuccessListener(new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { Intent feedsIntent = new Intent(WelcomeActivity.this, FeedsActivity.class); startActivity(feedsIntent); } }).addOnFailureListener( new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(WelcomeActivity.this, "Unable to sign in anonymously.", Toast.LENGTH_SHORT).show(); Log.e(TAG, e.getMessage()); } }); break; case R.id.sign_in_button: Intent signInIntent = new Intent(this, ProfileActivity.class); startActivity(signInIntent); break; } }
public void fetchConfig(){ long catchExpiration = 3600; if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()){ catchExpiration = 0; } mFirebaseRemoteConfig.fetch(catchExpiration) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { mFirebaseRemoteConfig.activateFetched(); applyRetrievedLengthLimit(); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG, "Error fetching config", e); applyRetrievedLengthLimit(); } }); }
private void onSmokeTestClicked() { FirebaseAuth.getInstance() .signInAnonymously() .addOnSuccessListener(this, new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { Log.d(TAG, "auth:onSuccess"); // Run snippets DocSnippets docSnippets = new DocSnippets(mFirestore); docSnippets.runAll(); } }) .addOnFailureListener(this, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(TAG, "auth:onFailure", e); } }); }
private void addAdaLovelace() { // [START add_ada_lovelace] // Create a new user with a first and last name Map<String, Object> user = new HashMap<>(); user.put("first", "Ada"); user.put("last", "Lovelace"); user.put("born", 1815); // Add a new document with a generated ID db.collection("users") .add(user) .addOnSuccessListener(new OnSuccessListener<DocumentReference>() { @Override public void onSuccess(DocumentReference documentReference) { Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId()); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG, "Error adding document", e); } }); // [END add_ada_lovelace] }
/** * Set the given value on the specified {@link DatabaseReference}. * * @param ref reference represents a particular location in your database. * @param value value to update. * @return a {@link Completable} which is complete when the set value call finish successfully. */ @NonNull public static Completable setValue(@NonNull final DatabaseReference ref, final Object value) { return Completable.create(new CompletableOnSubscribe() { @Override public void subscribe(@io.reactivex.annotations.NonNull final CompletableEmitter e) throws Exception { ref.setValue(value).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { e.onComplete(); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { e.onError(exception); } }); } }); }
public void insertAuthor(Author author) { mAuthorReference.child(author.getKey()).setValue(author).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(LOG_TAG, e.getLocalizedMessage()); } }).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { insertAuthorCount++; if(insertAuthorCount== ITERATIONS){ logEvent("Insert "+ ITERATIONS +" Authors", initialTimeAuthorCount, new Date()); } } }); mAuthorReference.push(); }
protected void updateAuthorAndYourPosts(final Author author) { mAuthorReference.child(author.getKey()).setValue(author).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(LOG_TAG, e.getLocalizedMessage()); } }).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { updateAuthorCount++; if(updateAuthorCount== ITERATIONS){ logEvent("Update "+ ITERATIONS +" Authors", initialTimeUpdateAuthor, new Date()); selectCount(); } } }); mAuthorReference.push(); }
protected void deletePost(Post post) { mPostReference.child(post.getKey().toString()).setValue(null).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(LOG_TAG, e.getLocalizedMessage()); } }).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { deleteAuthorsAndPostsCount++; if(deleteAuthorsAndPostsCount== ITERATIONS){ deleteAuthorsAndPostsCount = 0; logEvent("Delete "+ ITERATIONS +" Authors with Posts", initialTimeDeleteAuthorsAndPosts, new Date()); selectCount(); } } }); mPostReference.push(); }
protected void insertPost(Post post) { mPostReference.child(post.getKey()).setValue(post).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(LOG_TAG, e.getLocalizedMessage()); } }).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { insertPostCount++; if(insertPostCount== ITERATIONS){ logEvent("Insert "+ ITERATIONS +" Posts", initialTimePostCount, new Date()); updateData(); } } }); mPostReference.push(); }
@Override public void signUp(final String email, final String password) { FirebaseAuth.getInstance().createUserWithEmailAndPassword(email, password) .addOnSuccessListener(new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { postEvent(LoginEvent.onSignUpSuccess); signIn(email, password); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { postEvent(LoginEvent.onSignUpError, e.getMessage()); } }); }
private void taskChaining() { // [START task_chaining] Task<AuthResult> signInTask = FirebaseAuth.getInstance().signInAnonymously(); signInTask.continueWithTask(new Continuation<AuthResult, Task<String>>() { @Override public Task<String> then(@NonNull Task<AuthResult> task) throws Exception { // Take the result from the first task and start the second one AuthResult result = task.getResult(); return doSomething(result); } }).addOnSuccessListener(new OnSuccessListener<String>() { @Override public void onSuccess(String s) { // Chain of tasks completed successfully, got result from last task. // ... } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { // One of the tasks in the chain failed with an exception. // ... } }); // [END task_chaining] }
private void sendFileFirebase(StorageReference storageReference, final Uri file) { if (storageReference != null) { final String name = DateFormat.format("yyyy-MM-dd_hhmmss", new Date()).toString(); StorageReference imageGalleryRef = storageReference.child(name + "_gallery"); UploadTask uploadTask = imageGalleryRef.putFile(file); uploadTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.e(TAG, "onFailure sendFileFirebase " + e.getMessage()); } }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { Log.i(TAG, "onSuccess sendFileFirebase"); Uri downloadUrl = taskSnapshot.getDownloadUrl(); FileModel fileModel = new FileModel("img", downloadUrl.toString(), name, ""); ChatModel chatModel = new ChatModel(userModel, "", Calendar.getInstance().getTime().getTime() + "", fileModel); mFirebaseDatabaseReference.child(Constants.events).child(evekey).child(Constants.chatmodel).push().setValue(chatModel); } }); } else { //IS NULL } }
private void getCurPos () { mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); mFusedLocationClient.getLastLocation() .addOnSuccessListener(this, new OnSuccessListener<Location>() { @Override public void onSuccess(Location location) { // Got last known location. In some rare situations this can be null. if (location != null) { start = new LatLng(location.getLatitude(), location.getLongitude()); if (info == null) info = getAddress(MapsActivity2.this, location.getLatitude(), location.getLongitude()); moveToPosition(); } } }) .addOnFailureListener(this, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(MapsActivity2.this, "Check Your GPS or network", Toast.LENGTH_SHORT).show(); } }); }
public static void initializeMapMarkers(final User userData, final boolean isOtherUser) { // Check if user has added a profile picture storageRef.child(userData.getUserId()).child("map-size").getDownloadUrl ().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { getUserPhoto(userData, isOtherUser); // Get photo of specified user } }).addOnFailureListener(new OnFailureListener() { // Return user object without photo @Override public void onFailure(@NonNull Exception e) { if (!isOtherUser) { // Returns the user object without photo to initialize the current user // marker in the MapFragment photoDelegate.initializeCurrentUserMarker(userData); } } }); }
@Override public void onRating(Rating rating) { // In a transaction, add the new rating and update the aggregate totals addRating(mRestaurantRef, rating) .addOnSuccessListener(this, new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Log.d(TAG, "Rating added"); // Hide keyboard and scroll to top hideKeyboard(); mRatingsRecycler.smoothScrollToPosition(0); } }) .addOnFailureListener(this, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG, "Add rating failed", e); // Show failure message and hide keyboard hideKeyboard(); Snackbar.make(findViewById(android.R.id.content), "Failed to add rating", Snackbar.LENGTH_SHORT).show(); } }); }
private void imageUpload() { Log.i(TAG, "imageupload"); StorageReference mountainsRef = storageRef.child("user").child(mAuth.getUid()).child("profile.jpg"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] data = baos.toByteArray(); UploadTask uploadTask = mountainsRef.putBytes(data); uploadTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { // Handle unsuccessful uploads } }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { // taskSnapshot.getMetadata() contains file metadata such as size, content-type, and download URL. Uri downloadUrl = taskSnapshot.getDownloadUrl(); Log.d(TAG, String.valueOf(downloadUrl)); } }); }
private void uploadBirth() { Map<String, Object> birthMap = new HashMap<>(); birthMap.put("birth", mYear + "년 " + (mMonth + 1) + "월 " + mDay + "일"); userColRef.document(user.getUid()) .update(birthMap) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Toast.makeText(UserProfileActivity.this, "변경되었습니다", Toast.LENGTH_SHORT).show(); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG, "Error updating document", e); } }); }
public void psaSetting() { islandRef = storageRef.child("user").child(mAuth.getUid()).child("profile.jpg"); final long ONE_MEGABYTE = 1024 * 1024; islandRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() { @Override public void onSuccess(byte[] bytes) { Log.i(TAG, "Success"); // Data for "images/island.jpg" is returns, use this as needed try { bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); psa.setImageBitmap(bitmap); } catch (Exception e) { e.printStackTrace(); } } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { Log.i(TAG, "fail"); // Handle any errors } }); }
/** * {@inheritDoc} */ @Override public void download(String path, long bytesLimit, @NonNull final DownloadCallback<byte[]> callback) { StorageReference pathRef = firebaseStorage().getReference().child(path); pathRef.getBytes(bytesLimit).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { callback.onFail(e); } }).addOnSuccessListener(new OnSuccessListener<byte[]>() { @Override public void onSuccess(byte[] bytes) { callback.onSuccess(bytes); } }); }
/** * {@inheritDoc} */ @Override public void delete(String path, @NonNull final DeleteCallback callback) { StorageReference pathRef = firebaseStorage().getReference().child(path); pathRef.delete().addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { callback.onFail(e); } }).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { callback.onSuccess(); } }); }
/** * Add onFailure and onSuccess listeners to uploadTask. * * @param uploadTask Upload task which we want to deal with. * @param callback Callback which will be call from {@link UploadTask#addOnFailureListener(OnFailureListener)} and {@link UploadTask#addOnSuccessListener(OnSuccessListener)} */ private void processUpload(UploadTask uploadTask, final UploadCallback callback) { uploadTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { callback.onFail(e); } }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { FileMetadata fileMetadata = buildMetadata(taskSnapshot); callback.onSuccess(fileMetadata); } }); }
private void uploadImageUser(Uri photoUri, final Callbacks.IResultCallback<String> callback){ //Uploading Image FirebaseStorage imageProfilesStorage = Library.getImageProfilesStorage(); StorageReference imageProfilePath = imageProfilesStorage.getReference().child(photoUri.getLastPathSegment()); imageProfilePath.putFile(photoUri) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { // Notify error callback.onDataUnavailable(); } }) .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { @SuppressWarnings("VisibleForTests") Uri downloadUrl = taskSnapshot.getDownloadUrl(); String string_dwload = downloadUrl.toString(); // return the photo download url callback.onSuccess(string_dwload); } }); }
@Override public void delete(final Notification notification, final Callbacks.IResultCallback<Notification> callback) { Library.getNotificationsRef(notification.getToUserId()) .child(notification.getId()) .setValue(null) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { callback.onDataUnavailable(); } }) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { callback.onSuccess(notification); } }); }
public static void sendEmailVerification(final Callbacks.IRequestCallback callback, final String email) { FirebaseAuth auth = Library.getFirebaseAuth(); auth.sendPasswordResetEmail(email) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { callback.onError(); } }) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { callback.onSuccess(); } }); }
public void removeComment(String commentId, final String postId, final OnTaskCompleteListener onTaskCompleteListener) { final DatabaseHelper databaseHelper = ApplicationHelper.getDatabaseHelper(); databaseHelper.removeComment(commentId, postId).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { decrementCommentsCount(postId, onTaskCompleteListener); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { onTaskCompleteListener.onTaskComplete(false); LogUtil.logError(TAG, "removeComment()", e); } }); }
public void removePost(final Post post, final OnTaskCompleteListener onTaskCompleteListener) { final DatabaseHelper databaseHelper = ApplicationHelper.getDatabaseHelper(); Task<Void> removeImageTask = removeImage(post.getImageTitle()); removeImageTask.addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { databaseHelper.removePost(post).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { onTaskCompleteListener.onTaskComplete(task.isSuccessful()); databaseHelper.updateProfileLikeCountAfterRemovingPost(post); LogUtil.logDebug(TAG, "removePost(), is success: " + task.isSuccessful()); } }); LogUtil.logDebug(TAG, "removeImage(): success"); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { LogUtil.logError(TAG, "removeImage()", exception); onTaskCompleteListener.onTaskComplete(false); } }); }
public void updateComment(String commentId, String commentText, String postId, final OnTaskCompleteListener onTaskCompleteListener) { DatabaseReference mCommentReference = database.getReference().child("post-comments").child(postId).child(commentId).child("text"); mCommentReference.setValue(commentText).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { if (onTaskCompleteListener != null) { onTaskCompleteListener.onTaskComplete(true); } } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { if (onTaskCompleteListener != null) { onTaskCompleteListener.onTaskComplete(false); } LogUtil.logError(TAG, "updateComment", e); } }); }
public void FindandCollectProductPdfFileLink(String ProductName, String Manufacter){ FirebaseStorage mStor = FirebaseStorage.getInstance(); StorageReference mFindPdfStorageReference = mStor.getReferenceFromUrl("gs://farmers-helper-44f7a.appspot.com/"+Manufacter+"/"+ProductName+"/"+ProductName+".pdf"); mFindPdfStorageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { mPdfUrl = String.valueOf(uri);} }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { mPdfUrl=""; } }); }
private void onDeleteAllClicked() { FirebaseAuth.getInstance() .signInAnonymously() .addOnSuccessListener(this, new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { Log.d(TAG, "auth:onSuccess"); // Delete DocSnippets docSnippets = new DocSnippets(mFirestore); docSnippets.deleteAll(); } }) .addOnFailureListener(this, new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(TAG, "auth:onFailure", e); } }); }
/** * Pushed the current local data to Firebase * * @return the {@link Task} */ public Task<Void> push() { return new PushTask(this).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.e(TAG, "Push of " + getRoot().toString() + " failed", e); } }).addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Log.i(TAG, "Push of " + getRoot().toString() + " succeeded"); } }); }