I have a document in the Firebase storage. I want to open that document and display it using an alert dialog and a PDFView from the pdf-viewer:2.8.2 library. This doesen't work when the setPositiveButton is clicked. Any ideas on what I might be doing wrong? This is the code am writing.
holder.postDocument.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.AlertDialog);
builder.setTitle("Open the document?");
builder.setPositiveButton("Open", new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, int which) {
final PDFView pdfView = new PDFView(mContext, null);
pdfView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
pdfView.fromAsset(post.getPostdocument());
pdfView.loadPages();
builder.setView(pdfView);
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
}
});