| Mark M. | has entered the room |
| Jun 4 | 3:55 PM |
| Mark M. | turned on guest access |
| Suleyman O. | has entered the room |
| Suleyman O. |
Hi Mark!
|
| Jun 4 | 4:00 PM |
| Mark M. |
hello, Suleyman!
|
| Mark M. |
how can I help you today?
|
| Suleyman O. |
So I have a question about fragment state management :D
|
| Suleyman O. |
View paste
|
| Mark M. |
I can't say if it is the best, but for a small number of fragments, hide/show is not unreasonable
|
| Mark M. |
and bottom navigation can only hold so many buttons, so presumably you will not have that many fragments participating in this system
|
| Mark M. |
a SparseArray seems like overkill -- that is for thousands of entries, and if you have thousands of fragments... you are going to have issues :-)
|
| Mark M. |
beyond that, make sure the fragments are relatively lightweight
|
| Mark M. |
both in terms of view-level stuff and in terms of any per-fragment viewmodels
|
| Jun 4 | 4:05 PM |
| Suleyman O. |
Yep, only 4, I guess I went overboard with Sparse Array, will probably use an array. As for the fragments, they are quite lightweight I think, but I believe there would be a noticeable spike in memory if they weren't?
|
| Mark M. |
if you mean in terms of things like the Android Studio memory profiler, yes
|
| Suleyman O. |
View paste
|
| Mark M. |
not really
|
| Mark M. |
that is what FragmentPagerAdapter does for use with a ViewPager
|
| Mark M. |
in that case, the problems start to crop up with lots of pages, which is why there is FragmentStatePagerAdapter
|
| Mark M. |
you will not have that many pages
|
| Mark M. |
(or the bottom nav equivalent of "pages")
|
| Jun 4 | 4:10 PM |
| Suleyman O. |
Yep, that is true, I tried implementing it using a ViewPager and disabling the swipe gesture, but it didn't sit well with my SharedElementTransitions :D
|
| Jun 4 | 4:10 PM |
| Mark M. |
so, overall, your approach should be fine
|
| Suleyman O. |
Perfect, thank you very much Mark, that was very helpful, I needed some assurance as usual :D
|
| Mark M. |
you're welcome!
|
| Suleyman O. |
Have a great evening and I'll see you later!
|
| Mark M. |
have a pleasant evening!
|
| Jun 4 | 4:30 PM |
| Suleyman O. | has left the room |
| Jun 4 | 5:00 PM |
| Mark M. | turned off guest access |