Skip to content
Jack Malpo edited this page Jan 30, 2017 · 1 revision

##Router Routers are fairly self-evident: they route to an external Host Component (Activity), or they transition Fragments. If a view on the screen needs to change, the Interactor communicates this to the Router, and the Router makes it happen.

For example, say after clicking the "Done" button, you want to navigate to the next Activity. The View handles the click event, which goes down the chain until the Interactor eventually tells the Router to navigate to the next Activity.

Note - In the future we are looking to make the Router generic so it is not tied specifically to an Activity

Below is a sample router:

class NumberRouter extends BaseRouter implements NumberContract.Router {

    // This activity is injected
    NumberRouter(AppCompatActivity activity) {
        super(activity);
        Timber.d(activity.getLocalClassName());
    }

    @Override
    public void navigateToList() {
        Intent intent = new Intent(getActivity(), ListActivity.class);
        getActivity().startActivity(intent);
    }
}
Clone this wiki locally