<repo_name>majiddeh/MyBookStore<file_sep>/app/src/main/java/com/example/mybookstore/Activities/BasketActivity.java
package com.example.mybookstore.Activities;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.mybookstore.Adapters.AdapterBasket;
import com.example.mybookstore.Models.ModelBasket;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.example.mybookstore.Utils.UserSharedPrefrences;
import com.pnikosis.materialishprogress.ProgressWheel;

import java.text.DecimalFormat;
import java.util.List;

public class BasketActivity extends AppCompatActivity {
    TextView txtTitle,txttotal;
    ImageView imgBackButton;
    LinearLayout lnrBasket;
    CardView cardBasket;
    RecyclerView recyclerViewBasket;
    ApiServices apiServices = new ApiServices(BasketActivity.this);
    ProgressWheel progressWheel;
    AdapterBasket adapterBasket;
    int totalAllPrice = 0;
    String phone,token;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_basket);

        UserSharedPrefrences userSharedPrefrences = new UserSharedPrefrences(BasketActivity.this);
        phone= userSharedPrefrences.getUserName();
        token = userSharedPrefrences.getUserToken();


        finViews();
        initializePage();
        onClicks();




    }

    private void initializePage() {
        apiServices.CartReceived(progressWheel,token, new ApiServices.OnCartReceived() {
            @Override
            public void onReceived(List<ModelBasket> modelBaskets,int totalPrice) {
                adapterBasket = new AdapterBasket(BasketActivity.this,modelBaskets);
                adapterBasket.setOnloadPrice(new AdapterBasket.OnloadPrice() {
                    @Override
                    public void onloadPrice() {
                        recreate();
                    }
                });
                recyclerViewBasket.setLayoutManager(new LinearLayoutManager(BasketActivity.this));
                recyclerViewBasket.setAdapter(adapterBasket);
                DecimalFormat decimalFormat = new DecimalFormat("###,###");
                decimalFormat.format(totalPrice);
                txttotal.setText(totalPrice+""+" "+"تومان");


            }
        });


    }

    private void onClicks() {
        imgBackButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        cardBasket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(BasketActivity.this,PayConfirmActivity.class);
                intent.putExtra(Put.token,token);
                startActivity(intent);
            }
//                Intent intent = new Intent(Intent.ACTION_VIEW);
//                intent.setData(Uri.parse(Links.ZARRINPAL+"?Amount="+"1000"+"&Email="+"<EMAIL>"+"&Description="+"سفارش کتاب"));
//                try {
//                    startActivity(intent);
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
////                Intent intent = new Intent(BasketActivity.this,WebGateActivity.class);
////                intent.putExtra(Put.total,totalAllPrice);
////                startActivity(intent);
//            }
        });
    }

    private void finViews() {
        progressWheel = findViewById(R.id.progress_wheel);
        recyclerViewBasket=findViewById(R.id.recyclerbasket);
        cardBasket=findViewById(R.id.card_basket);
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("سبد خرید شما");
        imgBackButton = findViewById(R.id.img_back_second_toolbar);
        lnrBasket=findViewById(R.id.lnrbasket);
        txttotal=findViewById(R.id.txt_total);
    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Models/ModelBasket.java
package com.example.mybookstore.Models;

public class ModelBasket {

    private int id;
    private String image;
    private String number;
    private String title;
    private String price;
    private String allPrice;


    public ModelBasket(int id, String image, String number, String title, String price, String allPrice) {
        this.id = id;
        this.image = image;
        this.number = number;
        this.title = title;
        this.price = price;
        this.allPrice = allPrice;
    }

    public ModelBasket() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getAllPrice() {
        return allPrice;
    }

    public void setAllPrice(String allPrice) {
        this.allPrice = allPrice;
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/PayConfirmActivity.java
package com.example.mybookstore.Activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mybookstore.R;

public class PayConfirmActivity extends AppCompatActivity {

    TextView txtTitle;
    ImageView imgBackButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay_confirm);

        findViews();
        onClicks();
    }

    private void onClicks() {
        imgBackButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });
    }

    private void findViews() {
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("نهایی کردن خرید");
        imgBackButton = findViewById(R.id.img_back_second_toolbar);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/SendCommentActivity.java
package com.example.mybookstore.Activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Put;
import com.example.mybookstore.Utils.UserSharedPrefrences;
import com.willy.ratingbar.ScaleRatingBar;

public class SendCommentActivity extends AppCompatActivity {

    ScaleRatingBar ratingBar;
    EditText edInsert,edPositive,edNegative;
    CardView btnSubmit;
    TextView txtTollbar;
    ImageView imgBack;
    String phone;
    String id ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_send_comment);

        findViews();
        onClicks();

    }

    private void onClicks() {
        imgBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        btnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (phone.equals("ورود/عضویت")){
                    Toast.makeText(SendCommentActivity.this, "لطفا وارد حساب کاربری خود شوید", Toast.LENGTH_SHORT).show();
                }else {
                    if (!edInsert.getText().toString().equals("") && !edNegative.getText().toString().trim().equals("")
                                && !edPositive.getText().toString().trim().equals("")){
                        if (ratingBar.getRating() != 0){
                            ApiServices apiServices = new ApiServices(SendCommentActivity.this);
                            apiServices.SendComment(id, phone, edInsert.getText().toString().trim(),
                                    edPositive.getText().toString().trim(), edNegative.getText().toString().trim(),
                                    ratingBar.getRating(), new ApiServices.OnCommentSend() {
                                        @Override
                                        public void onSend(int responsStatus) {
                                            if (responsStatus == 218){
                                                Toast.makeText(SendCommentActivity.this, "نظر با موفقیت ثبت شد", Toast.LENGTH_SHORT).show();
                                                edInsert.setText("");
                                                edNegative.setText("");
                                                edPositive.setText("");
                                                edInsert.requestFocus();
                                            }
                                        }
                                    });
                        }else
                            Toast.makeText(SendCommentActivity.this, "لطفا امتیاز دهید", Toast.LENGTH_SHORT).show();

                    } else
                        Toast.makeText(SendCommentActivity.this, "لطفا تمامی مقادیر را پر کنید", Toast.LENGTH_SHORT).show();

                }
            }
        });
    }

    private void findViews() {

        ratingBar = findViewById(R.id.rating_insert_comment);
        edInsert = findViewById(R.id.ed_comment_input);
        edInsert.requestFocus();
        edNegative = findViewById(R.id.ed_negative);
        edPositive = findViewById(R.id.ed_positive);
        btnSubmit = findViewById(R.id.btn_submit);

        txtTollbar = findViewById(R.id.txt_title_toolbar_second);
        txtTollbar.setText(R.string.insert_comment);

        imgBack = findViewById(R.id.img_back_second_toolbar);

        UserSharedPrefrences userSharedPrefrences = new UserSharedPrefrences(SendCommentActivity.this);
        phone = userSharedPrefrences.getUserName();
//        image = userSharedPrefrences.getUserImaje();

        id = getIntent().getStringExtra(Put.id);

    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/ChangePassActivity.java
package com.example.mybookstore.Activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Put;
import com.example.mybookstore.Utils.UserSharedPrefrences;
import com.pnikosis.materialishprogress.ProgressWheel;

public class ChangePassActivity extends AppCompatActivity {

    EditText edRepass, edCurrentPass,edNewPass;
    RelativeLayout liner2;
    TextView txtTitle;
    CardView cardChangepass;
    ProgressWheel progressWheel;
    ImageView imgBack;
    ApiServices apiServices;
    String username,token;
    UserSharedPrefrences userSharedPrefrences;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_pass);
        findViews();
        initPage();
        onClicks();


    }

    private void initPage() {
        if (getIntent().getStringExtra("changepass").equals("forget")){
            liner2.setVisibility(View.GONE);
            edNewPass.requestFocus();
        }else if (getIntent().getStringExtra("changepass").equals("change")){
            edCurrentPass.requestFocus();
        }
    }

    private void onClicks() {
        imgBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        cardChangepass.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (getIntent().getStringExtra("changepass").equals("forget")){
                    String pass = convertNumberToEnglish(edNewPass.getText().toString().trim());
                    String repass = convertNumberToEnglish(edRepass.getText().toString().trim());
                    apiServices.SetPass(getIntent().getStringExtra(Put.username),pass,repass,progressWheel);
                }else if (getIntent().getStringExtra("changepass").equals("change")){
                    String pass = convertNumberToEnglish(edNewPass.getText().toString().trim());
                    String repass = convertNumberToEnglish(edRepass.getText().toString().trim());
                    String currentpass = convertNumberToEnglish(edCurrentPass.getText().toString().trim());
                    apiServices.ChangePass(username,token,currentpass,pass,repass,progressWheel);
                }
            }
        });


    }

    private String convertNumberToEnglish(String num) {
        String d = num;
        d = d.replace("۰", "0");
        d = d.replace("۱", "1");
        d = d.replace("۲", "2");
        d = d.replace("٣", "3");
        d = d.replace("٤", "4");
        d = d.replace("۵", "5");
        d = d.replace("٦", "6");
        d = d.replace("٧", "7");
        d = d.replace("۸", "8");
        d = d.replace("۹", "9");

        d = d.replace("۰", "0");
        d = d.replace("۱", "1");
        d = d.replace("۲", "2");
        d = d.replace("۳", "3");
        d = d.replace("۴", "4");
        d = d.replace("۵", "5");
        d = d.replace("۶", "6");
        d = d.replace("۷", "7");
        d = d.replace("۸", "8");
        d = d.replace("۹", "9");

        return d;
    }

    private void findViews() {
        userSharedPrefrences = new UserSharedPrefrences(ChangePassActivity.this);
        apiServices = new ApiServices(ChangePassActivity.this);
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("ایجاد کلمه عبور جدید");
        cardChangepass = findViewById(R.id.card_Register);
        progressWheel = findViewById(R.id.progress_wheel);
        edCurrentPass = findViewById(R.id.ed_current_pass);
        edNewPass = findViewById(R.id.ed_newpass);
        edRepass = findViewById(R.id.ed_repass);
        imgBack = findViewById(R.id.img_back_second_toolbar);
        liner2 =findViewById(R.id.liner2);
        username = userSharedPrefrences.getUserName();
        token = userSharedPrefrences.getUserToken();
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterBanner.java
package com.example.mybookstore.Adapters;

import android.content.Context;
import android.content.Intent;
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.ImageView;
import android.widget.Toast;

import com.example.mybookstore.Activities.BannerActivity;
import com.example.mybookstore.Models.ModelBanner;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.squareup.picasso.Picasso;

import java.util.List;

public class AdapterBanner extends RecyclerView.Adapter<AdapterBanner.viewHolder> {

    Context context;
    List<ModelBanner> modelBanners;

    public AdapterBanner(Context context, List<ModelBanner> modelBanners) {
        this.context = context;
        this.modelBanners = modelBanners;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_show_banner,viewGroup,false);
        return new viewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final viewHolder viewHolder, final int i) {

        Picasso.with(context).load(modelBanners.get(i).getImage())
                .error(R.drawable.placeholder)
                .placeholder(R.drawable.placeholder)
                .into(viewHolder.imgBanner);

        viewHolder.cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(viewHolder.itemView.getContext(), BannerActivity.class);
                intent.putExtra(Put.id,modelBanners.get(i).getId());
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        });

    }

    @Override
    public int getItemCount() {
        return modelBanners.size();
    }

    class viewHolder extends RecyclerView.ViewHolder{
        ImageView imgBanner;
        CardView cardView;

        public viewHolder(@NonNull View itemView) {
            super(itemView);

            imgBanner = itemView.findViewById(R.id.img_banner);
            cardView = itemView.findViewById(R.id.card_banner);
        }
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterItemCat.java
package com.example.mybookstore.Adapters;

import android.content.Context;
import android.content.Intent;
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.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.mybookstore.Activities.ItemActivity;
import com.example.mybookstore.Activities.ItemCatActivity;
import com.example.mybookstore.Models.ModelCategory;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.squareup.picasso.Picasso;

import java.util.List;

public class AdapterItemCat extends RecyclerView.Adapter<AdapterItemCat.viewHolder> {
    Context context;
    List<ModelCategory> modelCategories;

    public AdapterItemCat(Context context, List<ModelCategory> modelCategories) {
        this.context = context;
        this.modelCategories = modelCategories;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_view_category,viewGroup,false);
        return new viewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final viewHolder viewHolder, final int i) {

        final ModelCategory modelCategory = modelCategories.get(i);

        viewHolder.txtCat.setText(modelCategory.getTitle_category());
        Picasso.with(context).load(modelCategory.getImage())
                .placeholder(R.drawable.placeholder)
                .error(R.drawable.placeholder)
                .into(viewHolder.imgCat);

        viewHolder.cardCategory.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(viewHolder.itemView.getContext(), ItemActivity.class);
                intent.putExtra(Put.id,modelCategories.get(i).getId()+"");
                String title = modelCategory.getTitle_category();
                intent.putExtra(Put.name,title);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        });

    }

    @Override
    public int getItemCount() {
        return modelCategories.size();
    }

    class viewHolder extends RecyclerView.ViewHolder{
        CardView cardCategory;
        ImageView imgCat;
        TextView txtCat;

        public viewHolder(@NonNull View itemView) {
            super(itemView);
            cardCategory=itemView.findViewById(R.id.card_category);
            imgCat=itemView.findViewById(R.id.img_category);
            txtCat=itemView.findViewById(R.id.txt_title_category);
        }
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterSearch.java
package com.example.mybookstore.Adapters;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
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.ImageView;
import android.widget.TextView;

import com.example.mybookstore.Activities.ShowActivity;
import com.example.mybookstore.Models.ModelItemProduct;
import com.example.mybookstore.Models.ModelSearch;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.squareup.picasso.Picasso;

import java.text.DecimalFormat;
import java.util.List;

public class AdapterSearch extends RecyclerView.Adapter<AdapterSearch.viewHolder> {
    Context context;
    List<ModelSearch> modelSearches;

    public AdapterSearch(Context context, List<ModelSearch> modelSearches) {
        this.context = context;
        this.modelSearches = modelSearches;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_show_search,viewGroup,false);
        return new viewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final viewHolder viewHolder, int i) {

        final ModelSearch modelSearch =modelSearches.get(i);
        DecimalFormat decimalFormat = new DecimalFormat("###,###");



        if (modelSearch.getLable() != null && modelSearch.getLable().equals("0")){
            viewHolder.txtOffPrice.setVisibility(View.GONE);
        }else {
            viewHolder.txtPrice.setTextColor(Color.RED);
            viewHolder.txtPrice.setPaintFlags(viewHolder.txtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            viewHolder.txtOffPrice.setVisibility(View.VISIBLE);
            viewHolder.txtOffPrice.setText(decimalFormat.format(Integer.valueOf(modelSearch.getOffPrice()))+" "+"تومان");
        }

        viewHolder.txtVisit.setText(modelSearch.getVisit());
        viewHolder.txtTitle.setText(modelSearch.getTitle());
//        viewHolder.txtPublisher.setText(modelSearch.getPublisher());
//        viewHolder.txtAuthor.setText(modelSearch.getAuthor());
        viewHolder.txtPrice.setText(decimalFormat.format(Integer.valueOf(modelSearch.getPrice()))+" "+"تومان");

        viewHolder.txtDesc.setText(modelSearch.getDesc());

        Picasso.with(context).load(modelSearch.getImage())
                .error(R.drawable.placeholder)
                .placeholder(R.drawable.placeholder)
                .into(viewHolder.imageViewSearch);

        viewHolder.cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(viewHolder.itemView.getContext(), ShowActivity.class);
                if (modelSearch.getOffPrice().equals(modelSearch.getPrice())){
                    intent.putExtra(Put.offPrice,"0");
                }else {
                    intent.putExtra(Put.offPrice,modelSearch.getOffPrice());
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                }
                intent.putExtra(Put.id,modelSearch.getId()+"");
                intent.putExtra(Put.cat,modelSearch.getCat());
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                context.startActivity(intent);

            }
        });

    }

    @Override
    public int getItemCount() {
        return modelSearches.size();
    }

    public class viewHolder extends RecyclerView.ViewHolder{
        CardView cardView;
        ImageView imageViewSearch;
        TextView txtTitle,txtPrice,txtDesc,txtVisit,txtOffPrice;
        public viewHolder(@NonNull View itemView) {
            super(itemView);

            cardView=itemView.findViewById(R.id.card_search);
            imageViewSearch=itemView.findViewById(R.id.img_item_search);
            txtTitle=itemView.findViewById(R.id.txttitle_search);
            txtPrice=itemView.findViewById(R.id.txtprice_search);
            txtDesc=itemView.findViewById(R.id.txtdescription_search);
            txtVisit=itemView.findViewById(R.id.txt_visit_item_search);
            txtOffPrice=itemView.findViewById(R.id.txtprice_off_item_search);

        }
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Models/ModelAddress.java
package com.example.mybookstore.Models;

public class ModelAddress {
    int idAddress;
    String name;
    String family;
    String phone;
    String postalcode;
    String city;
    String cityCap;
    String idcityCap;
    String idcity;
    String mobile;
    String address;
    String iduser;

    public ModelAddress() {
    }

    public String getIdcityCap() {
        return idcityCap;
    }

    public void setIdcityCap(String idcityCap) {
        this.idcityCap = idcityCap;
    }

    public String getIdcity() {
        return idcity;
    }

    public void setIdcity(String idcity) {
        this.idcity = idcity;
    }

    public int getIdAddress() {
        return idAddress;
    }

    public void setIdAddress(int idAddress) {
        this.idAddress = idAddress;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFamily() {
        return family;
    }

    public void setFamily(String family) {
        this.family = family;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPostalcode() {
        return postalcode;
    }

    public void setPostalcode(String postalcode) {
        this.postalcode = postalcode;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCityCap() {
        return cityCap;
    }

    public void setCityCap(String cityCap) {
        this.cityCap = cityCap;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getIduser() {
        return iduser;
    }

    public void setIduser(String iduser) {
        this.iduser = iduser;
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterBasket.java
package com.example.mybookstore.Adapters;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
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.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.example.mybookstore.Models.ModelBasket;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.MySingleton;
import com.squareup.picasso.Picasso;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AdapterBasket extends RecyclerView.Adapter<AdapterBasket.ViewHolder> {

    Context context;
    List<ModelBasket> list;

    private OnloadPrice onloadPrice;

    public AdapterBasket(Context context, List<ModelBasket> list) {
        this.context = context;
        this.list = list;
    }

    public void setOnloadPrice(OnloadPrice onloadPrice) {
        this.onloadPrice = onloadPrice;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view =LayoutInflater.from(context).inflate(R.layout.item_show_basket,viewGroup,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {

        DecimalFormat decimalFormat = new DecimalFormat("###,###");

        viewHolder.txtTotalPrice.setText(decimalFormat.format(Integer.valueOf(list.get(i).getAllPrice()))+" "+"تومان");
        Picasso.with(context).load(list.get(i).getImage())
                .placeholder(R.drawable.placeholder)
                .error(R.drawable.placeholder)
                .into(viewHolder.imageBasket);
        viewHolder.txtNumber.setText(list.get(i).getNumber()+" "+"عدد");
        viewHolder.txtTitile.setText(list.get(i).getTitle());
        viewHolder.txtPrice.setText(decimalFormat.format(Integer.valueOf(list.get(i).getPrice()))+" "+"تومان");
        viewHolder.imgdelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

//                if (onloadPrice !=null ){
//                            onloadPrice.onloadPrice();
//                            ApiServices apiServices = new ApiServices(context);
//                            apiServices.DeleteFromCart(list.get(i).getId());
//                            Handler handler = new Handler();
//                            handler.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    list.remove(i);
//                                    notifyItemRemoved(i);
//                                    notifyItemRangeRemoved(i,list.size());
//                                }
//                            },2);
//                        }

                final Dialog dialog = new Dialog(context);
                dialog.setContentView(R.layout.dilaog_default);
                dialog.show();
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                TextView tvTitle,tvText,tvNegativ,tvPositive;
                tvNegativ=dialog.findViewById(R.id.tv_dialog_negative);
                tvPositive=dialog.findViewById(R.id.tv_dialog_positive);
                tvText=dialog.findViewById(R.id.tv_dialog_text);
                tvTitle=dialog.findViewById(R.id.tv_dialog_title);
                tvNegativ.setText("خیر");
                tvPositive.setText("بله");

                tvNegativ.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialog.dismiss();
                            }
                        },500);

                    }
                });

                tvPositive.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Handler handlerr = new Handler();
                        handlerr.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                if (onloadPrice !=null ){
                                    onloadPrice.onloadPrice();
                                    ApiServices apiServices = new ApiServices(context);
                                    apiServices.DeleteFromCart(list.get(i).getId());
                                    Handler handler = new Handler();
                                    handler.postDelayed(new Runnable() {
                                        @Override
                                        public void run() {
                                            list.remove(i);
                                            notifyItemRemoved(i);
                                            notifyItemRangeRemoved(i,list.size());
                                            dialog.dismiss();
                                        }
                                    },2);

                                }
                            }
                        },500);

                    }
                });

                tvTitle.setText("حذف از سبد خرید");
                tvText.setText("آیا مطمئن هستید؟");

            }
        });



    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public interface OnloadPrice {
        void onloadPrice();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageBasket,imgdelete;
        TextView txtTitile,txtNumber,txtPrice,txtTotalPrice;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            imgdelete=itemView.findViewById(R.id.img_delete_from_cart);
            txtNumber=itemView.findViewById(R.id.txtnumberbasket);
            txtPrice=itemView.findViewById(R.id.txtpricebasket);
            txtTitile=itemView.findViewById(R.id.txttitlebasket);
            txtTotalPrice=itemView.findViewById(R.id.txtpricetotalbasket);
            imageBasket=itemView.findViewById(R.id.imgbasket);
        }
    }




}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/ShowCommentActivity.java
package com.example.mybookstore.Activities;

import android.content.Intent;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mybookstore.Adapters.AdapterComment;
import com.example.mybookstore.Models.ModelComment;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Put;

import java.util.ArrayList;
import java.util.List;

public class ShowCommentActivity extends AppCompatActivity {

    RecyclerView recyclerView;
    AdapterComment adapterComment;
    ImageView imgBack;
    TextView txtTitle;
    FloatingActionButton fab;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_comment);

        findViews();
        initPage();
        onClicks();

    }

    private void onClicks() {
        imgBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ShowCommentActivity.this,SendCommentActivity.class);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                intent.putExtra(Put.id,getIntent().getStringExtra(Put.id));
                startActivity(intent);
            }
        });
    }

    private void initPage() {
        ApiServices apiServices = new ApiServices(ShowCommentActivity.this);
        apiServices.GetComment(getIntent().getStringExtra(Put.id),new ApiServices.OnCommentReceived() {
            @Override
            public void onComment(List<ModelComment> modelComments) {
                adapterComment= new AdapterComment(ShowCommentActivity.this,modelComments);
                recyclerView.setLayoutManager(new LinearLayoutManager(ShowCommentActivity.this));
                recyclerView.setAdapter(adapterComment);
                recyclerView.hasFixedSize();
            }
        });
    }

    private void findViews() {
        fab=findViewById(R.id.fab_comment);
        recyclerView=findViewById(R.id.recycler_comment);
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("نظرات کاربران");
        imgBack = findViewById(R.id.img_back_second_toolbar);

    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/FullProductActivity.java
package com.example.mybookstore.Activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mybookstore.Adapters.AdapterCategoryLittleView;
import com.example.mybookstore.Adapters.AdapterOff;
import com.example.mybookstore.Adapters.AdapterProduct;
import com.example.mybookstore.Models.ModelOff_Only_MostVisit;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;

import java.util.List;

public class FullProductActivity extends AppCompatActivity {

    private TextView txtTitle;
    private ImageView imgBack;
    private ApiServices apiServices;
    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_product);

        findViews();
        onClicks();
        initPage();

    }

    private void initPage() {
        if (getIntent().getStringExtra(Put.links).equals(Links.GET_OFF)){
            apiServices.offReceived(Links.GET_OFF, new ApiServices.OnOffReceived() {
                @Override
                public void onOffReceived(List<ModelOff_Only_MostVisit> modelOffOnlies) {
                    AdapterProduct adapterProduct = new AdapterProduct(getApplicationContext(),modelOffOnlies);
                    recyclerView.setLayoutManager(new GridLayoutManager(FullProductActivity.this,2));
                    recyclerView.setAdapter(adapterProduct);
                }
            });
        }else {
            apiServices.onlyReceived(getIntent().getStringExtra(Put.links), new ApiServices.OnOnlyReceived() {
                @Override
                public void onOnlyReceived(List<ModelOff_Only_MostVisit> modelOnlies) {
                    AdapterProduct adapterProduct = new AdapterProduct(getApplicationContext(),modelOnlies);
                    recyclerView.setLayoutManager(new GridLayoutManager(FullProductActivity.this,2));
                    recyclerView.setAdapter(adapterProduct);
                }
            });
        }
    }

    private void onClicks() {
        imgBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void findViews() {
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("لیست کامل");
        imgBack = findViewById(R.id.img_back_second_toolbar);
        apiServices = new ApiServices(FullProductActivity.this);
        recyclerView = findViewById(R.id.recycler_ull_products);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Models/ModelCategory.java
package com.example.mybookstore.Models;

public class ModelCategory {
    int id;
    String title_category;
    String image;

    public ModelCategory(int id, String title_category, String image) {
        this.id = id;
        this.title_category = title_category;
        this.image = image;
    }

    public ModelCategory() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle_category() {
        return title_category;
    }

    public void setTitle_category(String title_category) {
        this.title_category = title_category;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/FavoriteActivity.java
package com.example.mybookstore.Activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mybookstore.Adapters.AdapterFav;
import com.example.mybookstore.Models.ModelFav;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Put;

import java.util.List;

public class FavoriteActivity extends AppCompatActivity {
    private TextView txtTitle;
    private ImageView imgBackButton;
    private RecyclerView recyclerView;
    private AdapterFav adapterFav;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_favorite);


        findViews();
        onClicks();
        recyvlerInit();
    }

    private void recyvlerInit() {

//        adapterFav = new AdapterFav(FavoriteActivity.this, modelFavs);
//        recyclerView.setLayoutManager(new LinearLayoutManager(FavoriteActivity.this));
//        recyclerView.setAdapter(adapterFav);
//        recyclerView.hasFixedSize();
    }

    private void onClicks() {
        imgBackButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void findViews() {
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("لیست علاقه مندی ها");
        imgBackButton = findViewById(R.id.img_back_second_toolbar);
        recyclerView = findViewById(R.id.recycler_fav);

    }

    @Override
    protected void onStart() {
        super.onStart();

        ApiServices apiServices = new ApiServices(FavoriteActivity.this);
        apiServices.FavReceived(getIntent().getStringExtra(Put.username), new ApiServices.OnFavtReceived() {
            @Override
            public void onReceived(List<ModelFav> modelFavs) {
                adapterFav = new AdapterFav(FavoriteActivity.this, modelFavs);
                recyclerView.setLayoutManager(new LinearLayoutManager(FavoriteActivity.this));
                recyclerView.setAdapter(adapterFav);
                recyclerView.hasFixedSize();
            }
        });


    }
    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterAddressFragment.java
package com.example.mybookstore.Adapters;

import android.content.Context;
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.RadioButton;
import android.widget.TextView;

import com.example.mybookstore.Models.ModelAddress;
import com.example.mybookstore.R;

import java.util.List;

public class AdapterAddressFragment extends RecyclerView.Adapter<AdapterAddressFragment.viewHolder> {

    private RadioButton lastCheckedRB = null;
    Context context;
    List<ModelAddress> modelAddresses;
    GetAddressUser getAddressUser;

    public AdapterAddressFragment(Context context, List<ModelAddress> modelAddresses, GetAddressUser getAddressUser) {
        this.context = context;
        this.modelAddresses = modelAddresses;
        this.getAddressUser=getAddressUser;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_show_address,viewGroup,false);
        return new viewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final viewHolder viewHolder, final int position) {

        viewHolder.radioButton.setVisibility(View.VISIBLE);

        final ModelAddress modelAddress=modelAddresses.get(position);
        viewHolder.tvNameFamily.setText(modelAddress.getName() + " " + modelAddress.getFamily());
        viewHolder.tvMobile.setText("شماره تلفن ضروری : "+modelAddress.getMobile());
        viewHolder.tvPhone.setText("شماره تلفن ثابت : "+modelAddress.getPhone());
        viewHolder.tvAddress.setText("آدرس : "+modelAddress.getAddress());
        viewHolder.tvCity.setText(" شهر: ‌"+modelAddress.getCity());
        viewHolder.tvCityCap.setText(" استان : "+modelAddress.getCityCap());
        viewHolder.tvPostalCode.setText(" کدپستی : "+modelAddress.getPostalcode());

//        viewHolder.radioButton.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                for (int i = 0; i <idRadioButton.length ; i++) {
//                    RadioButton radioButtonset = ((Activity)context).findViewById(idRadioButton[i]);
//                    if (view.getId() == idRadioButton[i]){
//                        radioButtonset.setChecked(true);
//                        Toast.makeText(context, "true", Toast.LENGTH_SHORT).show();
//                    }else {
//                        radioButtonset.setChecked(false);
//                        Toast.makeText(context, "false", Toast.LENGTH_SHORT).show();
//                    }
//                }
//            }
//        });


        viewHolder.radioButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                RadioButton checked_rb = (RadioButton) view;
                getAddressUser.onAddressUser(modelAddress.getName(),modelAddress.getFamily(),modelAddress.getAddress(),modelAddress.getCity(),modelAddress.getCityCap(),modelAddress.getMobile());
                if(lastCheckedRB != null){
                    lastCheckedRB.setChecked(false);
                }
                lastCheckedRB = checked_rb;

            }
        });




    }

    public interface GetAddressUser {
        void onAddressUser(String name,String family,String address,String city,String cityCap,String mobile);
    }

    @Override
    public int getItemCount() {
        return modelAddresses.size();
    }

    public class viewHolder extends RecyclerView.ViewHolder {
        CardView cardView;
        RadioButton radioButton;
        TextView tvNameFamily,tvCityCap,tvCity,tvPhone,tvMobile,tvAddress,tvPostalCode;
        public viewHolder(@NonNull View itemView) {
            super(itemView);
            radioButton =itemView.findViewById(R.id.rb_select);
            tvNameFamily=itemView.findViewById(R.id.Tv_name_user);
            tvCityCap=itemView.findViewById(R.id.Tv_ostan_user);
            tvCity=itemView.findViewById(R.id.Tv_city);
            tvAddress=itemView.findViewById(R.id.Tv_address);
            tvPostalCode=itemView.findViewById(R.id.Tv_postalcode);
            tvPhone=itemView.findViewById(R.id.Tv_phone_home);
            tvMobile=itemView.findViewById(R.id.Tv_mobile);
            cardView = itemView.findViewById(R.id.card_address);
        }
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Fragments/FragmentOrderConfirmaton.java
package com.example.mybookstore.Fragments;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.mybookstore.Adapters.AdapterAddressFragment;
import com.example.mybookstore.Models.ModelAddress;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Put;
import com.example.mybookstore.Utils.UserSharedPrefrences;

import java.util.List;
import java.util.Objects;

/**
 * A simple {@link Fragment} subclass.
 */
public class FragmentOrderConfirmaton extends Fragment {

    RecyclerView recyclerView;
    ApiServices apiServices ;
    TextView tvAddressInfo;
    CardView cardOrder;
    String addressUser,nameUser,cityUser,cityCapUser,mobileUser,familyUser;
    public FragmentOrderConfirmaton() {
        // Required empty public constructor
    }

    public void AddressInfo(String name,String family,String address,String city,String cityCap,String mobile){
        this.nameUser=name;
        this.addressUser=address;
        this.cityUser=city;
        this.cityCapUser=cityCap;
        this.mobileUser=mobile;
        this.familyUser=family;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_order_confirmation, container, false);

        cardOrder = view.findViewById(R.id.card_fragment_order);
        tvAddressInfo = view.findViewById(R.id.tv_address_info);
        String text = "تمامی مرسوله های انتخابی " +nameUser+" "+familyUser+" به آدرس " + cityCapUser + " ،"
                +cityUser + " ،" +addressUser +" و به شماره تلفن " +mobileUser + " ارسال خواهد شد";

        tvAddressInfo.setText(text);

        cardOrder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                
            }
        });
        return view;
    }

}
<file_sep>/app/src/main/java/com/example/mybookstore/Utils/UserSharedPrefrences.java
package com.example.mybookstore.Utils;

import android.content.Context;
import android.content.SharedPreferences;

public class UserSharedPrefrences {
    private static final String USER_SHARED_PREF_NAME = "user_shared_pref";
    private SharedPreferences sharedPreferences;

    public UserSharedPrefrences(Context context) {
        sharedPreferences = context.getSharedPreferences(USER_SHARED_PREF_NAME, Context.MODE_PRIVATE);
    }

    public void saveUserLoginInfo(String username,String image,String token){
        SharedPreferences.Editor editor =sharedPreferences.edit();
        editor.putString(Put.username,username);
        editor.putString(Put.token,token);
        editor.putString(Put.image,image);
        editor.apply();
    }
    public void saveUserLoginInfoHA(String username ,String token){
        SharedPreferences.Editor editor =sharedPreferences.edit();
        editor.putString(Put.username,username);
        editor.putString(Put.token,token);
        editor.apply();
    }

//    public void saveUserLoginInfo(String username,String image){
//        SharedPreferences.Editor editor =sharedPreferences.edit();
//        editor.putString(Put.username,username);
//        editor.putString(Put.image,image);
//        editor.apply();
//    }

    public void exitFromAccount(){
        SharedPreferences.Editor editor =sharedPreferences.edit();
        editor.putString(Put.username,"ورود/عضویت");
        editor.putString(Put.image,"");
        editor.apply();
    }

    public String getUserName(){
        return sharedPreferences.getString(Put.username,"ورود/عضویت");
    }
    public String getUserImaje(){
        return sharedPreferences.getString(Put.image,"");
    }
    public String getUserToken(){
        return sharedPreferences.getString(Put.token,"");
    }

}
<file_sep>/app/src/main/java/com/example/mybookstore/Utils/Put.java
package com.example.mybookstore.Utils;

public class Put {
    public static final int REQUEST_CODE =220;
    public static final int STATUS_FAILED=0;
    public static final int STATUS_SUCCESS=218;
    public static final int CHOOSE_GALLERY=2332;
    public static final int EXTERNAL_STORAGE=3211;
    public static final int STATUS_USER_EXIST =214;
    public static final String FIELDS_NOT_FILLED ="01";
    public static final String NOT_EXIST_IN_DB ="0";
    public static final String VERFICATION_ERROR ="209";
    public static final int REQUEST_EXIT =214;


    static final String email = "email";
    public static final String username = "username";
    static final String address = "address";
    public static final String name = "name";
    public static final String total = "total";
    static final String family = "family";
    public static final String password = "<PASSWORD>";
    public static final String token = "token";
    public static final String code = "code";
    public static final String postalcode = "postalcode";
    public static final String repass = "<PASSWORD>";
    public static final String phone = "phone";
    public static final String mobile = "mobile";

    public static final String image = "image";
    public static final String price = "price";
    public static final String label = "label";
    public static final String id = "id";
    public static final String title = "title";
    public static final String visit = "visit";
    public static final String offPrice = "offPrice";
    static final String date = "date";
    static final String only = "only";
    static final String author = "author";
    static final String publisher = "publisher";
    public static final String cat = "cat";
    public static final String desc = "desc";
    static final String num_sold = "num_sold";

    static final String comment = "comment";
    static final String user = "user";
    static final String rating = "rating";
    static final String negative = "negative";
    static final String positive = "positive";
    static final String finalrating = "finalrating";

    static final String params = "param";

    public static final String links = "links";

    public static final String record = "record";
    public static String newuser="newuser";
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterAddress.java
package com.example.mybookstore.Adapters;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
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.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.mybookstore.Models.ModelAddress;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;

import org.w3c.dom.Text;

import java.util.List;

public class AdapterAddress extends RecyclerView.Adapter<AdapterAddress.viewHolder> {

    Context context;
    List<ModelAddress> modelAddresses;
    CardView cardViewPlace;
    RecyclerView recyclerView;
    OnEndLine onEndLine;

    public AdapterAddress(Context context, List<ModelAddress> modelAddresses,CardView cardView,RecyclerView recyclerView,OnEndLine onEndLine) {
        this.context = context;
        this.modelAddresses = modelAddresses;
        this.cardViewPlace=cardView;
        this.recyclerView=recyclerView;
        this.onEndLine=onEndLine;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_show_address,viewGroup,false);
        return new viewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull viewHolder viewHolder, final int i) {

        viewHolder.cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final Dialog dialog = new Dialog(context);
                dialog.setContentView(R.layout.dilaog_default);
                dialog.show();
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(true);
                TextView tvTitle,tvText,tvNegativ,tvPositive;
                tvNegativ=dialog.findViewById(R.id.tv_dialog_negative);
                tvPositive=dialog.findViewById(R.id.tv_dialog_positive);
                tvText=dialog.findViewById(R.id.tv_dialog_text);
                tvTitle=dialog.findViewById(R.id.tv_dialog_title);
                tvNegativ.setText("حذف");
                tvPositive.setText("ویرایش");

                tvNegativ.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                ApiServices apiServices = new ApiServices(context);
                                apiServices.DelAddress(String.valueOf(modelAddresses.get(i).getIdAddress()), new ApiServices.OnAddressDeleted() {
                                    @Override
                                    public void onDeleted(boolean succeed) {
                                        if (succeed){
                                            Handler handler = new Handler();
                                            handler.postDelayed(new Runnable() {
                                                @Override
                                                public void run() {
                                                    modelAddresses.remove(i);
                                                    notifyItemRemoved(i);
                                                    notifyItemRangeRemoved(i,modelAddresses.size());
                                                    if (modelAddresses.isEmpty()){
                                                        recyclerView.setVisibility(View.GONE);
                                                        cardViewPlace.setVisibility(View.VISIBLE);
                                                        onEndLine.onEnd(true);
                                                    }
                                                }
                                            },20);
                                            dialog.dismiss();
                                            Toast.makeText(context, "آدرس مورد نظر با موفقیت حذف شد", Toast.LENGTH_SHORT).show();
                                        }else {
                                            Toast.makeText(context, "عملیات حذف با خطا مواجه شد لطفا دوباره سعی کنید", Toast.LENGTH_SHORT).show();
                                        }
                                    }
                                });

                            }
                        },500);

                    }
                });

                tvPositive.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Handler handlerr = new Handler();
                        handlerr.postDelayed(new Runnable() {
                            @Override
                            public void run() {

                            }
                        },500);

                    }
                });

                tvTitle.setText("حذف یا ویرایش آدرس");
                tvText.setText("آدرس خود را ویرایش یا حذف کنید!");
            }
        });

        final ModelAddress modelAddress=modelAddresses.get(i);
        viewHolder.tvNameFamily.setText(modelAddress.getName() + " " + modelAddress.getFamily());
        viewHolder.tvMobile.setText("شماره تلفن ضروری : "+modelAddress.getMobile());
        viewHolder.tvPhone.setText("شماره تلفن ثابت : "+modelAddress.getPhone());
        viewHolder.tvAddress.setText("آدرس : "+modelAddress.getAddress());
        viewHolder.tvCity.setText(" شهر: ‌"+modelAddress.getCity());
        viewHolder.tvCityCap.setText(" استان : "+modelAddress.getCityCap());
        viewHolder.tvPostalCode.setText(" کدپستی : "+modelAddress.getPostalcode());



    }

    public interface OnEndLine{
        void onEnd(boolean isEnd);
    }


    @Override
    public int getItemCount() {
        return modelAddresses.size();
    }

    public class viewHolder extends RecyclerView.ViewHolder {
        CardView cardView;
        TextView tvNameFamily,tvCityCap,tvCity,tvPhone,tvMobile,tvAddress,tvPostalCode;
        public viewHolder(@NonNull View itemView) {
            super(itemView);
            tvNameFamily=itemView.findViewById(R.id.Tv_name_user);
            tvCityCap=itemView.findViewById(R.id.Tv_ostan_user);
            tvCity=itemView.findViewById(R.id.Tv_city);
            tvAddress=itemView.findViewById(R.id.Tv_address);
            tvPostalCode=itemView.findViewById(R.id.Tv_postalcode);
            tvPhone=itemView.findViewById(R.id.Tv_phone_home);
            tvMobile=itemView.findViewById(R.id.Tv_mobile);
            cardView = itemView.findViewById(R.id.card_address);
        }
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/MainActivity.java
package com.example.mybookstore.Activities;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.GravityCompat;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.CardView;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v4.widget.DrawerLayout;

import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.daimajia.slider.library.SliderLayout;
import com.daimajia.slider.library.SliderTypes.BaseSliderView;
import com.daimajia.slider.library.SliderTypes.TextSliderView;
import com.example.mybookstore.Adapters.AdapterBanner;
import com.example.mybookstore.Adapters.AdapterCategory;
import com.example.mybookstore.Adapters.AdapterCategoryLittleView;
import com.example.mybookstore.Adapters.AdapterOff;
import com.example.mybookstore.Adapters.AdapterProduct;
import com.example.mybookstore.Models.ModelBanner;
import com.example.mybookstore.Models.ModelCategory;
import com.example.mybookstore.Models.ModelOff_Only_MostVisit;
import com.example.mybookstore.Models.ModelSlider;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.example.mybookstore.Utils.UserSharedPrefrences;
import com.squareup.picasso.Picasso;

import java.util.HashMap;
import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class MainActivity extends AppCompatActivity
        implements  BaseSliderView.OnSliderClickListener {
    DrawerLayout drawer;
    Toolbar toolbar;
    ImageView imgShopCart,imgSearch;
    CircleImageView circleImageView;
    SliderLayout sliderLayout;
    CardView cardCategory;
    RecyclerView recyclerOff, recyclerCategory,recyclerOnly,
            recyclerMostVisit,recyclerMostSold,recycBanner,recyBannerBig,recycCatLittle;
    AdapterOff adapterOff;
    TextView txtNaviLogin,txtCount,navAbout, navCat,navBasket,navAccount,
            navFav,txtListOffs,txtListOnly,txtListMostVisit,txtListMostSold;
    LinearLayout specialOffersLable;
    String username,token;
    ApiServices apiServices = new ApiServices(MainActivity.this);
    UserSharedPrefrences userSharedPrefrences;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        init();

    }

    private void init() {
        findViews();
        setUpToolbar();
        sliderInitialize();
        recyclerInitialize();
        onCliclks();
        setUpNavigation();
    }

    private void findViews() {
        userSharedPrefrences = new UserSharedPrefrences(MainActivity.this);

        username = userSharedPrefrences.getUserName();
        token=userSharedPrefrences.getUserToken();

        recyclerOff = findViewById(R.id.offlist_recycler);
        sliderLayout = findViewById(R.id.slider);
        cardCategory = findViewById(R.id.card_category_main);
        specialOffersLable = findViewById(R.id.specialOffers_lable);
        recyclerCategory = findViewById(R.id.recycler_categoryList_main_activity);
        recyclerOnly = findViewById(R.id.recycler_only);
        recyclerMostVisit = findViewById(R.id.recycler_most_visited);
        recyclerMostSold = findViewById(R.id.recycler_most_sold);
        recycCatLittle = findViewById(R.id.recyc_cat_little);
        txtCount=findViewById(R.id.txt_count_cart);
        drawer = findViewById(R.id.drawer_layout);
        imgShopCart=findViewById(R.id.img_shop_cart);
        imgSearch=findViewById(R.id.img_search);
        toolbar = findViewById(R.id.toolbar);

        txtListMostSold = findViewById(R.id.txt_list_most_sold);
        txtListMostVisit = findViewById(R.id.txt_list_most_visit);
        txtListOnly = findViewById(R.id.txt_list_only);
        txtListOffs = findViewById(R.id.txt_list_offs);

        recycBanner = findViewById(R.id.recycler_banner);
        recyBannerBig = findViewById(R.id.recycler_banner_big);

        navAbout = findViewById(R.id.nav_about);
        navBasket = findViewById(R.id.nav_basket);
        navCat = findViewById(R.id.nav_list_category);
        navAccount = findViewById(R.id.nav_account);
        navFav = findViewById(R.id.nav_favorite);
        drawer = findViewById(R.id.drawer_layout);


        circleImageView = findViewById(R.id.img_circle_nav_header);
        if (userSharedPrefrences.getUserImaje().equals("")){
                    Picasso.with(MainActivity.this).load(R.drawable.avatar).
                error(R.drawable.placeholder)
                .placeholder(R.drawable.placeholder)
                .into(circleImageView);
        }else {
            Picasso.with(MainActivity.this).load(userSharedPrefrences.getUserImaje()).
                    error(R.drawable.placeholder)
                    .placeholder(R.drawable.placeholder)
                    .into(circleImageView);
        }

        txtNaviLogin = findViewById(R.id.txt_nav_login);
        txtNaviLogin.setText(username);




    }

    private void setUpNavigation() {

        if (!username.isEmpty()) {
            txtNaviLogin.setText(username);
        }
        navAccount.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (txtNaviLogin.getText().equals("ورود/عضویت")) {
                    startActivityForResult(new Intent(MainActivity.this, LoginActivity.class), Put.REQUEST_CODE);
                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                    drawer.closeDrawer(GravityCompat.START);
                    } else {
                    startActivityForResult(new Intent(MainActivity.this, ProfileActivity.class), Put.REQUEST_EXIT);
                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                    drawer.closeDrawer(GravityCompat.START);
                    }

            }
        });
        navCat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this,CategoryActivity.class));
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                drawer.closeDrawer(GravityCompat.START);
            }
        });
        navBasket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (txtNaviLogin.getText().equals("ورود/عضویت")) {
                    drawer.closeDrawer(GravityCompat.START);
                    Toast.makeText(MainActivity.this, "لطفا وارد حساب کاربری خود شوید", Toast.LENGTH_SHORT).show();
                } else {
                        startActivity(new Intent(MainActivity.this, BasketActivity.class));
                        overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                    drawer.closeDrawer(GravityCompat.START);
                    }

            }
        });
        navAbout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this,AboutActivity.class));
                drawer.closeDrawer(GravityCompat.START);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);

            }
        });
        navFav.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (txtNaviLogin.getText().equals("ورود/عضویت")) {
                    Toast.makeText(MainActivity.this, "وارد حساب کاربری خود شوید", Toast.LENGTH_SHORT).show();
                } else {

                    Intent intent = new Intent(MainActivity.this, FavoriteActivity.class);
                    intent.putExtra(Put.username, username);
                    startActivity(intent);
                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);

                }
            }
        });


    }

    private void onCliclks() {
        txtNaviLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (txtNaviLogin.getText().equals("ورود/عضویت")) {
                    startActivityForResult(new Intent(MainActivity.this, LoginActivity.class), Put.REQUEST_CODE);
                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                } else {
                    startActivityForResult(new Intent(MainActivity.this, ProfileActivity.class), Put.REQUEST_EXIT);
                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                }
            }
        });

        cardCategory.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, CatActivity_ViewPager.class));
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
            }
        });

        imgShopCart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (username.equals("ورود/عضویت")){
                    Toast.makeText(MainActivity.this, "لطفا وارد حساب خود شوید", Toast.LENGTH_SHORT).show();
                }else {
                    startActivity(new Intent(MainActivity.this,BasketActivity.class));
                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                }

            }
        });

        imgSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this,SearchActivity.class));
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
            }
        });

        txtListOffs.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,FullProductActivity.class);
                intent.putExtra(Put.links,Links.GET_OFF);
                startActivity(intent);
            }
        });

        txtListOnly.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,FullProductActivity.class);
                intent.putExtra(Put.links,Links.GET_ONLY);
                startActivity(intent);
            }
        });

        txtListMostVisit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,FullProductActivity.class);
                intent.putExtra(Put.links,Links.GET_MOST_VISIT);
                startActivity(intent);
            }
        });

        txtListMostSold.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,FullProductActivity.class);
                intent.putExtra(Put.links,Links.GET_MOST_VISIT);
                startActivity(intent);
            }
        });

    }

    private void recyclerInitialize() {

        apiServices.offReceived(Links.GET_OFF,new ApiServices.OnOffReceived() {
            @Override
            public void onOffReceived(List<ModelOff_Only_MostVisit> modelOffOnlies) {
                if (modelOffOnlies.size() == 0) {
                    specialOffersLable.setVisibility(View.INVISIBLE);
                    recyclerOff.setVisibility(View.INVISIBLE);
                } else {
                    adapterOff = new AdapterOff(modelOffOnlies, MainActivity.this);
                    recyclerOff.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
                    recyclerOff.hasFixedSize();
                    recyclerOff.setAdapter(adapterOff);

                }
            }
        });

        apiServices.categoryReceive(new ApiServices.OnCategoryReceived() {
            @Override
            public void onCatReceived(List<ModelCategory> modelCategories) {
                AdapterCategoryLittleView adapterCategoryLittleView = new AdapterCategoryLittleView(MainActivity.this, modelCategories);
                recycCatLittle.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
                recycCatLittle.hasFixedSize();
                recycCatLittle.setAdapter(adapterCategoryLittleView);
            }
        });

        apiServices.categoryReceive(new ApiServices.OnCategoryReceived() {
            @Override
            public void onCatReceived(List<ModelCategory> modelCategories) {
                AdapterCategory adapterCategory = new AdapterCategory(MainActivity.this, modelCategories);
                recyclerCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
                recyclerCategory.hasFixedSize();
                recyclerCategory.setAdapter(adapterCategory);
            }
        });

        apiServices.onlyReceived(Links.GET_ONLY,new ApiServices.OnOnlyReceived() {
            @Override
            public void onOnlyReceived(List<ModelOff_Only_MostVisit> modelOnlies) {
                AdapterProduct adapterProduct = new AdapterProduct(MainActivity.this,modelOnlies);
                recyclerOnly.setLayoutManager(new LinearLayoutManager(MainActivity.this,LinearLayoutManager.HORIZONTAL,false));
                recyclerOnly.hasFixedSize();
                recyclerOnly.setAdapter(adapterProduct);
            }
        });

        apiServices.MostvisitReceived(Links.GET_MOST_VISIT,new ApiServices.OnMostVisitReceived() {
            @Override
            public void onMostVisit(List<ModelOff_Only_MostVisit> modelMostVisit) {
                AdapterProduct adapterProduct = new AdapterProduct(MainActivity.this,modelMostVisit);
                recyclerMostVisit.setLayoutManager(new LinearLayoutManager(MainActivity.this,LinearLayoutManager.HORIZONTAL,false));
                recyclerMostVisit.hasFixedSize();
                recyclerMostVisit.setAdapter(adapterProduct);
            }
        });

        apiServices.MostSoldReceived(Links.GET_MOST_SOLD,new ApiServices.OnMostSoldReceived() {
            @Override
            public void onSold(List<ModelOff_Only_MostVisit> modelSold) {
                AdapterProduct adapterProduct = new AdapterProduct(MainActivity.this,modelSold);
                recyclerMostSold.setLayoutManager(new LinearLayoutManager(MainActivity.this,LinearLayoutManager.HORIZONTAL,false));
                recyclerMostSold.hasFixedSize();
                recyclerMostSold.setAdapter(adapterProduct);
            }
        });

        apiServices.GetBanners(new ApiServices.OnBannerReceived() {
            @Override
            public void onBanner(List<ModelBanner> modelBanners) {
                AdapterBanner adapterBanner = new AdapterBanner(MainActivity.this,modelBanners);
                recycBanner.setLayoutManager(new GridLayoutManager(MainActivity.this,2));
                recycBanner.hasFixedSize();
                recycBanner.setAdapter(adapterBanner);
            }
        });

        apiServices.GetBannerBig(new ApiServices.OnBannerReceived() {
            @Override
            public void onBanner(List<ModelBanner> modelBanners) {
                AdapterBanner adapterBanner = new AdapterBanner(MainActivity.this,modelBanners);
                recyBannerBig.setLayoutManager(new GridLayoutManager(MainActivity.this,1));
                recyBannerBig.hasFixedSize();
                recyBannerBig.setAdapter(adapterBanner);
            }
        });



    }

    private void sliderInitialize() {
        apiServices.GetSliders(new ApiServices.OnSliderReceived() {
            @Override
            public void onSlider(List<ModelSlider> modelSliders) {
                HashMap<String, String> url_image = new HashMap<>();
                for (int i = 0; i < modelSliders.size(); i++) {
                    url_image.put(modelSliders.get(i).getName(),modelSliders.get(i).getImage());
                }
                for (int i = 0; i < url_image.keySet().size(); i++) {
                    String keyname = url_image.keySet().toArray()[i].toString();
                    TextSliderView textSliderView = new TextSliderView(MainActivity.this);
                    textSliderView
                            .description(keyname)
                            .image(url_image.get(keyname))
                            .setOnSliderClickListener(MainActivity.this)
                            .empty(R.drawable.placeholder)
                            .error(R.drawable.placeholder)
                            .setScaleType(BaseSliderView.ScaleType.Fit);

                    textSliderView.bundle(new Bundle());
                    textSliderView.getBundle()
                            .putString("extra", keyname);
                    sliderLayout.setDuration(3000);
                    sliderLayout.addSlider(textSliderView);
                }
            }
        });
//        HashMap<String, String> url_image = new HashMap<>();
//        url_image.put("image1",Links.Link_HOST + "/samed_bookstore/uploads/banners/banner4.jpg");
//        url_image.put("image2",Links.Link_HOST + "/samed_bookstore/uploads/banners/banner1.jpg");
//        url_image.put("image3",Links.Link_HOST + "/samed_bookstore/uploads/banners/banner7.jpg");
//        url_image.put("image4",Links.Link_HOST + "/samed_bookstore/uploads/banners/banner8.jpg");
//
//        for (int i = 0; i < url_image.keySet().size(); i++) {
//            String keyname = url_image.keySet().toArray()[i].toString();
//            TextSliderView textSliderView = new TextSliderView(MainActivity.this);
//            textSliderView
////                    .description(keyname)
//                    .image(url_image.get(keyname))
//                    .setOnSliderClickListener(this)
//                    .empty(R.drawable.placeholder)
//                    .error(R.drawable.placeholder)
//                    .setScaleType(BaseSliderView.ScaleType.Fit);
//
//            textSliderView.bundle(new Bundle());
//            textSliderView.getBundle()
//                    .putString("extra", keyname);
//            sliderLayout.setDuration(3000);
//            sliderLayout.addSlider(textSliderView);
//        }
    }

    private void setUpToolbar() {
        setSupportActionBar(toolbar);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();
        if (username != null && username.equals("ورود/عضویت")){
            imgShopCart.setColorFilter(Color.rgb(170,170,170));
            txtCount.setVisibility(View.GONE);
        }



    }




    @SuppressLint("SetTextI18n")
    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);


        if (requestCode == Put.REQUEST_CODE && resultCode == RESULT_OK) {
            if (data != null) {
                String username = data.getStringExtra(Put.username);
                String image = data.getStringExtra(Put.image);
                txtNaviLogin.setText("خوش آمدید  " + username);
                Picasso.with(MainActivity.this).load(image)
                        .placeholder(R.drawable.avatar)
                        .error(R.drawable.avatar)
                        .into(circleImageView);
                recreate();
            }
        } else if (requestCode == Put.REQUEST_EXIT && resultCode == RESULT_OK) {
            if (data != null) {
                String username = data.getStringExtra(Put.username);
                String image = data.getStringExtra(Put.image);
                if (image.equals("")){
                    Picasso.with(MainActivity.this).load(R.drawable.banner2).
                            error(R.drawable.placeholder)
                            .placeholder(R.drawable.placeholder)
                            .into(circleImageView);
                }else {
                    Picasso.with(MainActivity.this).load(userSharedPrefrences.getUserImaje()).
                            error(R.drawable.placeholder)
                            .placeholder(R.drawable.placeholder)
                            .into(circleImageView);
                }
                txtNaviLogin.setText(username);
                recreate();
            }

        }


    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }


    @Override
    public void onSliderClick(BaseSliderView slider) {
        String s = slider.getBundle().get("extra") + "";

//        switch (s) {
//            case ("image1"):
//                Toast.makeText(this, "عکس شماره 1", Toast.LENGTH_SHORT).show();
//                break;
//            case ("image2"):
//                Toast.makeText(this, "عکس شماره 2", Toast.LENGTH_SHORT).show();
//                break;
//            case ("image3"):
//                Toast.makeText(this, "عکس شماره 3", Toast.LENGTH_SHORT).show();
//                break;
//            case ("image4"):
//                Toast.makeText(this, "عکس شماره 4", Toast.LENGTH_SHORT).show();
//                break;
//
//
//        }


    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onStart() {
        super.onStart();
        apiServices.GetCount(token, new ApiServices.OnCountReceived() {
            @Override
            public void onCount(String count) {
                txtCount.setText(count);
            }
        });
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterOff.java
package com.example.mybookstore.Adapters;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.Typeface;
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.ImageView;
import android.widget.TextView;

import com.example.mybookstore.Activities.ShowActivity;
import com.example.mybookstore.Models.ModelOff_Only_MostVisit;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.squareup.picasso.Picasso;

import java.text.DecimalFormat;
import java.util.List;

import jp.shts.android.library.TriangleLabelView;

public class AdapterOff extends RecyclerView.Adapter<AdapterOff.viewHolder> {

    private List<ModelOff_Only_MostVisit> modelOffOnlies;
    private Context context;

    public AdapterOff(List<ModelOff_Only_MostVisit> modelOffOnlies, Context context) {
        this.modelOffOnlies = modelOffOnlies;
        this.context = context;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_show_off,viewGroup,false);
        return new viewHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull final AdapterOff.viewHolder viewHolder, final int i) {

        DecimalFormat decimalFormat = new DecimalFormat("###,###");
        viewHolder.txtPrice.setText(decimalFormat.format(Float.valueOf(modelOffOnlies.get(i).getOffPrice()))+" "+"تومان");

        viewHolder.txtVisit.setText(modelOffOnlies.get(i).getVisit());
        viewHolder.txtTitle.setText(modelOffOnlies.get(i).getTitle());
        viewHolder.txtoffPrice.setText(decimalFormat.format(Integer.valueOf(modelOffOnlies.get(i).getPrice()))+" "+"تومان");
        viewHolder.txtoffPrice.setPaintFlags(viewHolder.txtoffPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        viewHolder.triangleLabelView.setSecondaryText(modelOffOnlies.get(i).getLable());
        Picasso.with(context)
                .load(modelOffOnlies.get(i).getImage())
                .placeholder(R.drawable.placeholder)
                .error(R.drawable.placeholder)
                .into(viewHolder.imgOff);

        viewHolder.cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(viewHolder.itemView.getContext(), ShowActivity.class);
                intent.putExtra(Put.id,modelOffOnlies.get(i).getId()+"");
                intent.putExtra(Put.offPrice,modelOffOnlies.get(i).getOffPrice());
                intent.putExtra(Put.cat,modelOffOnlies.get(i).getCat());
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);

            }
        });


    }

    @Override
    public int getItemCount() {
        return modelOffOnlies.size();
    }

    class viewHolder extends RecyclerView.ViewHolder{
        CardView cardView;
        TriangleLabelView triangleLabelView;
        ImageView imgOff;
        TextView txtTitle,txtVisit,txtPrice,txtoffPrice;

        viewHolder(@NonNull View itemView) {
            super(itemView);

            cardView=itemView.findViewById(R.id.cardview_product);
            triangleLabelView = itemView.findViewById(R.id.triangle_product);
            imgOff = itemView.findViewById(R.id.img_product);
            txtTitle = itemView.findViewById(R.id.txt_title_product);
            txtPrice = itemView.findViewById(R.id.txt_price_product);
            txtVisit = itemView.findViewById(R.id.txt_visit_product);
            txtoffPrice = itemView.findViewById(R.id.txt_price_off);
        }
    }

}
<file_sep>/app/src/main/java/com/example/mybookstore/Fragments/FragmentOrder.java
package com.example.mybookstore.Fragments;


import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.Toast;

import com.example.mybookstore.Activities.BasketActivity;
import com.example.mybookstore.Activities.EditInformation;
import com.example.mybookstore.Adapters.AdapterAddressFragment;
import com.example.mybookstore.Adapters.AdapterBasket;
import com.example.mybookstore.Models.ModelAddress;
import com.example.mybookstore.Models.ModelBasket;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.example.mybookstore.Utils.UserSharedPrefrences;
import com.pnikosis.materialishprogress.ProgressWheel;

import java.lang.reflect.Type;
import java.util.List;
import java.util.Objects;

/**
 * A simple {@link Fragment} subclass.
 */
public class FragmentOrder extends Fragment {

    RecyclerView recyclerViewAddress,recyclerViewProducts;
    ProgressWheel progressWheel;
    ApiServices apiServices ;
    CheckBox checkBoxFactor;
    CardView cardOrder,cardPlaceHolder;
    String nameUser,addressUser,cityUser,cityCapUser,mobileUser,familyUser;
    public FragmentOrder() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_order, container, false);
        String token = Objects.requireNonNull(getActivity()).getIntent().getStringExtra(Put.token);
        recyclerViewAddress = view.findViewById(R.id.recycler_fragment_order_address);
        recyclerViewProducts = view.findViewById(R.id.recycler_fragment_order_products);
        cardPlaceHolder = view.findViewById(R.id.card_placeholder);
        checkBoxFactor = view.findViewById(R.id.chk_factor);
        checkBoxFactor.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), Links.LINK_FONT_VAZIR));
        progressWheel = view.findViewById(R.id.progress_wheel);
        apiServices = new ApiServices(getActivity());
        apiServices.GetAddress(token, new ApiServices.OnAddressReceived() {
            @Override
            public void onReceived(List<ModelAddress> modelAddresses) {
                AdapterAddressFragment adapterAddress = new AdapterAddressFragment(getActivity(), modelAddresses, new AdapterAddressFragment.GetAddressUser() {
                    @Override
                    public void onAddressUser(String name,String family ,String address, String city, String cityCap, String mobile) {
                        nameUser=name;
                        addressUser=address;
                        cityUser=city;
                        cityCapUser=cityCap;
                        mobileUser=mobile;
                        familyUser=family;
                    }
                });
                if (modelAddresses.isEmpty()){
                    cardPlaceHolder.setVisibility(View.VISIBLE);
                    recyclerViewAddress.setVisibility(View.GONE);
                }else {
                    recyclerViewAddress.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL,false));
                    recyclerViewAddress.setAdapter(adapterAddress);
                    recyclerViewAddress.hasFixedSize();
                }

            }
        });

        cardPlaceHolder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(),EditInformation.class);
                startActivity(intent);
            }
        });

        apiServices.CartReceived(progressWheel,token, new ApiServices.OnCartReceived() {
            @Override
            public void onReceived(List<ModelBasket> modelBaskets, int totalPrice) {
                AdapterBasket adapterBasket = new AdapterBasket(getActivity(),modelBaskets);
                recyclerViewProducts.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL,false));
                recyclerViewProducts.setAdapter(adapterBasket);
            }
        });
        cardOrder = view.findViewById(R.id.card_fragment_order);
        cardOrder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (addressUser == null || addressUser.equals("")){
                            Toast.makeText(getActivity(), "لطفا آدرس را جهت ارسال مرسوله انتخاب کنید" , Toast.LENGTH_SHORT).show();
                        }else {
                            FragmentManager fragmentManager = getFragmentManager();
                            FragmentOrderConfirmaton fragmentOrderConfirmaton = new FragmentOrderConfirmaton();
                            fragmentOrderConfirmaton.AddressInfo(nameUser,familyUser,addressUser,cityUser,cityCapUser,mobileUser);
                            FragmentTransaction transaction = Objects.requireNonNull(fragmentManager).beginTransaction();
                            transaction.replace(R.id.rel_root,fragmentOrderConfirmaton).addToBackStack("");
                            transaction.commit();
                        }

                    }
                },1000);

            }
        });
        return view;
    }

}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterProduct.java
package com.example.mybookstore.Adapters;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
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.ImageView;
import android.widget.TextView;

import com.example.mybookstore.Activities.ShowActivity;
import com.example.mybookstore.Models.ModelOff_Only_MostVisit;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.Links;
import com.example.mybookstore.Utils.Put;
import com.squareup.picasso.Picasso;

import java.text.DecimalFormat;
import java.util.List;

import jp.shts.android.library.TriangleLabelView;

public class AdapterProduct extends RecyclerView.Adapter<AdapterProduct.viewHolder> {

    private Context context;
    private List<ModelOff_Only_MostVisit> modelProduct;

    public AdapterProduct(Context context, List<ModelOff_Only_MostVisit> modelProduct) {
        this.context = context;
        this.modelProduct = modelProduct;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_show_product,viewGroup,false);
        return new viewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final viewHolder viewHolder, final int i) {

        DecimalFormat decimalFormat = new DecimalFormat("###,###");

        if (Integer.valueOf(modelProduct.get(i).getLable()) > 0){
            viewHolder.txtPrice.setText(decimalFormat.format(Float.valueOf(modelProduct.get(i).getOffPrice()))+" "+"تومان");
            viewHolder.txtVisit.setText(modelProduct.get(i).getVisit());
            viewHolder.txtTitle.setText(modelProduct.get(i).getTitle());
            viewHolder.triangleLabelView.setSecondaryText(modelProduct.get(i).getLable());
            Picasso.with(context)
                    .load(modelProduct.get(i).getImage())
                    .placeholder(R.drawable.placeholder)
                    .error(R.drawable.placeholder)
                    .into(viewHolder.imgOnly);
        }else {
            viewHolder.txtPrice.setText(decimalFormat.format(Integer.valueOf(modelProduct.get(i).getPrice()))+" "+"تومان");
            viewHolder.txtVisit.setText(modelProduct.get(i).getVisit());
            viewHolder.txtTitle.setText(modelProduct.get(i).getTitle());
            viewHolder.triangleLabelView.setVisibility(View.GONE);
            Picasso.with(context)
                    .load(modelProduct.get(i).getImage())
                    .placeholder(R.drawable.placeholder)
                    .error(R.drawable.placeholder)
                    .into(viewHolder.imgOnly);
        }

        viewHolder.cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(viewHolder.itemView.getContext(), ShowActivity.class);
                intent.putExtra(Put.id,modelProduct.get(i).getId()+"");
                intent.putExtra(Put.offPrice,modelProduct.get(i).getOffPrice());
                intent.putExtra(Put.cat,modelProduct.get(i).getCat());
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        });

    }

    @Override
    public int getItemCount() {
        return modelProduct.size();
    }

    class viewHolder extends RecyclerView.ViewHolder{

        CardView cardView;
        TriangleLabelView triangleLabelView;
        ImageView imgOnly;
        TextView txtTitle,txtVisit,txtPrice;

        viewHolder(@NonNull View itemView) {
            super(itemView);

            cardView=itemView.findViewById(R.id.cardview_product);
            triangleLabelView = itemView.findViewById(R.id.triangle_product);
            imgOnly = itemView.findViewById(R.id.img_product);
            txtTitle = itemView.findViewById(R.id.txt_title_product);
            txtPrice = itemView.findViewById(R.id.txt_price_product);
            txtVisit = itemView.findViewById(R.id.txt_visit_product);
        }
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/BannerActivity.java
package com.example.mybookstore.Activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mybookstore.Adapters.AdapterItemProduct;
import com.example.mybookstore.Models.ModelItemProduct;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.example.mybookstore.Utils.Put;

import java.util.List;

public class BannerActivity extends AppCompatActivity {

    private TextView txtTitle;
    private ImageView imgBackButton;
    private RecyclerView recyBannerItem;
    private ApiServices apiServices;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner);

        finViews();
        onClicks();
        initPage();

    }

    private void initPage() {
        String id = String.valueOf(getIntent().getIntExtra(Put.id,0));
        apiServices = new ApiServices(BannerActivity.this);
        apiServices.GetItemBanner(id, new ApiServices.OnItemBannerReceived() {
            @Override
            public void onItemReceived(List<ModelItemProduct> modelItemProducts) {
                AdapterItemProduct adapterItemProduct = new AdapterItemProduct(BannerActivity.this,modelItemProducts);
                recyBannerItem.setLayoutManager(new LinearLayoutManager(BannerActivity.this));
                recyBannerItem.setAdapter(adapterItemProduct);
                recyBannerItem.hasFixedSize();
            }
        });
    }

    private void finViews() {
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("محصولات");
        imgBackButton = findViewById(R.id.img_back_second_toolbar);
        recyBannerItem = findViewById(R.id.recycler_banner_item);
    }

    private void onClicks() {
        imgBackButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Activities/RegisterActivity.java
package com.example.mybookstore.Activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.mybookstore.R;
import com.example.mybookstore.Utils.ApiServices;
import com.pnikosis.materialishprogress.ProgressWheel;

public class RegisterActivity extends AppCompatActivity {
    EditText edUsername,edPassword;
    TextView txtTitle;
    CardView cardRegister;
    CheckBox checkBox;
    ImageView imgBack;
    ApiServices apiServices;
    ProgressWheel progressWheel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reg);

        findViews();
        onClicks();

    }

    private void onClicks() {
        imgBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    edPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                }else {
                    edPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
                }
            }
        });

        cardRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!edPassword.getText().toString().trim().equals("")&&!edUsername.getText().toString().trim().equals("")){
                    if (!(edPassword.getText().toString().trim().length() <4)){
                        String username=convertNumberToEnglish(edUsername.getText().toString().trim());
                        String password=convertNumberToEnglish(edPassword.getText().toString().trim());
//                        Toast.makeText(RegisterActivity.this, username, Toast.LENGTH_SHORT).show();
                        apiServices.registeWhitSMS(username,password,progressWheel);
                    }else{
                        edPassword.setError("پسورد حداقل باید چهار کاراکتر باشد");
                        edPassword.requestFocus();
                    }


                }else{
                    edUsername.setError("لطفا نام کاربری و پسورد را وارد کنید");
                    edPassword.setError("لطفا نام کاربری و پسورد را وارد کنید");
                    edUsername.requestFocus();
                }


            }
        });


    }

    private String convertNumberToEnglish(String num) {
        String d = num;
        d = d.replace("۰", "0");
        d = d.replace("۱", "1");
        d = d.replace("۲", "2");
        d = d.replace("٣", "3");
        d = d.replace("٤", "4");
        d = d.replace("۵", "5");
        d = d.replace("٦", "6");
        d = d.replace("٧", "7");
        d = d.replace("۸", "8");
        d = d.replace("۹", "9");

        d = d.replace("۰", "0");
        d = d.replace("۱", "1");
        d = d.replace("۲", "2");
        d = d.replace("۳", "3");
        d = d.replace("۴", "4");
        d = d.replace("۵", "5");
        d = d.replace("۶", "6");
        d = d.replace("۷", "7");
        d = d.replace("۸", "8");
        d = d.replace("۹", "9");

        return d;
    }

    private void findViews() {
        apiServices = new ApiServices(RegisterActivity.this);
        txtTitle = findViewById(R.id.txt_title_toolbar_second);
        txtTitle.setText("ثبت نام");
        cardRegister = findViewById(R.id.card_Register);
        progressWheel=findViewById(R.id.progress_wheel);
        edPassword = findViewById(R.id.ed_password);
        edUsername = findViewById(R.id.ed_phone);
        edUsername.requestFocus();
        imgBack = findViewById(R.id.img_back_second_toolbar);
        checkBox = findViewById(R.id.checkbox_reg);
    }
}
<file_sep>/app/src/main/java/com/example/mybookstore/Adapters/AdapterComment.java
package com.example.mybookstore.Adapters;

import android.content.Context;
import android.graphics.Typeface;
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.RatingBar;
import android.widget.TextView;

import com.example.mybookstore.Models.ModelComment;
import com.example.mybookstore.R;
import com.example.mybookstore.Utils.Links;
import com.squareup.picasso.Picasso;
import com.willy.ratingbar.ScaleRatingBar;

import java.lang.reflect.Type;
import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class AdapterComment extends RecyclerView.Adapter<AdapterComment.viewHolder> {
    Context context;
    List<ModelComment> modelComments;

    public AdapterComment(Context context, List<ModelComment> modelComments) {
        this.context = context;
        this.modelComments = modelComments;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_show_comments,viewGroup,false);
        return new viewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull viewHolder viewHolder, int i) {

        ModelComment comment = modelComments.get(i);

        viewHolder.txtUser.setText(comment.getUser());
        viewHolder.txtPositive.setText(comment.getPositive());
        viewHolder.txtNegative.setText(comment.getNegative());
        viewHolder.txtComment.setText(comment.getComment());
//
//        Picasso.with(context).load(comment.getImage())
//                .error(R.drawable.placeholder)
//                .placeholder(R.drawable.placeholder)
//                .into(viewHolder.circleImageView);
        viewHolder.ratingBar.setRating(comment.getRating());

    }

    @Override
    public int getItemCount() {
        return modelComments.size();
    }

    class viewHolder extends RecyclerView.ViewHolder{

        TextView txtComment,txtUser,txtPositive,txtNegative;
//        CircleImageView circleImageView;
        ScaleRatingBar ratingBar;

        viewHolder(@NonNull View itemView) {
            super(itemView);
            txtComment=itemView.findViewById(R.id.txt_commnet);
            txtNegative=itemView.findViewById(R.id.txt_negativeComment);
            txtPositive=itemView.findViewById(R.id.txt_posotiveComment);
            txtUser=itemView.findViewById(R.id.txt_usercomment);
//            circleImageView = itemView.findViewById(R.id.img_userComment);
            ratingBar = itemView.findViewById(R.id.rating_comment);
        }
    }
}
