SHARE
TWEET

Untitled

a guest Sep 17th, 2019 98 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.     private AdapterView.OnItemClickListener itemClickListener;
  6.     public  PassengerDetailsIObserver mObserver;
  7.     private String name_passenger;
  8.     private int phone_no, seat_no;
  9.  
  10.  
  11.     public class ViewHolder extends RecyclerView.ViewHolder {
  12.         public TextView number_plate, amountCollected, no_of_passenger, rate, destination;
  13.         public CardView card_view1;
  14.         public RelativeLayout cardeye;
  15.         public ItemClickListener itemClickListener;
  16.         public ViewHolder(@NonNull View itemView, ItemClickListener itemClickListener) {
  17.             super(itemView);
  18.             number_plate.findViewById(R.id.number_plate);
  19.             amountCollected.findViewById(R.id.amountCollected);
  20.             no_of_passenger.findViewById(R.id.no_of_passengers);
  21.             rate.findViewById(R.id.rate);
  22.             destination.findViewById(R.id.destination);
  23.             card_view1.findViewById(R.id.card_view1);
  24.             cardeye.findViewById(R.id.cardeye);
  25.  
  26.             this.itemClickListener = itemClickListener;
  27.  
  28.  
  29.         }
  30.     }
  31.  
  32.     List<PassengerDetails>passengerDetails;
  33.  
  34.     public PaymentAdapter( ArrayList<Paymentdetails> paymentdetails){
  35.         this.paymentdetails = paymentdetails;
  36.  
  37.     }
  38.  
  39.     @NonNull
  40.     @Override
  41.     public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
  42.         final View view = LayoutInflater.from(context).inflate(R.layout.tripdetail, viewGroup, false);
  43.         return new ViewHolder(view, (ItemClickListener) itemClickListener);
  44.     }
  45.  
  46.     @Override
  47.     public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int position) {
  48.  
  49.     viewHolder.number_plate.setText((CharSequence) paymentdetails.get(position));
  50.         viewHolder.amountCollected.setText((CharSequence) paymentdetails.get(position));
  51.         viewHolder.no_of_passenger.setText((CharSequence) paymentdetails.get(position));
  52.         viewHolder.rate.setText((CharSequence) paymentdetails.get(position));
  53.         viewHolder.destination.setText((CharSequence) paymentdetails.get(position));
  54.  
  55.         name_passenger = passengerDetails.get(position).passenger_name;
  56.  
  57.         final int phone_no = position;
  58.         final int seat_no = position;
  59.  
  60.         viewHolder.cardeye.setOnClickListener(new View.OnClickListener() {
  61.             @Override
  62.             public void onClick(View v) {
  63.                 mObserver.onCardClicked(name_passenger, phone_no, seat_no);
  64.                 }
  65.         });
  66.  
  67.  
  68.     }
  69.  
  70.     @Override
  71.     public int getItemCount() {
  72.         return paymentdetails.size();
  73.     }
  74. //
  75. //    @Override
  76. //    public int getItemCount() {
  77. //        return paymentdetails.size();
  78. //    }
  79.  
  80.     public interface ItemClickListener {
  81.         void onItemOnClick(View view, int position);
  82.  
  83.         View.OnClickListener onItemOnClick();
  84.     }
  85.  
  86.  
  87. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top