Open strmchsr opened 8 years ago
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, What is the resolution?
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. The event will work fine for the new WeekPager but will fail for the old one.
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. On Feb 1, 2016 9:50 PM, "BroScience repository" notifications@github.com wrote:
Found it.
BusProvider is a singleton that is never disposed of and hence maintains a reference to methods within the old WeekPager.
Implement the proper design pattern and it fixes it.
— Reply to this email directly or view it on GitHub https://github.com/nomanr/WeekCalendar/issues/8#issuecomment-178064140.
Pull request created
is it fixed?
Yes, you need to download and add the library. Haven't updated in on Maven yet. On Feb 2, 2016 4:08 PM, "shashank090789" notifications@github.com wrote:
is it fixed?
— Reply to this email directly or view it on GitHub https://github.com/nomanr/WeekCalendar/issues/8#issuecomment-178512949.
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 will get the solution for only to prevent a crash. Change BusProvider lib
from com.squareup:otto
to org.greenrobot:eventbus
But it will not override the WeekCalendar view in newly added fragment also not showing the days. And previous fragment's WeekCalander makes disabled.
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)