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

Unhandled exception from SnackbarNotification.cs (Droid) #126

Closed
pdunlop opened this issue Jul 27, 2017 · 3 comments
Closed

Unhandled exception from SnackbarNotification.cs (Droid) #126

pdunlop opened this issue Jul 27, 2017 · 3 comments

Comments

@pdunlop
Copy link

pdunlop commented Jul 27, 2017

There was an issue raised back in April for this, but I'm still seeing the issue in version 3.2.0. When clicking on a notification, I occasionally get the error below:

 System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0 
   at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <3fd174ff54b146228c505f23cf75ce71>:0 
   at Plugin.Toasts.SnackbarNotification.ToastClosed (System.String id, Plugin.Toasts.NotificationResult result) [0x0001e] in C:\Users\Adam\Source\Repos\Toasts.Forms.Plugin\Toasts.Forms.Plugin.Droid\SnackbarNotification.cs:75 
   at Plugin.Toasts.SnackbarNotification.<Notify>b__5_2 (System.String toastId, Plugin.Toasts.NotificationResult result) [0x00000] in C:\Users\Adam\Source\Repos\Toasts.Forms.Plugin\Toasts.Forms.Plugin.Droid\SnackbarNotification.cs:43 
   at Plugin.Toasts.ToastCallback.OnDismissed (Android.Support.Design.Widget.Snackbar snackbar, System.Int32 evt) [0x0001d] in C:\Users\Adam\Source\Repos\Toasts.Forms.Plugin\Toasts.Forms.Plugin.Droid\SnackbarNotification.cs:99 
   at Android.Support.Design.Widget.Snackbar+Callback.n_OnDismissed_Landroid_support_design_widget_Snackbar_I (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_snackbar, System.Int32 evt) [0x00011] in <12ef52c9fdb344f58cbdf75db3fa86d8>:0 
   at (wrapper dynamic-method) System.Object:5cfc4f73-d1a7-4c55-93b6-d6acc659d030 (intptr,intptr,intptr,int)
@Troto
Copy link

Troto commented Aug 18, 2017

Any progress on this?

@pdunlop
Copy link
Author

pdunlop commented Sep 5, 2017

Tracing through the plugin, I've found that using SnackbarNotification can sometimes result in ToastClosed() being called twice.

The first time is with the action NotificationAction.Clicked from a click on the ViewText. This sets the reset event, and the id is removed from the dictionary.

The second time is from the callback from snackbar.SetCallback(). ToastCallback.OnDismissed is sometimes called with the event type DismissEventConsecutive, presumably due to a timing issue where the user has clicked it, but it self-dismisses as well. As the reset event was removed already from the step above, we see the exception above.

Any idea what the best fix is for this?

@adamped
Copy link
Contributor

adamped commented Sep 6, 2017

@pdunlop @Troto - fixed in 3.2.1 - https://www.nuget.org/packages/Toasts.Forms.Plugin/3.2.1

It will now just action the first it receives, and ignore any event if gets after that, in the rare case 2 events are raised.

@adamped adamped closed this as completed Sep 6, 2017
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

3 participants