UpdatableFragmentStatePagerAdapter icon indicating copy to clipboard operation
UpdatableFragmentStatePagerAdapter copied to clipboard

Add commit to method destroyItem

Open VladTE opened this issue 7 years ago • 2 comments

Hi Daniel,

Should you not commit the remove transaction on destroyItem method overriden ?

I mean from : mCurTransaction.remove(fragment);

to

mCurTransaction.remove(fragment).commit();

at line 124 of UpdatableFragmentPagerAdapter class.

I am having a problem that after onSave/Restore instance of the viewpager, some fragment remain on the memory and are reused even after I create a new adapter... So, every time I put the app on background and then on foreground, the number of the instances of the used fragment from getSupportFragmentManager().getFragments() increases with 2 (I use one OffscreenPageLimit).

Thanks!

VladTE avatar Jun 13 '18 15:06 VladTE

@VladTE sorry for the late reply, commit is called inside finishUpdate() 🤔 ... Can you maybe make a sample project where we can isolate the issue and fix it?

DanielNovak avatar Jul 03 '18 06:07 DanielNovak

Hi @DanielNovak !

Ok, this cold be the problem. The number of the fragments always increases after a background-foreground switch of the app, and the method has this warning : "This is dangerous because the commit can be lost if the activity needs to later be restored from its state". Right now I don't have time to invest on this, but when I get the chance, I will make a new project to find a solution for my problem.

Thanks, VladTE

VladTE avatar Jul 03 '18 07:07 VladTE