sockeqwe / mosby

A Model-View-Presenter / Model-View-Intent library for modern Android apps
http://hannesdorfmann.com/mosby/
Apache License 2.0
5.49k stars 841 forks source link

View without Activity #329

Open bdelville opened 5 years ago

bdelville commented 5 years ago

Allow mosby to support view without activity: Reference ticket: https://github.com/sockeqwe/mosby/issues/281

Alternatively, we can just remove the Exception when there is no activity and switch automatically to Window-mode for ViewGroup base DelegateCallback. But I guess if we add this feature we would like it to be enforced and managed. So the user will need to implement "public boolean isViewOnActivity()" It basically switch to a mod where it does not expect to save a state nor detach a view without destroying.

From a user perspective, a CustomView can be use alternatively by a Activity or a Window directly, an easy way to support that would be to implement:

public boolean isViewOnActivity() { return PresenterManager.getActivity(delegateCallback.getContext()) != null }

bdelville commented 5 years ago

Build failed due to api 28:

"Failed to install the following Android SDK packages as some licences have not been accepted."

sockeqwe commented 5 years ago

Hey @bdelville thanks for this PR I'm not sure though if that is the right API.

I was wondering if it make sense to keep this outside of the library?