Advertisement
ricky_yulianto

Untitled

May 15th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. package codelabs.ambarrukmo.adapter;
  2.  
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.support.v4.app.DialogFragment;
  7. import android.support.v4.app.Fragment;
  8. import android.support.v4.app.FragmentActivity;
  9. import android.support.v4.app.FragmentManager;
  10. import android.support.v4.app.FragmentTransaction;
  11. import android.support.v4.content.ContextCompat;
  12. import android.support.v7.app.AppCompatActivity;
  13. import android.support.v7.widget.RecyclerView;
  14. import android.view.LayoutInflater;
  15. import android.view.View;
  16. import android.view.ViewGroup;
  17. import android.widget.TextView;
  18.  
  19. import com.google.gson.annotations.Expose;
  20. import com.google.gson.annotations.SerializedName;
  21.  
  22. import java.util.ArrayList;
  23. import java.util.List;
  24.  
  25. import butterknife.BindView;
  26. import butterknife.ButterKnife;
  27. import codelabs.ambarrukmo.R;
  28. import codelabs.ambarrukmo.activity.PaymentMethodActivity;
  29. import codelabs.ambarrukmo.activity.StoreDetailActivity;
  30. import codelabs.ambarrukmo.fragment.MapDialogFragment;
  31. import codelabs.ambarrukmo.fragment.QrCodeMenuFragment;
  32. import codelabs.ambarrukmo.fragment.ShoppingCartFragment;
  33. import codelabs.ambarrukmo.fragment.ValletBarcodeFragment;
  34. import codelabs.ambarrukmo.model.GetHistoryVallet;
  35. import codelabs.ambarrukmo.model.GetValletNumber;
  36. import codelabs.ambarrukmo.utils.RecentUtils;
  37.  
  38. import static codelabs.ambarrukmo.utils.RecentUtils.setStatusColor;
  39.  
  40. public class HistoryValletAdapter extends RecyclerView.Adapter<HistoryValletAdapter.MyViewHolder> {
  41.  
  42.  
  43. private Context mContext;
  44. private List<GetHistoryVallet.DATABean> mData = new ArrayList<>();
  45. public HistoryValletAdapter(Context context) {
  46. this.mContext = context;
  47. }
  48.  
  49.  
  50.  
  51. public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  52. View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_history_valley, parent, false);
  53. return new MyViewHolder(view);
  54.  
  55. }
  56.  
  57. @Override
  58. public void onBindViewHolder(MyViewHolder holder, final int position) {
  59.  
  60. holder.tvStatusValley.setText(mData.get(position).getStatus_txt());
  61. // if (mData.get(position).getStatus_txt().toLowerCase().equals("Completed")){
  62. // holder.tvStatusValley.getResources().getColor(R.color.green);
  63. // }else if (mData.get(position).getStatus_txt().toLowerCase().equals("Booked")){
  64. // holder.tvStatusValley.getResources().getColor(R.color.red);
  65. // }else
  66. // holder.tvStatusValley.getResources().getColor(R.color.blue);
  67. holder.tvNoValley.setText(mData.get(position).getVallet_number());
  68. holder.tvCarType.setText(mData.get(position).getCar_brand());
  69. holder.tvCarColor.setText(mData.get(position).getCar_color());
  70. holder.tvDateHistoryValley.setText(mData.get(position).getParking_date_in());
  71. holder.tvNumbCar.setText(mData.get(position).getNo_pol());
  72. holder.tvTimeVallet.setText(mData.get(position).getParking_date_out());
  73.  
  74.  
  75. }
  76.  
  77.  
  78.  
  79. public void setData(List<GetHistoryVallet.DATABean> items) {
  80. this.mData = items;
  81. notifyDataSetChanged();
  82. }
  83.  
  84. public void addData(List<GetHistoryVallet.DATABean> items) {
  85. mData.addAll(items);
  86. notifyDataSetChanged();
  87. }
  88.  
  89. @Override
  90. public int getItemCount() {
  91. return mData.size();
  92. }
  93.  
  94. public class MyViewHolder extends RecyclerView.ViewHolder {
  95. @BindView(R.id.tv_no_valley)
  96. TextView tvNoValley;
  97. @BindView(R.id.tv_status_valley)
  98. TextView tvStatusValley;
  99. @BindView(R.id.tv_car_type)
  100. TextView tvCarType;
  101. @BindView(R.id.tv_car_color)
  102. TextView tvCarColor;
  103. @BindView(R.id.tv_date_history_valley)
  104. TextView tvDateHistoryValley;
  105. @BindView(R.id.tv_numb_car)
  106. TextView tvNumbCar;
  107. @BindView(R.id.tv_time_history_valley)
  108. TextView tvTimeVallet;
  109.  
  110.  
  111.  
  112. public MyViewHolder(View itemView) {
  113. super(itemView);
  114. ButterKnife.bind(this, itemView);
  115.  
  116.  
  117. itemView.setOnClickListener(new View.OnClickListener() {
  118. @Override
  119. public void onClick(View v) {
  120.  
  121.  
  122.  
  123.  
  124. ValletBarcodeFragment fragment = new ValletBarcodeFragment();
  125. FragmentTransaction transaction = ((FragmentActivity)mContext).getSupportFragmentManager().beginTransaction();
  126. transaction.replace(R.id.fragment_container, fragment);
  127. transaction.commit();
  128.  
  129. // Intent intent = new Intent(mContext, PaymentMethodActivity.class);
  130. //// intent.putExtra(StoreDetailActivity.DETAIL_IMAGE, mItems.get(getAdapterPosition()).brandLogo);
  131. //// intent.putExtra("query_param","brand_id");
  132. //// intent.putExtra("value_param",mItems.get(getAdapterPosition()).brandId);
  133. // mContext.startActivity(intent);
  134.  
  135.  
  136.  
  137.  
  138. }
  139. });
  140.  
  141. }
  142. }
  143.  
  144.  
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement