Xamarin.Plugin.Calendar
Xamarin.Plugin.Calendar copied to clipboard
Ensure that the GestureDetector is disposed
I received a log from a crash of my app that is related to the SwipeAwareContainerRenderer class used by the calendar. From the stacktrace the crash seem to be caused by a press that try to access the renderer, but it has already been disposed so it crash the application. This PR make two things :
- Ensure that the the gesture detector is disposed correctly like in #115
- Decouple the renderer from the gesture listener because the two have not the same lifecycle, by doing this we ensure that the gesture listener is disposed before the renderer which is not garanted when the renderer is itself the gesture listener
FYI, the stacktrace of the crash
System.NotSupportedException: Unable to activate instance of type Xamarin.Plugin.Calendar.Android.SwipeAwareContainerRenderer from native handle 0xffc46fdc (key_handle 0xe4b6c0a).
at IJavaPeerable Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)
at IJavaPeerable Java.Lang.Object.GetObject(IntPtr handle, JniHandleOwnership transfer, Type type)
at IOnGestureListener Java.Lang.Object._GetObject<IOnGestureListener>(IntPtr handle, JniHandleOwnership transfer)
at IOnGestureListener Java.Lang.Object.GetObject<IOnGestureListener>(IntPtr handle, JniHandleOwnership transfer) x 2
at void Android.Views.GestureDetector+IOnGestureListenerInvoker.n_OnLongPress_Landroid_view_MotionEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_e)
--- End of inner exception stack trace ---
System.MissingMethodException: No constructor found for Xamarin.Plugin.Calendar.Android.SwipeAwareContainerRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
at object Java.Interop.TypeManager.CreateProxy(Type type, IntPtr handle, JniHandleOwnership transfer)
at IJavaPeerable Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)