Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. /**
  2. * Custom Fragment implementation to bind basic elements and force the use of
  3. * the MVP pattern logically attaching a presenter to this Fragment.
  4. */
  5. public abstract class WoloxFragment<T extends BasePresenter> extends Fragment {
  6.  
  7. protected T mPresenter;
  8.  
  9. @Override
  10. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  11. Bundle savedInstanceState) {
  12. View v = inflater.inflate(layout(), container, false);
  13. mPresenter = createPresenter();
  14. setUi(v);
  15. init();
  16. populate();
  17. setListeners();
  18. return v;
  19. }
  20.  
  21. /**
  22. * Returns the layout id for the inflater so the view can be populated
  23. */
  24. protected abstract int layout();
  25.  
  26. /**
  27. * Loads the view elements for the fragment
  28. */
  29. protected abstract void setUi(View v);
  30.  
  31. /**
  32. * Initializes any variables that the fragment needs
  33. */
  34. protected abstract void init();
  35.  
  36. /**
  37. * Populates the view elements of the fragment
  38. */
  39. protected abstract void populate();
  40.  
  41. /**
  42. * Sets the listeners for the views of the fragment
  43. */
  44. protected abstract void setListeners();
  45.  
  46. /**
  47. * Create the presenter for this fragment
  48. */
  49. protected abstract T createPresenter();
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement