• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which method runs when fragment gone from visible in view pager

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used android-pdfview library to view pdf files in my view pager.It loads pdf file clearly in first fragment.For 2nd fragment it doesn't load pdf file.below is the code




This is my fragment




There is no any errors .But it load pdf files for only one page.for 2nd page it loads a blank page.I used the below library for this example. android-pdfview
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is the 2nd fragment of a different class? Is it not supposed to do the same thing as the 1st fragment?
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok ULF.I change the code.Both classes have same code.Now code is as below.

[code=java] private List<Fragment> getFragments(){

List<Fragment> fList = new ArrayList<Fragment>();
fList.add(MyFragment.newInstance("Fragment 1"));
fList.add(MyFragment.newInstance("Fragment 2"));
//fList.add(MyFragment.newInstance("Fragment 3"));

return fList;
}/code]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And?
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still same result ULF?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that a question? Just asking because of the question mark. Also, you need to drop the habit of writing names in all uppercase; it looks like you're shouting.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for inconvenience ulf. I am still struggling with this pdf thing.I don't know why it is not visible the other pdf file.But i didn't close the pdf from fragment.That may be the issue.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what it means to "close the pdf"; the documentation of the PDF library would/should presumably talk about that.

Have you tried loading a different PDF instead of the same one for all fragments? That would presumably be the point of using fragments in the first place.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Close mean ulf when it laod the pdf from the first fragment i don't remove it from the layout.I guess it may be the problem.by the way yes ulf,I tried with different pdf files.same issues occur.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Removing from layout? You should not mess with the fragments, that's the ViewPager's job. Of course your code should do whatever the PDF library requires it to do for handling PDF documents' lifecycle (if it does, in fact, require it to do anything).
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whether other page is a blank one it seems that it loads the pdf file ,but it is not visible the pdf file.Because when i try to zoom the blank page it is getting zoom.But it doesn't show the pdf file.I added 4 fragments to view pager.Then i goes to until last page.Then i try to come back.Then i see the pdf file is open on the the fragment before last one(3rd).Then i moved to first page and move forward again.Now i see the pdf file is open in 2nd fragment.I don't how it happen.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the PDFView isn't fully aware of being part of a ViewPager, or possibly doesn't interact well with it.

Do you even need a ViewPager? It looks like the PDFView has a "swipe" feature built in.

Also be aware that the library uses the GPL license; you will need to make the full source code of the app available to anyone using it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic