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