-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ViewPager Adapters cleanup #2440
Comments
@nmilcoff |
@Qwin can you elaborate a bit more please? I've been browsing the source code but I don't fully get it. It looks like those adapters only provide getter methods for tags. |
@nmilcoff yes of course, if you look at MvxCachingFragmentPagerAdapter.cs you will see this : Anyways the |
@nmilcoff I noticed even though we are adding the Tag in the custom implementation (caching classes), it would still require some work on the: MvxAppCompatViewPresenter.cs I would suggest the following happens if we want to do a good job at removing the Caching classes:
Considering I am running into this issue anyways currently I might rewrite the MvxAppCompatViewPresenter to support it and do a PR. |
So I think @nmilcoff based on what I have seen so far is that we need do need to override the InstantiateItem for both MvxFragmentStatePagerAdapter and MvxFragmentPagerAdapter and call ourselves the GetItem as well and set a default tag on it like so: This will cause each added fragment to have at least a default Tag and when people want to override that Tag they can by overriding the GetTag method. Also looking at the presenter I already implemented a way to support ChildFragmentManager (recursive) like so (this will search the hierarchie for the right Tag on a Fragment and can then handle setting it on the view, so we would need to add this to both presenters in Android) : I tested the code and it works as expected. |
@Qwin you are on the right track i think! Can you make a PR so we can test this? |
@martijn00 will do :) |
@Qwin based on your work on #2482 what are we missing to remove the caching adapters? From your previous comment looks like this is still necessary:
|
@nmilcoff @martijn00 is this still going to make it into 6.0, or can we push to 6.1? |
To reiterate what @Qwin said about fragment tags, I have just encountered this issue after switching from 4.4.0 to 5.7.0 and stopping to use caching pager adapter. My scenario is as follows:
If my tags were used, these view model instances would have been stored under different tags and cache would safely store / get and clear twice. |
@nickrandolph we should take the chance to work on this for v6, as it involves a breaking change. |
@nmilcoff are we able to generate a PR that demonstrates this issue in the playground, so we can get this issue resolved |
I've been digging more about this and it seems to me the most reasonable way to cleanup our adapters might be to keep the To avoid this we would need to fully override the behavior of We must then modify the Android ViewPresenters to support the nesting scenario better, but that's another step. What do you people think about this? (cc: @Qwin @wh1t3cAt1k) |
@nmilcoff is this completed now, or is there more work to be done? |
Well... I would like to have only two ViewPager adapters and not four, but that doesn't bring any actual value to our users - and it is a breaking change. So I would say we can schedule it for the next major version. |
Description 📜
We currently expose four ViewPager Fragment Adapters:
It looks like the ones with the word "Caching" are there because in 2014 there was an issue with the adapters provided by the Android SDK.
Maybe it's time to remove them?
Expected behavior 🤔
We should expose only two ViewPager adapters.
Actual behavior 🐛
We are exposing too many ViewPager adapters
Configuration 🔧
Version: 5.x
Platform:
The text was updated successfully, but these errors were encountered: