質問

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

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top