3

I'm overhelmed trying to find an optimal way to manage the contents of recyclerviews that are in fragments, which are managed by an ViewPager with PagerAdapter.

Currently, my Application class has a complete list of objects, acting as a singleton, my viewpager act as an filter, each page is a category of those items, I have three ideas to implement:

1 - Create an enum types of categories, and when i instantiate the fragment i pass the type of category in the bundle, and within the fragment I do a switch on enums to filter the items (which i will fetch from the application) based on the received category in the bundle fragment.

2 - I could send the whole list as parcelable to fragment, but the lists are large and time-consuming to create the fragments.

3 - Use the OttoBus to produce the filtered items, so the activity I will have a method annotated with @Produce and it generates an Event with itens inside fetched from Application class, and in that event I will have a method that takes an enum value as parameter and based on this enum value it filters and returns the list of items.

My question is, what the pros and cons of making these 3 ways?

Yuri Heupa
  • 1,198
  • 3
  • 10
  • 35

0 Answers0