TubeLab-App-Android/app/src/google_donation/java/app/fedilab/fedilabtube/fragment/MySubscriptionDonationsFrag...

81 lines
2.7 KiB
Java
Raw Normal View History

2021-01-05 17:26:21 +01:00
package app.fedilab.fedilabtube.fragment;
/* 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.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
2021-01-06 19:23:44 +01:00
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.SkuDetails;
2021-01-05 17:26:21 +01:00
2021-01-07 17:39:47 +01:00
import java.util.HashMap;
2021-01-05 17:26:21 +01:00
import java.util.List;
import app.fedilab.fedilabtube.databinding.FragmentMyDonationsBinding;
import app.fedilab.fedilabtube.drawable.DonationHistoryAdapter;
2021-01-06 19:23:44 +01:00
public class MySubscriptionDonationsFragment extends Fragment {
2021-01-05 17:26:21 +01:00
private FragmentMyDonationsBinding binding;
private View rootView;
private Context context;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentMyDonationsBinding.inflate(LayoutInflater.from(context));
rootView = binding.getRoot();
context = getContext();
binding.loader.setVisibility(View.VISIBLE);
binding.lvPurchases.setVisibility(View.GONE);
return rootView;
}
2021-01-07 17:39:47 +01:00
public void initialized(List<SkuDetails> skuDetailsList, HashMap<String, Purchase> map, BillingClient bc) {
2021-01-05 17:26:21 +01:00
binding.loader.setVisibility(View.GONE);
binding.lvPurchases.setVisibility(View.VISIBLE);
2021-01-06 19:23:44 +01:00
2021-01-07 17:39:47 +01:00
DonationHistoryAdapter donationHistoryAdapter = new DonationHistoryAdapter(skuDetailsList, map, bc);
2021-01-05 17:26:21 +01:00
binding.lvPurchases.setAdapter(donationHistoryAdapter);
binding.lvPurchases.setLayoutManager(new LinearLayoutManager(context));
2021-01-06 19:23:44 +01:00
2021-01-05 17:26:21 +01:00
}
@Override
public void onDestroyView() {
super.onDestroyView();
rootView = null;
}
@Override
public void onCreate(Bundle saveInstance) {
super.onCreate(saveInstance);
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
this.context = context;
}
}