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
/**
* 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;
package com.putuguna.ratinggoogleplaystore.product;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cv_item"
package com.putuguna.ratinggoogleplaystore.reviews;
public class ProductModel {
private String idProduct;
private int totalVoters;
private double totalRating;
private int star1;
private int star2;
private int star3;
private int star4;
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.putuguna.ratinggoogleplaystore"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"