0

In my app, which has tabbled activity with four tabs [ tab1 | tab2 | tab3 | tab4 ]. Pic shown is not of my app, but to get a feel how it might look similar to although there are differences as mentioned here.

enter image description here

  1. Each tab is associated with a fragment. Each fragment is list, either in vertical list or grid.
  2. Tab1 and Tab2 has list of similar objects(X), restaurants.
  3. Tab3 has different class object list (Y), friends.
  4. Tab4 has object list and each object is superset of object(X) + object (Y). Restaurants and my friends who visited there.
  5. Each of these tab content are different and obtained through RESTful http call.

Now, my query is:

  1. Should I put all view class, X, Y, X+Y in factory pattern?
  2. Should I put REST api call into observer pattern with callback on data receive?

Am I correct with this approach or should I chose different pattern to make things even improved?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Abhishek Dwivedi
  • 6,557
  • 3
  • 15
  • 20

1 Answers1

1

If you want apply any design pattern, I'm offer MVP pattern strategy: all your fragments are view, which are attached to Presenter. And the presenter call data layer(Repository, Data manager), get data and throw it into view, where it rendering in layout. As Rest Api library you can use Retrofit+okhttp3

Scrobot
  • 1,911
  • 3
  • 19
  • 36