Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public interface ViewContract {
  2. void setupContentList(ArrayList<MyModel> list);
  3. }
  4.  
  5. public interface PresenterContract {
  6. void onViewCreated();
  7. }
  8.  
  9. public class MainActivity extends Activity implements ViewContract {
  10.  
  11. @Override
  12. protected void onCreate(@Nullable Bundle savedInstanceState) {
  13. super.onCreate(savedInstanceState);
  14.  
  15. ......
  16. mListView = findViewById(R.id.listview);
  17. mPresenter.onViewCreated();
  18. }
  19.  
  20. public void setupContentList(ArrayList<MyModel> list) {
  21. MyAdapter adapter = new MyAdapter<MyModel>(this, R.layout.list_item, items);
  22. mListView.setAdapter(adapter);
  23. }
  24. }
  25.  
  26. public class Presenter implements PresenterContract {
  27.  
  28. public Presenter() {
  29. ArrayList<MyModel> mItems = new ArrayList();
  30. // Add items to the list
  31. }
  32.  
  33. public void onViewCreated() {
  34. mView.setupContentList(mItems);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement