Skip to content

Instantly share code, notes, and snippets.

@griajobag
Created May 25, 2018 01:38
Show Gist options
  • Save griajobag/625587174592945039e471884a49f1ad to your computer and use it in GitHub Desktop.
Save griajobag/625587174592945039e471884a49f1ad to your computer and use it in GitHub Desktop.
/**
* Insert data review to collection of product
* @param review
*/
private void insertDataReview(ReviewModel review) {
ReviewModel reviewModel = new ReviewModel(review.getName(), review.getReview(), review.getTimeStamp(), review.getTotalStarGiven());
CollectionReference collectionReference = firebaseFirestore.collection("product");
DocumentReference documentReference = collectionReference.document(productModelGlobal.getIdProduct());
documentReference.collection("review")
.add(reviewModel)
.addOnSuccessListener(documentReference1 -> {
progressDialog.dismiss();
//after success, then update the rating in product
updateRating(review, productModelGlobal);
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(ReviewActivity.this, "Failed : " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment