Issue/3858 plans adapter refactor #3861
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #3858 - simplifies and optimizes the ViewPager adapter used by plans. Rather than being passed a list of fragments in the constructor and then holding on to them, we instead pass a list of site plans and let the FragmentPagerAdapter handle fragment creation/destruction/restoration.
I also moved the adapter out of the activity, which wasn't entirely necessary but it prevents some of the coupling seen in other areas of the app where a ViewPager is used.
I think this adapter was originally based off code used elsewhere in the app, where it was necessary to retain the list of fragments. But here it isn't needed.
Needs review: @daniloercoli