I am using an Android app with what, in my opinion, is passive MVP.
So, for example, in my class class I have a ListView.
View
ListView userListView;
and when the element is clicked, I just call the method on the presenter
userListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mPresenter.onUserSelected(position); } });
The part I'm confused with is that ListView requires an adapter.
Presenter
So, my host currently has the following:
private ArrayList<User> mUserList = new ArrayList<User>();
...
adapter = new UserListAdapter(getContext(), mUserList); mView.setUserListAdapter(adapter);
and when I want to change something, I do this:
mUserList.add(user); adapter.notifyDataSetChanged();
Is this a suitable place for an adapter? The reason I'm asking for is because I recently looked for work with a swing, and a similar problem occurs, JLists need a ListModel that seems pretty similar. So, for the swing, where should the ListModel be?
source share