I have an Android MVP project. I want to keep out any Android references out of the presenter. This way, I can keep UI separated in the Activity/View.
There is a ListView
in the Activity
which uses a custom ArrayList
in the adapter (MyAdapter
). This uses MyModel
objects to populate the ListView
with data.
Now, I'm trying to initialize the adapter and the ListView
.
By doing that on the activity I would end up with something like
`MyAdapter adapter = new MyAdapter<MyModel>(this, R.layout.list_item, items);`
The problem with this is that the Activity
now have access to the Model and has a reference to an ArrayList
of items which I wanted to keep only in the presenter and manage it from there.
I can't move setup the adapter on the Presenter because I would have to share the context from the Activity to the presenter, setup the adapter and pass it back to the Activity. The problem with this is that the presenter now depends on an Android context object (There shouldn't be any Android code in the Presenter part of an MVP Android project).
So the question is what do I do in this case? Where and how do I handle setting up the ArrayAdapter?