JavaScript is disabled on your browser.
Skip navigation links
  • Summary:
  • Field |
  • Required |
  • Optional
  • Detail:
  • Field |
  • Element
easymvp.annotation

Annotation Type Presenter



  • @Retention(value=RUNTIME)
     @Target(value=FIELD)
    public @interface Presenter
    Annotation to inject the presenter that already defined in a ActivityView.presenter(), a FragmentView.presenter() or a CustomView.presenter().

    It must be applied into the view implementation classes (Activity, Fragment or Custom View), otherwise it won't work.

    You have access to the presenter instance after super call in Activity.onCreate(Bundle), Fragment.onActivityCreated(Bundle) and View.onAttachedToWindow() methods. Also during configuration changes, same instance of presenter will be injected.

    Here is an example:

     @FragmentView(presenter = MyPresenter.class)
     public class MyFragment extends Fragment{
     @Presenter
     MyPresenter presenter;
     }
     public class MyPresenter extends AbstractPresenter<MyView>{
     public MyPresenter(){
     }
     }
     interface MyView{
     }
     

    By default you can't pass any objects to the constructor of presenters, but you can use Dagger to inject presenters.

    Here is an example of using dagger:

     @FragmentView(presenter = MyPresenter.class)
     public class MyFragment extends Fragment{
     @Inject
     @Presenter
     MyPresenter presenter;
     @Override
     void onCreate(Bundle b){
     SomeComponent.injectTo(this);
     }
     }
     public class MyPresenter extends AbstractPresenter<MyView>{
     public MyPresenter(){
     }
     }
     interface MyView{
     }
     
Skip navigation links
  • Summary:
  • Field |
  • Required |
  • Optional
  • Detail:
  • Field |
  • Element

AltStyle によって変換されたページ (->オリジナル) /