Ejemplo n.º 1
0
        //Download Info
        private async void MAdapterOnItemClick(object sender, MyInformationAdapterClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    return;
                }

                var position = e.Position;
                if (position > -1)
                {
                    var item = MAdapter.GetItem(position);
                    if (item != null)
                    {
                        //Show a progress
                        AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                        var(apiStatus, respond) = await RequestsAsync.Global.DownloadInfoAsync(item.Type);

                        if (apiStatus == 200)
                        {
                            if (respond is DownloadInfoObject result)
                            {
                                Link = result.Link;
                                var fileName = Link.Split('/').Last();
                                WoWonderTools.GetFile("", Methods.Path.FolderDcimFile, fileName, Link);

                                BtnDownload.Visibility = ViewStates.Visible;

                                Toast.MakeText(this, GetText(Resource.String.Lbl_YourFileIsReady), ToastLength.Long).Show();

                                AndHUD.Shared.Dismiss(this);
                            }
                        }
                        else
                        {
                            if (respond is ErrorObject errorMessage)
                            {
                                var errorText = errorMessage.Error.ErrorText;
                                //Show a Error image with a message
                                AndHUD.Shared.ShowError(this, errorText, MaskType.Clear, TimeSpan.FromSeconds(2));
                            }

                            // Methods.DisplayReportResult(this, respond);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }
Ejemplo n.º 2
0
        //Download Info
        private async void MAdapterOnItemClick(object sender, MyInformationAdapterClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                    return;
                }

                var position = e.Position;
                switch (position)
                {
                case > -1:
                {
                    var item = MAdapter.GetItem(position);
                    if (item != null)
                    {
                        //Show a progress
                        AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                        var(apiStatus, respond) = await RequestsAsync.Global.DownloadInfoAsync(item.Type);

                        switch (apiStatus)
                        {
                        case 200:
                        {
                            switch (respond)
                            {
                            case DownloadInfoObject result:
                            {
                                Link = result.Link;
                                var fileName = Link.Split('/').Last();
                                WoWonderTools.GetFile("", Methods.Path.FolderDcimFile, fileName, Link);

                                BtnDownload.Visibility = ViewStates.Visible;

                                Toast.MakeText(this, GetText(Resource.String.Lbl_YourFileIsReady), ToastLength.Long)?.Show();

                                AndHUD.Shared.Dismiss(this);
                                break;
                            }
                            }

                            break;
                        }

                        default:
                            Methods.DisplayAndHudErrorResult(this, respond);
                            break;
                        }
                    }

                    break;
                }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }