Closed lurecas closed 6 years ago
Yep, Actvity is required to determine if view is destroyed temporarily or permanently and therfore release / destroy Presenter. Im not sure how to get this information without activity. I will check that next week but I'm afraid that there is no simple solution.
What you can do, however, is to stick with Mosby 2.x for activityless ViewGroups. You can totally use Mosby 2 and Mosby 3 at the same time in your project.
Luis R. notifications@github.com schrieb am Do., 23. Nov. 2017, 11:45:
Hello!
We've been using Mosby for a fair amount of time on a production app. We've had a lot of work coming in, and we haven't been able to update it to the v3. We were happy with v2, but there were several weird crashes that we wanted to solve.
After reading the instructions, the update process went super smooth. All the views that we've been using on the app were correctly rendered. Here is where the complain begins ๐
Our app is using the WindowManager to show contextual info when you are outside of the app. Just like the Facebook Bubbles. For example, our root view inherits from MvpRelativeLayout. When the views are attached to the window, the PresenterManager class tries to obtain the Activity, with no success. The context you can retrieve there, is directly the Application object, so it is impossible to cast it to Activity.
If you want to me to assemble a little project with the parts that would reproduce the issue, don't doubt to ask
Mosby Version: v3.0.4
Actual behavior (include a stacktrace if crash)
11-22 23:58:49.622 17039-17039/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.XXX, PID: 17039 java.lang.IllegalStateException: Could not find the surrounding Activity at com.hannesdorfmann.mosby3.PresenterManager.getActivity(PresenterManager.java:229) at com.hannesdorfmann.mosby3.mvp.delegate.ViewGroupMvpDelegateImpl.
(ViewGroupMvpDelegateImpl.java:79) at com.hannesdorfmann.mosby3.mvp.layout.MvpRelativeLayout.getMvpDelegate(MvpRelativeLayout.java:77) at com.hannesdorfmann.mosby3.mvp.layout.MvpRelativeLayout.onAttachedToWindow(MvpRelativeLayout.java:85) at XXXX.onAttachedToWindow(WidgetContainer.kt:107) at android.view.View.dispatchAttachedToWindow(View.java:17377) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3319) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1658) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) **Steps to reproduce the behavior or link to a sample repository** Add any MvpViewGroup class to the WindowManager (using the `SYSTEM_ALERT_WINDOW`) Thank you very much! โ You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/sockeqwe/mosby/issues/281>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAjnrl4vJZe3gdI1pJO7RuD1-KYgf6clks5s5VrfgaJpZM4QooGS> .
Sorry for the long delay in getting back to you. In the end, we went with both versions of Mosby on our app. Thanks
I'd like to revive this Thread. Since Android-X mosby3 only is needed
Hello!
We've been using Mosby for a fair amount of time on a production app. We've had a lot of work coming in, and we haven't been able to update it to the v3. We were happy with v2, but there were several weird crashes that we wanted to solve.
After reading the instructions, the update process went super smooth. All the views that we've been using on the app were correctly rendered. Here is where the complain begins ๐
Our app is using the WindowManager to show contextual info when you are outside of the app. Just like the Facebook Bubbles. For example, our root view inherits from
MvpRelativeLayout
. When the views are attached to the window, thePresenterManager
class tries to obtain the Activity, with no success. The context you can retrieve there, is directly theApplication
object, so it is impossible to cast it to Activity.If you want to me to assemble a little project with the parts that would reproduce the issue, don't doubt to ask
Mosby Version:
v3.0.4
Actual behavior (include a stacktrace if crash)
Steps to reproduce the behavior or link to a sample repository Add any MvpViewGroup class to the WindowManager (using the
SYSTEM_ALERT_WINDOW
permission)Thank you very much!