Created
May 25, 2018 01:38
-
-
Save griajobag/625587174592945039e471884a49f1ad to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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