public CoordinatesForAdvertisementsModel GetCoordinatesModel(int maxDistance = -1)
        {
            CoordinatesForAdvertisementsModel coordinatesModel = new CoordinatesForAdvertisementsModel();
            var location      = GetLocation();
            var settingsMOdel = (AppSettingsModel)sharedPreferencesHelper.GetSharedPreference <AppSettingsModel>(SharedPreferencesKeys.APP_SETTINGS);

            if (location == null || latitude == 0 || longitude == 0)
            {
                AlertsService.ShowLongToast(this.mContext, "Nie mogê ustaliæ aktualnej lokalizacji. W³¹cz lokalizacjê w ustawieniach telefonu.");
                throw new Exception("Brak lokalizacji");
            }
            else
            {
                coordinatesModel.Latitude  = latitude;
                coordinatesModel.Longitude = longitude;
                if (maxDistance > -1)
                {
                    coordinatesModel.MaxDistance = maxDistance;
                }
                else if (settingsMOdel != null)
                {
                    coordinatesModel.MaxDistance = settingsMOdel.LocationSettings.MaxDistance;
                }
                else
                {
                    coordinatesModel.MaxDistance = ValueConsts.MAX_DISTANCE_VALUE;
                }
            }

            return(coordinatesModel);
        }
        public async Task ShowCategoriesSingleSelectAndMakeAction(Action <int, string> actionOnSelect, string selectedItemName = null)
        {
            try
            {
                this.progressDialogHelper.ShowProgressDialog("Trwa pobieranie danych");
                var allKeywords = await this.categoryService.GetCategories();

                var allKeywordsNames = allKeywords.Select(k => k.Value).ToArray();
                this.progressDialogHelper.CloseProgressDialog();
                AlertsService.ShowSingleSelectListString(ctx, allKeywordsNames, s => actionOnSelect(allKeywords.First(v => v.Value == s).Key, s), selectedItemName, "Wybierz kategoriê");
            }
            catch (Exception exc)
            {
                AlertsService.ShowLongToast(ctx, "Wyst¹pi³ problem z pobraniem danych. Upewnij siê, ¿e masz dostêp do internetu: " + exc);
                this.progressDialogHelper.CloseProgressDialog();
            }
        }
        public async Task ShowCategoriesListAndMakeAction(List <string> userSelectesKeywordsNames, Func <IDictionary <int, string>, Action <List <string> > > methodToExecuteAfterCategoriesSelect)
        {
            try
            {
                this.progressDialogHelper.ShowProgressDialog("Trwa pobieranie danych");
                var allKeywords = await this.categoryService.GetCategories();

                var allKeywordsNames = allKeywords.Select(k => k.Value).ToArray();
                this.progressDialogHelper.CloseProgressDialog();
                AlertsService.ShowMultiSelectListString(ctx, "Wybierz kategorie", allKeywordsNames, userSelectesKeywordsNames, methodToExecuteAfterCategoriesSelect(allKeywords));
            }
            catch (Exception exc)
            {
                this.progressDialogHelper.CloseProgressDialog();
                AlertsService.ShowLongToast(ctx, "Wyst¹pi³ problem z pobraniem danych. Upewnij siê, ¿e masz dostêp do internetu");
            }
        }
        public string SavePhotoFromUriAndReturnPhysicalPath(Android.Net.Uri contentURI, Java.IO.File file, Context ctx)
        {
            try
            {
                var contentResolver = ctx.ContentResolver;
                var stream          = contentResolver.OpenInputStream(contentURI);
                using (OutputStream output = new FileOutputStream(file))
                {
                    var memStream = new MemoryStream();
                    stream.CopyTo(memStream);
                    var buffer = memStream.ToArray();

                    output.Write(buffer);
                }

                return(file.AbsolutePath);
            }
            catch (Exception exc)
            {
                AlertsService.ShowLongToast(ctx, "Wyst¹pi³ b³¹d podczas zapisu pliku z adresu URI");
                return(String.Empty);
            }
        }
        public Location GetLocation()
        {
            try
            {
                locationManager = (LocationManager)mContext.GetSystemService("location");

                // Getting GPS status
                isGPSEnabled = locationManager.IsProviderEnabled(LocationManager.GpsProvider);

                // Getting network status
                isNetworkEnabled = locationManager.IsProviderEnabled(LocationManager.NetworkProvider);

                if (!isGPSEnabled && !isNetworkEnabled)
                {
                    //showalert in activity
                }
                else
                {
                    if (isNetworkEnabled)
                    {
                        if (locationManager != null)
                        {
                            locationManager.RequestLocationUpdates(
                                LocationManager.NetworkProvider,
                                MIN_TIME_BW_UPDATES,
                                MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                            location = locationManager.GetLastKnownLocation(LocationManager.NetworkProvider);
                            if (location != null)
                            {
                                latitude  = location.Latitude;
                                longitude = location.Longitude;
                            }
                        }
                    }
                    if (isGPSEnabled)
                    {
                        if (location == null)
                        {
                            locationManager.RequestLocationUpdates(
                                LocationManager.GpsProvider,
                                MIN_TIME_BW_UPDATES,
                                MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                            if (locationManager != null)
                            {
                                location = locationManager.GetLastKnownLocation(LocationManager.GpsProvider);
                                if (location != null)
                                {
                                    latitude  = location.Latitude;
                                    longitude = location.Longitude;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                AlertsService.ShowLongToast(this.mContext, "Nie masz w³¹czonej lokalizacji!");
            }

            return(location);
        }