4

I have a list view populated in popup. I am using 1.0.4 version of

Rg.plugins.popup.

on selecting list item, I'm calling

PopupNavigation.PopAsync(true);

to close the popup.

but sometimes I'm getting below crash:

Android.Runtime.JavaProxyThrowable: Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown. --- End of managed Android.Runtime.JavaProxyThrowable stack trace --- android.runtime.JavaProxyThrowable: System.IndexOutOfRangeException: There is not page in PopupStack at Rg.Plugins.Popup.Services.PopupNavigation.PopAsync (System.Boolean animate) [0x0000c] in :0 at TCRMobile.ViewModels.TicketsListGenericViewModel.OpenTicketTabsPage (TCRMobile.DataObjects.Ticket selectedTicket, System.Int32 mobileID, System.Nullable`1[T] laborMiscTimeMobileID) [0x00000] in :0 at TCRMobile.ViewModels.TicketsListGenericViewModel+<>c__DisplayClass13_0.b__0 () [0x00055] in :0 at TCRMobile.Droid.Services.DialogService+<>c__DisplayClass5_0.b__1 (System.Object sender, Android.Content.DialogClickEventArgs e) [0x0001d] in <5c6ae91b284846f5995b4e735df62b69>:0 at Android.Content.IDialogInterfaceOnClickListenerImplementor.OnClick (Android.Content.IDialogInterface dialog, System.Int32 which) [0x00012] in <1ccf2ea9504d42c08b47c05ee0c5e9f7>:0 at Android.Content.IDialogInterfaceOnClickListenerInvoker.n_OnClick_Landroid_content_DialogInterface_I (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_dialog, System.Int32 which) [0x0000f] in <1ccf2ea9504d42c08b47c05ee0c5e9f7>:0 at (wrapper dynamic-method) System.Object:d515a9d0-d793-4191-a5c6-5e450c1fd743 (intptr,intptr,intptr,int) at mono.android.content.DialogInterface_OnClickListenerImplementor.n_onClick(Native Method) at mono.android.content.DialogInterface_OnClickListenerImplementor.onClick(DialogInterface_OnClickListenerImplementor.java:30) at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:175) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1534) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1424)

I assume crash is because some of my users double clicking the list item. Do I need to always check the popup stack count before calling

popasync(true).

If updating the above popup library would solve this issue?

please explain the reason for crash and solution.

Thanks

Sai Sunkari
  • 179
  • 3
  • 27

2 Answers2

0

Try this Popup ViewPage.

  <?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage  xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="RootNamespace.Views.NeedHelpPopupView"
             xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
             xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
             xmlns:Controls="clr-namespace:RootNamespace.Controls">
    <pages:PopupPage.Animation>
        <animations:ScaleAnimation DurationIn="400" DurationOut="300" EasingIn="SinOut" EasingOut="SinIn" HasBackgroundAnimation="True" PositionIn="Center" PositionOut="Center" ScaleIn="1.2"  ScaleOut="0.8" />
    </pages:PopupPage.Animation>
    <StackLayout Padding="20,20,20,20" HorizontalOptions="Center" VerticalOptions="Center">
        <Grid Grid.Row="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Frame CornerRadius="10" Grid.Row="0" BackgroundColor="{StaticResource YetiBlue}" HasShadow="False" Margin="20,0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid Grid.Row="0">
                        <Image Source="{Binding IconNeedHelp}"/>
                        <Image Source="{Binding IconClose}" x:Name="ImageClose" HorizontalOptions="End" VerticalOptions="Start"/>
                    </Grid>
                </Grid>
            </Frame>
            <Frame CornerRadius="10" Grid.Row="0" BackgroundColor="{StaticResource YetiBlue}" HasShadow="False"  Margin="10,130,10,0">
            </Frame>
            <Frame CornerRadius="10" Grid.Row="0" BackgroundColor="{StaticResource White}" Margin="10,120,10,10" HasShadow="False">
                <Grid BackgroundColor="{StaticResource White}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Controls:Label Grid.Row="0" Text="{Binding LabelNeedHelpTitle}" TextColor="{Binding Black}" HorizontalOptions="Center" FontAttributes="Bold" FontSize="20"/>
                    <BoxView Grid.Row="1" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" WidthRequest="80" HeightRequest="4" Color="{StaticResource YetiBlue}"/>
                    <Controls:Label Grid.Row="2" Text="{Binding LabelDescription}" TextColor="{Binding Black}" HorizontalOptions="CenterAndExpand" FontAttributes="Bold" FontSize="17" Margin="{StaticResource Margin10}"/>
                </Grid>
            </Frame>
        </Grid>
    </StackLayout>
</pages:PopupPage>

This is the Navigation Part.

 protected override void OnAppearing()
        {
            base.OnAppearing();
            ImageClose.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(_ =>
                {
                    PopupNavigation.Instance.PopAsync();
                })
            });
        }

Android

In MainActivity.cs file.

Rg.Plugins.Popup.Popup.Init(this, bundle);

IOS

In AppDelegate.cs file.

 Rg.Plugins.Popup.Popup.Init();

Try to this code.

And In Project Rg.Plugins.Popup 1.1.4.158-pre package is installed.

Akash Limbani
  • 1,283
  • 4
  • 14
  • 34
0

Probably this would be no brainer solution.

Call it

await PopUpService.PopUpAll();

Service

public static class PopUpService
{
    public static async Task PopUpAll()
    {
        if (Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Any())
        {
            await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAllAsync();
        }
    }
}
valentasm
  • 2,137
  • 23
  • 24