I am getting/ downloading the encoded base64 string through api, Now I have to decoding it to base 64, and then after decoding the base64 string, I need to convert it as pdf file.so that when I click the downloading button it will give me the converted decoding base64 as PDF.
Code:
Context context;
List<BillReceiptReport> list;
UtilityBillManager manager;
String encodedBase64 = "";
public BillReportDetailsAdapter(Context context, List<BillReceiptReport> list) {
this.context = context;
this.list = list;
}
@Override
public BillReportDetailsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new BillReportDetailsViewHolder(LayoutInflater.from(context).inflate(R.layout.transaction_reports_details_item_layout, parent, false));
}
@Override
public void onBindViewHolder(@NonNull BillReportDetailsViewHolder holder, int position) {
BillReceiptReport billReceiptReport = list.get(position);
holder.downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager = new UtilityBillManager(context, AppBaseController.get().getUserSettings());
manager.UserTransactionReceiptReport(listener,billReceiptReport); //UserTransactionReceiptReport is the api where i get the base64 string from server.
}
});
}
private final TransactionReportListener listener = new TransactionReportListener() {
@Override
public void didFetch(String response, String message) {
encodedBase64 = response;
//Log.e("tag",encodedBase64);
byte [] decodeBase64 = android.util.Base64.decode(encodedBase64, Base64.DEFAULT);
// Now i have the decoded base64 string, Now i need to showing it as pdfview.
}
@Override
public void didError(String message) {
}
};
I think now my question is understanding to you