Problems with Lib Pdfview

Asked

Viewed 39 times

0

I’ve had the following problem for days:

I am using the Pdfview library to upload a PDF to my application.

https://github.com/JoanZapata/android-pdfview

Sometimes the PDF disappears, becomes a white screen.

I put a Textview where I pick up and update the current PDF page.

And when I swiping to change the PDF page Textview is updated even if the PDF does not appear.

I’m uploading the PDF to 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);
}
  • Has anyone ever experienced this problem ? ?

  • Because no one helps me solve this question ? I put the question very clearly. I put source code for what I’ve already done. Why ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.