TubeLab-App-Android/app/src/google_donation/java/app/fedilab/fedilabtube/drawable/DonationHistoryAdapter.java

82 lines
2.7 KiB
Java

package app.fedilab.fedilabtube.drawable;
/* Copyright 2021 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.SkuDetails;
import java.util.List;
import app.fedilab.fedilabtube.databinding.DrawerMyDonationBinding;
public class DonationHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<SkuDetails> skuDetailsList;
private final BillingClient billingClient;
private Context context;
public DonationHistoryAdapter(List<SkuDetails> SkuDetailsList, BillingClient billingClient) {
this.skuDetailsList = SkuDetailsList;
this.billingClient = billingClient;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
DrawerMyDonationBinding itemBinding = DrawerMyDonationBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new ViewHolder(itemBinding);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
final ViewHolder holder = (ViewHolder) viewHolder;
SkuDetails skuDetails = skuDetailsList.get(position);
holder.binding.productTitle.setText(skuDetails.getTitle());
holder.binding.productName.setText(skuDetails.getDescription());
holder.binding.productInfo.setText(skuDetails.getOriginalPrice());
holder.binding.cancelDonation.setOnClickListener(v -> {
});
}
@Override
public int getItemCount() {
return skuDetailsList.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
DrawerMyDonationBinding binding;
ViewHolder(DrawerMyDonationBinding itemView) {
super(itemView.getRoot());
binding = itemView;
}
}
}