Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.
Joris Blaak edited this page Oct 27, 2015 · 4 revisions

Every screen in an application that uses Triad has one or multiple classes extending the Screen class. This class defines which layout to use, and creates the Presenter for the screen:

public class MyScreen extends Screen<ApplicationComponent> {

  @Override
  protected int getLayoutResId() {
    return R.layout.view_my;
  }

  @NonNull
  @Override
  protected Presenter<?, ?> createPresenter(@NonNull final Class<? extends Presenter<?, ?>> presenterClass) {
    if (presenterClass.equals(MyPresenter.class)) {
      return new MyPresenter();
    }

    throw new AssertionError("Unknown presenter class: " + presenterClass.getCanonicalName());
  }
}

The Layout

The layout file should have the used View class as its root. For more information, see the View page.

Creating the Presenter

The Presenter instance created in createPresenter(...) is a singleton instance in the screen scope, making it survive orientation changes. For more information, see the Presenter page.

Presenter dependencies

Naturally, a Presenter class may have dependencies that need to be passed into its constructor. The user-defined application component class provides a way to deliver these dependencies. For more information, see the Application Component page.

Clone this wiki locally