示例#1
0
        // Pick up an image from the studio of the camera
        async Task ChooseImage()
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await CoreMethods.DisplayAlert("No Camera", ":( No camera available.", "OK");

                return;
            }

            var file = await CrossMedia.Current.PickPhotoAsync();

            if (file == null)
            {
                return;
            }

            await CoreMethods.DisplayAlert("File Location", file.Path, "OK");

            Article.CoverImage = ImageSource.FromStream(() =>
            {
                var stream = file.GetStream();
                return(stream);
            });
        }
        protected async Task <MediaFile> TakeVideosync()
        {
            await CrossMedia.Current.Initialize();

            if (!IsCameraAvailable || !CrossMedia.Current.IsTakeVideoSupported)
            {
                await CoreMethods.DisplayAlert(SportsGoResources.NoCamara, SportsGoResources.CamaraNoDisponible, "OK");

                return(null);
            }

            if (await CheckCameraPermissionAndAskForIt() && await CheckStoragePermissionAndAskForIt())
            {
                MediaFile file = await CrossMedia.Current.TakeVideoAsync(new StoreVideoOptions
                {
                    SaveToAlbum        = true,
                    Quality            = VideoQuality.Medium,
                    DesiredLength      = TimeSpan.FromSeconds(App.Usuario.PlanesUsuarios.Planes.TiempoPermitidoVideo),
                    CompressionQuality = 70,
                    DesiredSize        = 100000000
                });

                return(file);
            }
            else
            {
                if (await CoreMethods.DisplayAlert(SportsGoResources.PermisoDenegado, SportsGoResources.NosePudoTomarVideo, "OK", SportsGoResources.Cancelar))
                {
                    //On iOS you may want to send your user to the settings screen.
                    CrossPermissions.Current.OpenAppSettings();
                }

                return(null);
            }
        }
示例#3
0
        private void LoadQnAJson()
        {
            try
            {
                var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(SwipeCardsViewModel)).Assembly;
                Stream stream   = assembly.GetManifestResourceStream("MyTasks.TODO.Data.qa_deck.json");
                string json     = "";
                using (var reader = new System.IO.StreamReader(stream))
                {
                    json = reader.ReadToEnd();
                }

                if (string.IsNullOrEmpty(json))
                {
                    return;
                }
                QuizDeck deck = JsonConvert.DeserializeObject <QuizDeck>(json);
                if (deck == null)
                {
                    Cards = new ObservableCollection <DeckItem>
                    {
                        new DeckItem()
                        {
                            Id = 0, QuestionText = "No Questions were found."
                        }
                    };
                }

                Cards = deck.DeckItems;
            }
            catch (Exception ex)
            {
                CoreMethods.DisplayAlert("Exception", ex.Message, "OK");
            }
        }
示例#4
0
        internal async void GetMoreGifs()
        {
            try
            {
                _giphyServiceObj = FreshIOC.Container.Resolve <GiphyService>();

                Giphy = String.IsNullOrEmpty(SearchText)
                        ? await _giphyServiceObj.GetTrendingGifs()
                        : await _giphyServiceObj.SearchGifs(SearchText);

                List <GifDataItem> gifDataItems = CreateGifDataItemList(Giphy.Data.ToList());
                gifDataItems.ForEach((gifDataItem) => { TrendingImages.Add(gifDataItem); });
                IsGettingMoreGifsDone = true;
            }
            catch (Exception exception)
            {
                MainThread.BeginInvokeOnMainThread
                (
                    () =>
                {
                    CoreMethods.DisplayAlert("Uh Oh", "Something bad happened: \n" + exception.Message, "Ok");
                }
                );
            }
        }
示例#5
0
        protected override void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);
            _credential = DependencyService.Get <ICredentialService>().GetCredential();
            _url        = CrossSettings.Current.GetValueOrDefault <string>("URL");
            _clients    = CrossSettings.Current.GetValueOrDefault <string>("Clients").Split(',').ToList();

            if (_credential == null || _url == null || _clients == null)
            {
                CoreMethods.DisplayAlert("Error", "Setting is incomplete!", "OK");
            }

            else if (_credential != null && _url != null && _clients != null)
            {
                //CalculateReport(_credential, _url, _clients);
                MenuTapped = new Command <string>(NavigateToTaskPage);
            }

            //Push Search Page
            SearchCommand = new Command(async() =>
            {
                await CoreMethods.PushPageModel <SearchPageModel>();
            });

            //Init Temp
            DaysToComplete  = 21.1;
            Task1ChartImage = ImageSource.FromResource("SLB.iTrackr.Resources.RadiusGraph70.png");
            Task2ChartImage = ImageSource.FromResource("SLB.iTrackr.Resources.RadiusGraph65.png");
            Task3ChartImage = ImageSource.FromResource("SLB.iTrackr.Resources.RadiusGraph90.png");
            Task4ChartImage = ImageSource.FromResource("SLB.iTrackr.Resources.RadiusGraph85.png");
            Task5ChartImage = ImageSource.FromResource("SLB.iTrackr.Resources.RadiusGraph60.png");
            Task6ChartImage = ImageSource.FromResource("SLB.iTrackr.Resources.RadiusGraph80.png");
        }
示例#6
0
        public async Task LoginCommandHandler()
        {
            try
            {
                string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); //Call Database
                var    db     = new SQLiteConnection(dpPath);
                var    data   = db.Table <LoginTable>();                                                                               //Call Table
                var    data1  = data.Where(x => x.username == Username && x.password == Password).FirstOrDefault();                    //Linq Query
                if (data1 != null)
                {
                    await CoreMethods.DisplayAlert("Login", "Login Successful", "Continue");

                    await CoreMethods.PushPageModel <MainPageModel>();
                }
                else
                {
                    await CoreMethods.DisplayAlert("Login", "Login has failed", "Try again");
                }
            }
            catch (Exception ex)
            {
                await CoreMethods.DisplayAlert("Error", ex.ToString(), "OK");
            }
            ;
        }
        private async void LoadInfo()
        {
            IsLoading = true;
            var response = await App.Client.FetchVegetables();

            if (response != null)
            {
                App.FromServer.Clear();
                foreach (var veg in response)
                {
                    if (!App.Favorites.Exists(v => v.Name == veg.Name))
                    {
                        App.FromServer.Add(veg);
                    }
                }
                IsLoading = false;
                MessagingCenter.Send <DisplayPageModel, List <Vegetable> > (this, "AllVegetablesLoaded", response);
            }
            else
            {
                var msg = App.Client.StatusMessage;
                IsLoading = false;
                await CoreMethods.DisplayAlert("Error", msg, "OK");
            }
        }
示例#8
0
        async Task FetchMovies(int page)
        {
            try
            {
                var service = DependencyService.Get <ITmdbService>().GetInstance();
                var movies  = await service.GetUpcomingMovies(page);

                foreach (var movie in movies.Results)
                {
                    movie.GenreDescription = await GetMovieGenreDescription(movie.GenreIds);

                    Movies.Add(movie);
                }

                currentPage = page;
                totalPages  = movies.TotalPages;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                await CoreMethods?.DisplayAlert("Error", "An error occurred while loading movies.", "Ok");
            }
            finally
            {
                IsRefreshing = IsLoading = false;
            }
        }
示例#9
0
        private async void Register()
        {
            if (string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(Password) || string.IsNullOrWhiteSpace(ConfirmPassword))
            {
                await CoreMethods.DisplayAlert("Oops!", "All fields must be filled", "Alright");
            }
            else if (Password != ConfirmPassword)
            {
                await CoreMethods.DisplayAlert("Oops!", "Password must match", "Alright");
            }
            else
            {
                try
                {
                    User user = new User(UserName, Password);
                    App.UserDatabase.SaveUser(user);
                    var result = await CoreMethods.DisplayAlert("Success!", "Your registration is successful....You can now login", "Alright", "Cancel");

                    if (result)
                    {
                        await CoreMethods.PushPageModel <LoginPageModel>();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#10
0
        public void MatchListhWords()
        {
            if (QuestionSet1 != null && QuestionSet2 != null && QuestionSet2.Count > 0 && QuestionSet1.Count > 0)
            {
                var joined               = QuestionSet1.Zip(QuestionSet2, (x, y) => new { x, y });
                var shuffled             = joined.OrderBy(x => Guid.NewGuid()).ToList();
                var MatchedQuestionSet11 = shuffled.Select(pair => pair.x).ToList();
                MatchedQuestionSet1 = Shuffle(MatchedQuestionSet11);
                MatchedQuestionSet2 = shuffled.Select(pair => pair.y).ToList();
                //MatchedQuestionSet2 = Shuffle(MatchedQuestionSet22);
                List <RandomNumbers> MainRandomList = new List <RandomNumbers>();

                for (int i = 0; i < MatchedQuestionSet1.Count; i++)
                {
                    RandomNumbers randomList = new RandomNumbers();
                    randomList.Item1 = MatchedQuestionSet1[i];
                    randomList.Item2 = MatchedQuestionSet2[i];
                    MainRandomList.Add(randomList);
                }

                GetMatchItems = new ObservableCollection <RandomNumbers>(MainRandomList);
            }
            else
            {
                CoreMethods.DisplayAlert("Both Editor boxes Should not be empty!", "Please Enter Something else", "Ok");
            }
            //return matchword;
        }
示例#11
0
        protected override void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);

            //Get REST request status
            MessagingCenter.Subscribe <SPService, string>(this, "SP_REQUEST_STATUS", (s, args) =>
            {
                CoreMethods.DisplayAlert("Notification", args, "OK");
            });

            IsBusy = false;

            var credTemp    = DependencyService.Get <ICredentialService>().GetCredential();
            var urlTemp     = CrossSettings.Current.GetValueOrDefault <string>("URL");
            var clientsTemp = CrossSettings.Current.GetValueOrDefault <string>("Clients");

            if (credTemp != null)
            {
                UserName = credTemp.UserName;
                Password = credTemp.Password;
            }

            if (urlTemp != null)
            {
                URL = urlTemp;
            }

            if (credTemp != null && urlTemp != null)
            {
                GetClients(clientsTemp);
            }
        }
        private async Task SaveProfile()
        {
            if (!EmailValidator.EmailIsValid(CurrentUser.Email))
            {
                await CoreMethods.DisplayAlert("Email", "Veuillez entrer une adresse email valide", "OK");

                return;
            }

            using (_dialogs.Loading("Enregistrement..."))
            {
                Settings.CurrentUser = JsonConvert.SerializeObject(CurrentUser);

                var passwd = await ChangePassword();

                if (passwd)
                {
                    CurrentUser.Password = NewPassword;
                }

                if (App.IsConnected())
                {
                    await App.UserManager.SaveOrUpdateAsync(CurrentUser.Id, CurrentUser, false);
                }

                if (passwd)
                {
                    NavBackCommand.Execute(null);

                    await Task.Delay(400);

                    MessagingCenter.Send(this, "ShowPasswordMessage");
                }
            }
        }
示例#13
0
        async Task <bool> ValidarDatosCandidatos()
        {
            bool esValido = true;

            if (Persona.CandidatoDeLaPersona.Estatura <= 0 || Persona.CandidatoDeLaPersona.Peso <= 0 || Persona.CandidatoDeLaPersona.FechaNacimiento == DateTime.MinValue ||
                Persona.CandidatoDeLaPersona.TipoGenero == TipoGeneros.SinGenero)
            {
                await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.FaltaDatosPerfil, "OK");

                esValido = false;
            }
            else if (DateTimeHelper.DiferenciaEntreDosFechasAños(DateTime.Now, Persona.CandidatoDeLaPersona.FechaNacimiento) < 18)
            {
                if (string.IsNullOrWhiteSpace(Persona.CandidatoDeLaPersona.CandidatosResponsables.Nombres) ||
                    string.IsNullOrWhiteSpace(Persona.CandidatoDeLaPersona.CandidatosResponsables.TelefonoMovil) || string.IsNullOrWhiteSpace(Persona.CandidatoDeLaPersona.CandidatosResponsables.Email))
                {
                    await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.FaltanDatosResponsable, "OK");

                    esValido = false;
                }
                else if (!Regex.IsMatch(Persona.CandidatoDeLaPersona.CandidatosResponsables.Email.Trim(), AppConstants.RegexEmail))
                {
                    await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.EmailFormatoInvalidoResponsable, "OK");

                    esValido = false;
                }
            }

            return(esValido);
        }
        private async Task GetUserDataAsync()
        {
            try
            {
                IsBusy = true;

                if (IsConnected)
                {
                    var _apiResult = await _webService.GetData <UserData>(APIEndPoints.NamesUri);

                    if (_apiResult != null)
                    {
                        var userData = JsonConvert.DeserializeObject <UserData>(_apiResult);

                        if (userData != null && userData.People.Any())
                        {
                            PersonList = new ObservableCollection <Person>(userData.People);

                            SaveDataToLocalCache();
                        }
                    }
                }
                else
                {
                    await CoreMethods.DisplayAlert("Error", "No Internet", "Ok");
                }
            }
            catch (Exception ex)
            {
                await CoreMethods.DisplayAlert("Error", "Something went wrong.", "Ok");
            }

            finally { IsBusy = false; }
        }
示例#15
0
        private List <LocationModel> GetLocatonsOnline()
        {
            List <LocationModel> locations = null;

            try
            {
                locations = GetLocations();
            }
            catch (ServerNotFoundException)
            {
                CoreMethods.DisplayAlert("Failed", "Failed to connect to server", "Continue");
            }
            catch (NotLoggedInException ex)
            {
                Debug.WriteLine(ex);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                CoreMethods.DisplayAlert("Failed", "Unknown error", "Quit");
                throw;
            }

            return(locations);
        }
示例#16
0
        async void ValidateSignatureAndUpload()
        {
            Dialog.ShowLoading("");

            if (Contract.SignImageSource != null)
            {
                PdfDocument duplicate = (PdfDocument)Contract.Document.Clone();


                var addPage = duplicate.Pages.Add();

                var width = addPage.GetClientSize().Width;

                PdfGraphics graphics = addPage.Graphics;

                PdfBitmap image = new PdfBitmap(new MemoryStream(contract.SignImageSource));

                graphics.DrawImage(image, new RectangleF(20, 40, width / 2, 60));


                MemoryStream m = new MemoryStream();

                duplicate.Save(m);

                var document = await StoreManager.DocumentStore.GetItemByContractId(Contract.Id, "saleContract");

                if (document == null)
                {
                    var documentItem = new Document()
                    {
                        Path = Contract.Id + '/' + "saleContract.pdf", Name = contract.Id + ".pdf", InternalName = "saleContract", ReferenceKind = "contract", ReferenceId = contract.Id, MimeType = "application/pdf"
                    };

                    var uploaded = await StoreManager.DocumentStore.InsertImage(m.ToArray(), documentItem);
                }
                else
                {
                    await PclStorage.SaveFileLocal(m.ToArray(), document.Id);

                    document.ToUpload = true;

                    await StoreManager.DocumentStore.UpdateAsync(document);

                    await StoreManager.DocumentStore.OfflineUploadSync();
                }

                Contract.ToSend = true;

                var isSent = await StoreManager.ContractStore.UpdateAsync(Contract);

                if (isSent)
                {
                    await CoreMethods.DisplayAlert(AppResources.Alert, AppResources.EmailSent, AppResources.Ok);

                    BackButton.Execute(null);
                }
            }

            Dialog.HideLoading();
        }
        async Task IniciarSesionUsuarioRegistrado(UsuariosDTO usuario)
        {
            if (IsNotConnected)
            {
                return;
            }
            UsuariosDTO usuarioVerificado = await _authService.VerificarUsuario(usuario);

            if (usuarioVerificado != null && (usuarioVerificado.TipoPerfil == TipoPerfil.Anunciante || usuarioVerificado.TipoPerfil == TipoPerfil.Administrador))
            {
                await CoreMethods.DisplayAlert(SportsGoResources.TituloAlerta, SportsGoResources.UsuarioNoExiste, "OK");

                return;
            }

            if (usuarioVerificado != null && usuarioVerificado.Consecutivo != 0)
            {
                if (usuarioVerificado.CuentaActiva == 0)
                {
                    await CoreMethods.DisplayAlert(SportsGoResources.TituloAlerta, SportsGoResources.CuentaNoActiva, "OK");

                    return;
                }

                await ConfigurarTabPrincipal(usuarioVerificado);
            }
            else
            {
                await CoreMethods.DisplayAlert(SportsGoResources.TituloAlerta, SportsGoResources.UsuarioNoExiste, "OK");
            }
        }
示例#18
0
        public async Task <bool> ValidarPublicacion()
        {
            bool publicacionValida = true;

            if (string.IsNullOrWhiteSpace(PublicacionSeleccionada.Titulo))
            {
                publicacionValida = false;
                await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.FaltaDatosPublicacion, "OK");
            }
            else if (EsGrupo && (PaisSeleccionado == null || CategoriaSeleccionada == null || PublicacionSeleccionada.IdiomaDelEvento == null))
            {
                publicacionValida = false;
                await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.FaltaDatosPublicacion, "OK");
            }
            else if (EsCandidato && (string.IsNullOrWhiteSpace(UrlArchivo) && (!PublicacionSeleccionada.CodigoArchivo.HasValue || PublicacionSeleccionada.CodigoArchivo < 0)))
            {
                publicacionValida = false;
                await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.FaltaVideoPublicacion, "OK");
            }
            else if (PublicacionSeleccionada.FechaTerminacion < PublicacionSeleccionada.FechaInicio)
            {
                publicacionValida = false;
                await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.FechasEventoInvalida, "OK");
            }

            return(publicacionValida);
        }
示例#19
0
 private async void ShowSimulationExplanation()
 {
     await CoreMethods.DisplayAlert(
         "Simulation Mode Activated",
         "Cringebot will now simulate the experience of involuntary recall by sending you notifications about items in the list at random intervals.",
         "OK");
 }
示例#20
0
        public Task <bool> MakeDataBaseCallToAddItemToDatabase()
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            Food food = new Food();

            food.name = NewFoodEntryText;
            if (SelectedItem != null)
            {
                food.categories  = SelectedItem.Categories;
                food.blacklisted = Enums.BlackListed.ToCheck;
                var result = DatabaseConnection.Connection.InsertAsync(food);
                result.Wait();
                if (result.IsCompleted)
                {
                    tcs.SetResult(true);
                    return(tcs.Task);
                }
                tcs.SetResult(false);
                return(tcs.Task);
            }
            else
            {
                CoreMethods.DisplayAlert("Uwaga", "Nie wybrales kategorii, sprobuj ponownie", "OK");
                tcs.SetResult(false);
                return(tcs.Task);
            }
        }
示例#21
0
        private async void Initialize()
        {
            try
            {
                if (IsConnected())
                {
                    _searchCacheServiceObj = FreshIOC.Container.Resolve <SearchCacheService>();
                    _giphyServiceObj       = FreshIOC.Container.Resolve <GiphyService>();

                    TrendingImages = new ObservableCollection <GifDataItem>();
                    SearchCache    = new ObservableCollection <SearchCacheItem>();

                    await RefreshTrendingGifs();
                    await RefreshSearchCache();

                    IsTrendingImagesPanelVisible = true;
                    IsGettingMoreGifsDone        = true;
                }
                else
                {
                    // Handle in ViewIsAppearing(..) handler.
                }
            }
            catch (Exception exception)
            {
                MainThread.BeginInvokeOnMainThread
                (
                    async() =>
                {
                    await CoreMethods.DisplayAlert("Uh Oh", "Something bad happened: \n" + exception.Message, "Ok");
                }
                );
            }
        }
示例#22
0
        private async void OnSyncCompleted()
        {
            IsBusy = false;

            try
            {
                AppSettings.ReloadSetting();
                SyncHelper.Instance.StartAutoSync(15);
            }
            catch (Exception ex)
            {
                await CoreMethods.DisplayAlert(TranslateExtension.GetValue("error"), ex.Message, TranslateExtension.GetValue("error"));

                Debug.WriteLine("ERROR:" + ex.Message);
            }
            //TODO find out reason
            if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
            {
                if (CrossDeviceInfo.Current.VersionNumber.Major >= 13)
                {
                    Application.Current.MainPage = new NavigationContainer(ViewModelResolver.ResolveViewModel <ViewModels.Login.LoginViewModel>())
                    {
                        BarBackgroundColor = Color.FromHex("#2196F3"),
                        BarTextColor       = Color.White
                    };
                    return;
                }
            }

            Application.Current.MainPage = new MainPage();
        }
示例#23
0
        internal override async Task LoadData(bool refreshData = false, bool FetchNextPage = false)
        {
            HasLoaded = false;
            if (BuildingId == 0)
            {
                return;
            }
            try
            {
                Building buildingDetails = await DataAccess.GetBuildingDetails(BuildingId);

                Units = buildingDetails.Units;
                foreach (var u in Units)
                {
                    u.BuildingId = BuildingId;
                }
                BuildingName = buildingDetails.BuildingShortAddress;
                HasLoaded    = true;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                await CoreMethods.DisplayAlert("Something went wrong", ex.Message, "DISMISS");

                APIhasFailed = true;
            }
        }
        private async void UpdatePIN(object sender, TaskCompletionSource <bool> tcs)
        {
            if (string.IsNullOrEmpty(tempPIN) || string.IsNullOrEmpty(tempConfirmPIN) || !tempPIN.Equals(tempConfirmPIN))
            {
                if (string.IsNullOrEmpty(tempPIN))
                {
                    await CoreMethods.DisplayAlert("Fail", "New PIN cannot be empty ", "OK");

                    tcs.SetResult(true);
                    return;
                }
                if (string.IsNullOrEmpty(tempConfirmPIN))
                {
                    await CoreMethods.DisplayAlert("Fail", "Confirmation PIN cannot be empty ", "OK");

                    tcs.SetResult(true);
                    return;
                }
                if (!tempPIN.Equals(tempConfirmPIN))
                {
                    await CoreMethods.DisplayAlert("Fail", "Confirm new PIN is not matching ", "OK");

                    tcs.SetResult(true);
                    return;
                }
            }
            Helpers.Settings.PIN = tempConfirmPIN;
            await CoreMethods.DisplayAlert("Successed", "You just created a new PIN", "OK");

            await CoreMethods.PopViewModel();

            tcs.SetResult(true);
        }
示例#25
0
        protected async Task <MediaFile> TakePhotoAsync()
        {
            await CrossMedia.Current.Initialize();

            if (!IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await CoreMethods.DisplayAlert(SportsGoResources.NoCamara, SportsGoResources.CamaraNoDisponible, "OK");

                return(null);
            }

            if (await CheckCameraPermissionAndAskForIt() && await CheckStoragePermissionAndAskForIt())
            {
                MediaFile file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                {
                    SaveToAlbum        = true,
                    CompressionQuality = 80,
                    PhotoSize          = PhotoSize.Large,
                    //AllowCropping = true
                });

                return(file);
            }
            else
            {
                if (await CoreMethods.DisplayAlert(SportsGoResources.PermisoDenegado, SportsGoResources.NoSePudoTomarFoto, "OK", SportsGoResources.Cancelar))
                {
                    //On iOS you may want to send your user to the settings screen.
                    CrossPermissions.Current.OpenAppSettings();
                }

                return(null);
            }
        }
示例#26
0
        async Task CheckAnswerAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                if (!IsItemInTheList(Answer, GivenAnswers.ToList()) && IsItemInTheList(Answer, CorrectAnswers))
                {
                    GivenAnswers.Add(Answer);
                    Score  = Score + 1;
                    Answer = string.Empty;
                }
            }
            catch (System.Exception ex)
            {
                await CoreMethods.DisplayAlert("", "Erro ao checar resposta", "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#27
0
        protected async Task <MediaFile> PickVideoAsync()
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsPickVideoSupported)
            {
                await CoreMethods.DisplayAlert(SportsGoResources.NoGaleria, SportsGoResources.GaleriaNoDisponible, "OK");

                return(null);
            }

            if (await CheckStoragePermissionAndAskForIt())
            {
                MediaFile file = await CrossMedia.Current.PickVideoAsync();

                return(file);
            }
            else
            {
                if (await CoreMethods.DisplayAlert(SportsGoResources.PermisoDenegado, SportsGoResources.NoSePudoPickearVideo, "OK", SportsGoResources.Cancelar))
                {
                    //On iOS you may want to send your user to the settings screen.
                    CrossPermissions.Current.OpenAppSettings();
                }

                return(null);
            }
        }
示例#28
0
 private async Task Raffle(object arg)
 {
     var random      = new Random();
     int winnerIndex = random.Next(0, ParticipantList.Count);
     var winner      = ParticipantList[winnerIndex];
     await CoreMethods.DisplayAlert("And the winner is....", winner.ToString(), "Ok");
 }
        /// <summary>
        /// Reloads the data.
        /// </summary>
        /// <returns>The data.</returns>
        /// <param name="isSilent">If set to <c>true</c> is silent.</param>
        async Task ReloadData(bool isSilent = false, bool force = false)
        {
            IsRefreshing = !isSilent;
            IsLoading    = true;

            try
            {
                if (Plugin.Connectivity.CrossConnectivity.Current.IsConnected)
                {
                    // Download jobs from server
                    var localJobs = await jobsApiService.GetJobsAsync(force);

                    // Group jobs by JobStatus
                    var groupedJobs = GroupJobs(localJobs);
                    Jobs.ReplaceRange(groupedJobs);
                }
                else
                {
                    await CoreMethods.DisplayAlert("Network Error", "No internet connectivity found", "OK");
                }
            }
            catch (Exception)
            {
                await CoreMethods.DisplayAlert("Error", "An error occured while communicating with the backend. Please check your settings and try again.", "Ok");
            }

            IsRefreshing = false;
            IsLoading    = false;
        }
示例#30
0
        private async Task ExecutePoofCommand()
        {
            try
            {
                if (!await LoginAsync())
                {
                    return;
                }

                LoadingMessage = "Adding Poof...";
                IsBusy         = true;

                //esiste overload per proprietà e metriche
                HockeyApp.MetricsManager.TrackEvent("Add Poof");

                //await Task.Delay(4000);
                await azureService.AddPoof(Justified, Comment, Settings.UserId);

                Comment   = null;
                Justified = false;
            }
            catch (Exception ex)
            {
                Insights.Report(ex, Insights.Severity.Error);
                await CoreMethods.DisplayAlert("Service Error", ex.Message, "OK");
            }
            finally
            {
                LoadingMessage = string.Empty;
                IsBusy         = false;
            }
        }