Search code examples
daggermortarsquare-flow

How do I finish an Activity from within a mortar Presenter or a View?


How do I finish an Activity from within a Presenter or a View in the mortar sample app?


Solution

  • The majority of the time you would want to avoid doing this. But in dire circumstances you could follow the same pattern the ActionBarOwner[0] class implements. Create an injectable class that exposes Activity#finish via an interface.

    Item 3 in [1] is related but the calling order is inverted. (Activity lifecycle methods to presenters instead of Presenters to Activity methods).

    Hope that helps!

    [0] https://github.com/square/mortar/blob/master/mortar-sample/src/main/java/com/example/mortar/android/ActionBarOwner.java

    [1] Mortar + Flow with third party libraries hooked to activity lifecycle