Skip to content

Instantly share code, notes, and snippets.

View griajobag's full-sized avatar
🏠
Working from home

Putu Guna griajobag

🏠
Working from home
View GitHub Profile
<uses-permission android:name="android.permission.INTERNET"/>
package com.putuguna.ratinggoogleplaystore.reviews;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
/**
* the method used to get all reviews in firebase firestore
* @param idProduct
*/
private void getAllReview(String idProduct) {
progressBar.setVisibility(View.VISIBLE);
rvReview.setVisibility(View.GONE);
CollectionReference collectionReference = firebaseFirestore.collection("product");
DocumentReference documentReference = collectionReference.document(idProduct);
documentReference.collection("review")
/**
* This method used to display rating by colors
*
* @param productModel
*/
private void setRatingByColor(ProductModel productModel) {
int widthView = constrainLayout1.getWidth();
int totalAllVoters = productModel.getTotalVoters();
int totalRateStar1 = productModel.getStar1();
int totalRateStar2 = productModel.getStar2();
/**
* this method used to update rating of product
*
* @param reviewModel
* @param productModel
*/
private void updateRating(ReviewModel reviewModel, ProductModel productModel) {
ProductModel rate = new ProductModel();
rate.setIdProduct(productModel.getIdProduct());
rate.setProductName(productModel.getProductName());
/**
* 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)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_value_10dp"
android:orientation="vertical">
<LinearLayout
package com.putuguna.ratinggoogleplaystore.reviews;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.putuguna.ratinggoogleplaystore.R;
package com.putuguna.ratinggoogleplaystore.reviews;
import java.util.Date;
public class ReviewModel {
private String name;
private String review;
private Date timeStamp;
private double totalStarGiven;
package com.putuguna.ratinggoogleplaystore.product;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;