Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Third-party activity crashes onDestroy #11

Closed
eprendre opened this issue May 11, 2016 · 2 comments
Closed

Third-party activity crashes onDestroy #11

eprendre opened this issue May 11, 2016 · 2 comments

Comments

@eprendre
Copy link

after upgrading to 0.3.2 I got several problems:

1.ClassCastException

Caused by: java.lang.ClassCastException: xxxActivity cannot be cast to com.hardsoftstudio.rxflux.dispatcher.RxViewDispatch

@Override public void onActivityDestroyed(Activity activity) {
    activityCounter--;

    List<RxStore> rxStoreList = ((RxViewDispatch) activity).getRxStoreListToUnRegister();
    if (rxStoreList != null) {
      for (RxStore rxStore: rxStoreList) {
        rxStore.unregister();
      }
    }
...
2.((RxViewDispatch) activity).onRxViewUnRegistered() moved to onActivityStopped

Thus behaviour is slightly different from unRegister onActivityPaused in 0.3.1. I have two activities responding to a same Action under onRxStoreChanged. It's OK with 0.3.1, cause one activity is unregistered onPause(when another activity launches). Is there any solution for 0.3.2?

@marcelpinto
Copy link
Owner

  1. I will add a check with instanceof RxViewDispatch. I wanted to force that all activities implement the method to avoid breaking the flow of flux. But I did not think on third parties.
  2. I decided to move it to onStop so the activity still reacts when there is sth on top but is still there. I will think it better and I will maybe revert it to onPause and onResume.

@eprendre
Copy link
Author

Thanks for quick reply.
For question 2, I think you're right, keep it plz. In 0.3.1 I did repeat the code in order to catch that same action. Now, after refactoring my code, it seems to be more reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants