Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. @Singleton
  2. @Component(modules = {ContextModule.class,
  3.         MediaPlayerModule.class,
  4.         RxBusModule.class,
  5.         DataModule.class,
  6.         SocialModule.class})
  7. public interface ApplicationComponent {
  8.     Context getContext();
  9.     RxBus getRxBus();
  10.     MediaPlayer getMediaPlayer();
  11.  
  12.     ComplexScreensComponent plus(ComplexScreensModule complexScreensModule);
  13.  
  14.     void inject(MainActivity mainActivity);
  15.     void inject(MainFragment mainFragment);
  16.     void inject(MainPresenter mainPresenter);
  17. ......
  18. }
  19.  
  20.  
  21. @Subcomponent(modules = {ComplexScreensModule.class})
  22. @ActivityScope
  23. public interface ComplexScreensComponent {
  24.     void inject(FeaturedFragment featuredFragment);
  25.     void inject(FeaturedPresenter featuredPresenter);
  26.  
  27.     void inject(PopularFragment popularFragment);
  28.     void inject(PopularPresenter popularPresenter);
  29. ....
  30. }
  31.  
  32. @Scope
  33. @Retention(RetentionPolicy.RUNTIME)
  34. public @interface ActivityScope {
  35. }
  36.  
  37.  
  38.  
  39. @Module
  40. public class ComplexScreensModule {
  41.     private Activity mActivity;
  42.  
  43.     public ComplexScreensModule() {}
  44.  
  45.     public ComplexScreensModule(Activity activity) {
  46.         mActivity = activity;
  47.     }
  48.  
  49.     @Provides
  50.     @ActivityScope
  51.     public Activity providesActivity() {
  52.         return mActivity;
  53.     }
  54.  
  55.     @Provides
  56.     @ActivityScope
  57.     FeaturedAdapter providesFeaturedAdapter(Activity activity) {
  58.         return new FeaturedAdapter(activity);
  59.     }
  60.  
  61.     @Provides
  62.     @ActivityScope
  63.     FeaturedPresenter providesFeaturedPresenter() {
  64.         return new FeaturedPresenter();
  65.     }
  66. ....
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement