SHARE
TWEET

Untitled

a guest Sep 20th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHolder> {
  2.  
  3.     private Context context;
  4.     private ArrayList<Paymentdetails> paymentdetails;
  5.     public  PassengerDetailsIObserver mObserver;
  6.     private OnItemCLickListener onItemCLickListener;
  7.  
  8.  
  9.     private String numberplate_tapped;
  10.     private String amount_tapped;
  11.    
  12.     public interface OnItemCLickListener{
  13.         void onItemClicked(int position);
  14.     }
  15.  
  16.  
  17.     public class ViewHolder extends RecyclerView.ViewHolder{
  18.         public TextView number_plate, amountCollected, no_of_passenger, rate, destination;
  19.         public CardView  cardtouch;
  20.  
  21.  
  22.  
  23.         public ViewHolder(@NonNull View itemView, OnItemCLickListener onItemCLickListener) {
  24.             super(itemView);
  25.             number_plate.findViewById(R.id.number_plate);
  26.             amountCollected.findViewById(R.id.amountCollected);
  27. //            no_of_passenger.findViewById(R.id.no_of_passengers);
  28. //            rate.findViewById(R.id.rate);
  29.             destination.findViewById(R.id.destination);
  30.             cardtouch.findViewById(R.id.cardtouch);
  31.            
  32.  
  33.         }
  34.  
  35.     }
  36.  
  37.  
  38.  
  39.     public PaymentAdapter( Context context, ArrayList <Paymentdetails> paymentdetails, OnItemCLickListener onItemCLickListener){
  40.         this.paymentdetails = paymentdetails;
  41.         this.context = context;
  42.         this.onItemCLickListener = onItemCLickListener;
  43.  
  44.     }
  45.  
  46.     @Override
  47.     public void onAttachedToRecyclerView(RecyclerView recyclerView) {
  48.         super.onAttachedToRecyclerView(recyclerView);
  49.  
  50.     }
  51.  
  52.     @NonNull
  53.     @Override
  54.     public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
  55.         final View view = LayoutInflater.from(context).inflate(R.layout.tripdetail, viewGroup, false);
  56.         return new ViewHolder(view, onItemCLickListener);
  57.     }
  58.  
  59.     @Override
  60.     public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int position) {
  61.  
  62.     viewHolder.number_plate.setText((CharSequence) paymentdetails.get(position));
  63.         viewHolder.amountCollected.setText((CharSequence) paymentdetails.get(position));
  64.         viewHolder.no_of_passenger.setText((CharSequence) paymentdetails.get(position));
  65.         viewHolder.rate.setText((CharSequence) paymentdetails.get(position));
  66.         viewHolder.destination.setText((CharSequence) paymentdetails.get(position));
  67.  
  68.         numberplate_tapped = paymentdetails.get(position).getNumber_plate();
  69.         amount_tapped = paymentdetails.get(position).getAmount();
  70.  
  71.  
  72.  
  73.         final int posi = position;
  74.  
  75.         viewHolder.cardtouch.setOnClickListener(new View.OnClickListener() {
  76.             @Override
  77.             public void onClick(View v) {
  78.                 mObserver.onCardClicked(posi, numberplate_tapped);
  79.             }
  80.         });
  81.  
  82.     }
  83.  
  84.     @Override
  85.     public int getItemCount() {
  86.         return paymentdetails.size();
  87.     }
  88.  
  89. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top