I've been having the following problem for days:
I'm using the PDFView library to load a PDF into my application.
Sometimes the PDF disappears, a white screen appears.
I've placed a TextView where I get and update the current PDF page.
And when I do the swiping to change the PDF page the TextView is updated even though the PDF does not appear.
I'm putting the PDF into a Fragment
I'm using the following code:
TextView txtPag;
PDFView pdfViewLe;
Integer pageNumberLe;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_le_livro, container, false);
SharedPreferences npaginaLe = getActivity().getSharedPreferences("PAGINALE", getActivity().MODE_PRIVATE);
txtPag=(TextView) view.findViewById(R.id.txtPag);
pdfViewLe=(PDFView) view.findViewById(R.id.pdfview);
if(npaginaLe.contains("pag")){
pageNumberLe=npaginaLe.getInt("pag", 1);
} else {
pageNumberLe=1;
}
txtPag.setText(pageNumberLe.toString());
pdfViewLe.fromAsset("le.pdf").defaultPage(pageNumberLe).showMinimap(false).enableSwipe(true).onPageChange(new OnPageChangeListener() {
@Override
public void onPageChanged(int i, int i2) {
pageNumberLe = i;
SharedPreferences npaginaLe = getActivity().getSharedPreferences("PAGINALE", getActivity().MODE_PRIVATE);
SharedPreferences.Editor editor = npaginaLe.edit();
editor.putInt("pag", pageNumberLe);
editor.commit();
txtPag.setText(pageNumberLe.toString());
}
}).load();
return view;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}