Advertisement
ricky_yulianto

Untitled

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