Advertisement
vmeansdev

MVPContract

Sep 24th, 2019
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. // его можно положить в ../presentation/contract
  2.  
  3. public interface PhotosContract {
  4.  
  5.     interface Model {
  6.         // Presenter -> Model
  7.         void loadPhotos(Integer page);
  8.     }
  9.  
  10.     interface View {
  11.         // Presenter -> View
  12.         void displayPhotos(List<Photo> photos);
  13.         void displayError();
  14.     }
  15.  
  16.     interface Presenter {
  17.         // View -> Presenter
  18.         void onViewCreated();
  19.         void loadNextPhotos();
  20.         void onViewDestroyed();
  21.        
  22.         // Model -> Presenter
  23.         void onPhotosLoaded(List<Photo> photos);
  24.         void onLoadFailure();
  25.     }
  26.  
  27. }
  28.  
  29.  
  30. ...
  31.  
  32. class UnsplashService implements PhotosContract.Model {
  33.  
  34.     private PhotosContract.Presenter presenter;
  35.  
  36.     ...
  37.  
  38. }
  39.  
  40. class WPFragment extends Fragment implements PhotosContract.View {
  41.  
  42.     private PhotosContract.Presenter presenter;
  43.  
  44.     ..
  45.  
  46. }
  47.  
  48. class PhotosPresenter implements PhotosContract.Presenter {
  49.  
  50.     private PhotosConract.Model model;
  51.     private PhotosContract.View view;
  52.  
  53.     ...
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement