Hi I have a adapter which displays the list of items and all the functions related to setItems, getCount, notifyDataSetChanged.
adapter also has calls to api's through use cases.
Structure is
Adapter -> UseCase -> Repository -> apiLayer
I am aware that fragemnts and activities should not contains calls to api (usecases in my instance).
So should adapter's have api calls (usecases in my instance)
Thanks R
It is possible, but from a software design point of view I would not recommend it.
The
Adapter's responsibility is to connect yourDatawith theViewand make it available to theListView/RecyclerView. The Adapter should not have any other dependency (knowledge). This will also make it more robust to changes.So you should consider that only the Activity/Fragment talks to your Presenter and delegates the results from the Presenter to the Adapter. This will also make (unit) testing (of the Presenter) more easier.