private void DownloadIndex(Action <string> onFinished)
        {
            try
            {
                var ec = new FileDownload();

                var pd = new ProgressDialog(this);
                pd.SetMessage(Resources.GetText(Resource.String.Download_LoadingData));
                pd.SetCancelable(false);
                pd.Show();

                ec.OnFinishedAction = (result) =>
                {
                    MainThread.BeginInvokeOnMainThread(() =>
                    {
                        onFinished.Invoke(result);
                        pd.Hide();
                    });
                };
                ec.OnError = (message) =>
                {
                    MainThread.BeginInvokeOnMainThread(() =>
                    {
                        pd.Hide();
                        PopupHelper.ErrorDialog(this, Resource.String.Download_ErrorDownloading, message);
                    });
                };

                ec.Execute(GpxFileProvider.GetIndexUrl());
            }
            catch (Exception ex)
            {
                PopupHelper.ErrorDialog(this, Resource.String.Download_ErrorDownloading, ex.Message);
            }
        }
Example #2
0
 protected override string RunInBackground(params string[] @url)
 {
     try
     {
         var file = GpxFileProvider.GetFile(url[0]);
         Thread.Sleep(500);
         return(file);
     }
     catch (Exception ex)
     {
         OnError?.Invoke(ExceptionHelper.Exception2ErrorMessage(ex));
         return(null);
     }
 }
Example #3
0
        protected override PoiList RunInBackground(params string[] @url)
        {
            try
            {
                OnStageChange?.Invoke(Resource.String.Download_Progress_Downloading, 1);
                var file = GpxFileProvider.GetFile(GpxFileProvider.GetUrl(url[0]));
                OnProgressChange?.Invoke(1);

                var listOfPoi = GpxFileParser.Parse(file, _source.Category, _source.Country, _source.Id,
                                                    x => OnStageChange?.Invoke(Resource.String.Download_Progress_Processing, x),
                                                    x => OnProgressChange?.Invoke(x));

                return(listOfPoi);
            }
            catch (Exception ex)
            {
                OnError?.Invoke(ExceptionHelper.Exception2ErrorMessage(ex));
                return(new PoiList());
            }
        }
Example #4
0
        protected override bool RunInBackground(params string[] @command)
        {
            try
            {
                OnStageChange?.Invoke(Resource.String.Download_Progress_FetchingElevationTilesList, 1);
                var file = GpxFileProvider.GetFile(GpxFileProvider.GetUrl(_source.Url));
                OnProgressChange?.Invoke(1);
                var elevationMap = JsonConvert.DeserializeObject <ElevationMap>(file);

                _elevationTileCollection = new ElevationTileCollection(elevationMap);

                if (@command[0] == COMMAND_DOWNLOAD)
                {
                    OnStageChange?.Invoke(Resource.String.Download_Progress_DownloadingElevationData, _elevationTileCollection.GetCountToDownload());
                    if (!_elevationTileCollection.Download(progress => { OnProgressChange(progress); }))
                    {
                        OnError?.Invoke(_elevationTileCollection.GetErrorList());
                        return(false);
                    }

                    return(true);
                }

                if (@command[0] == COMMAND_REMOVE)
                {
                    OnStageChange?.Invoke(Resource.String.Download_Progress_RemovingElevationData, 1);
                    return(_elevationTileCollection.Remove());
                }

                return(false);
            }
            catch (Exception ex)
            {
                OnError?.Invoke(ExceptionHelper.Exception2ErrorMessage(ex));
                return(false);
            }
        }