-
Notifications
You must be signed in to change notification settings - Fork 128
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
java.lang.RuntimeException: Could not dispatch event #8
Comments
Are you using the calendar view inside a fragment? |
I am using my calendar view inside an AppCompatActivity and have the same problem. So using getChildFragmentManager will not work in this instance (if that is what you were gonna suggest). |
yes, |
This is a memory leak issue. When the activity is destroyed, somehow the WeekPager of the WeekCalendar view remains in memory. When a new activity is created and a call is made to a fresh WeekCalendar, the BusProvider dispatches the event to both the leaked WeekPager and the new WeekPager. I don't know enough about Views' lifecycle to fix it but I've done a temporary hack in WeekPager by surrounding the code of every method marked as @subscribe with a try/catch. |
Found it. BusProvider is a singleton that is never disposed of and hence maintains a reference to methods within the old WeekPager. I'll fix it and do a pull request when I get around to it. |
You are welcome to contribute to this library and fix the issue you found.
|
Pull request created |
is it fixed? |
Yes, you need to download and add the library. Haven't updated in on Maven
|
I got the same problem. What's the solution? |
me too :( |
@konstantin-gorbunov I couldn't solve this problem. Suggest this library, https://github.com/Mulham-Raee/Horizontal-Calendar. |
Getting the Same Problem is there any solution or anyone get the solution? |
I am facing the following issue sometimes:
Fatal Exception: java.lang.RuntimeException: Could not dispatch event: class noman.weekcalendar.eventbus.Event$SetSelectedDateEvent to handler [EventHandler public void noman.weekcalendar.view.WeekPager.setSelectedDate(noman.weekcalendar.eventbus.Event$SetSelectedDateEvent)]: Fragment WeekFragment{426ab190} is not currently in the FragmentManager
at com.squareup.otto.Bus.throwRuntimeException(Bus.java:460)
at com.squareup.otto.Bus.dispatch(Bus.java:387)
at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:368)
at com.squareup.otto.Bus.post(Bus.java:337)
at noman.weekcalendar.eventbus.BusProvider.post(BusProvider.java:26)
at noman.weekcalendar.WeekCalendar.setSelectedDate(WeekCalendar.java:165)
at com.kwench.android.kfit.ui.SleepFragment$1$1.onDateSet(SleepFragment.java:147)
at android.app.DatePickerDialog.tryNotifyDateSet(DatePickerDialog.java:148)
at android.app.DatePickerDialog.onClick(DatePickerDialog.java:116)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5345)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.IllegalStateException: Fragment WeekFragment{426ab190} is not currently in the FragmentManager
at android.support.v4.app.FragmentManagerImpl.saveFragmentInstanceState(FragmentManager.java:687)
at android.support.v4.app.FragmentStatePagerAdapter.destroyItem(FragmentStatePagerAdapter.java:136)
at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:418)
at noman.weekcalendar.view.WeekPager.initPager(WeekPager.java:56)
at noman.weekcalendar.view.WeekPager.setSelectedDate(WeekPager.java:102)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.squareup.otto.EventHandler.handleEvent(EventHandler.java:89)
at com.squareup.otto.Bus.dispatch(Bus.java:385)
at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:368)
at com.squareup.otto.Bus.post(Bus.java:337)
at noman.weekcalendar.eventbus.BusProvider.post(BusProvider.java:26)
at noman.weekcalendar.WeekCalendar.setSelectedDate(WeekCalendar.java:165)
at com.kwench.android.kfit.ui.SleepFragment$1$1.onDateSet(SleepFragment.java:147)
at android.app.DatePickerDialog.tryNotifyDateSet(DatePickerDialog.java:148)
at android.app.DatePickerDialog.onClick(DatePickerDialog.java:116)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5345)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(NativeStart.java)
The text was updated successfully, but these errors were encountered: