コード例 #1
0
        private async void OnFavoriteTapped(object sender, EventArgs e)
        {
            var obj = sender as Image;

            Device.BeginInvokeOnMainThread(() =>
            {
                try
                {
                    obj.ScaleTo(1.3, 75).ContinueWith((t) =>
                    {
                        try
                        {
                            obj.ScaleTo(1.0, 75);
                        }
                        catch
                        {
                        }
                    },
                                                      scheduler: TaskScheduler.FromCurrentSynchronizationContext());
                }
                catch
                {
                }
            });

            if (Helpers.Settings.DisplayUserRole == Enums.UserRole.Guest.ToString())
            {
                App.AppCurrent.AlertToGuest();
                return;
            }

            try
            {
                Acr.UserDialogs.UserDialogs.Instance.ShowLoading(AppResource.alertLoading);


                var result = await service.AddRemoveCompanyFavorite(Company.Id);

                Company.IsFavorited = JsonConvert.DeserializeObject <bool>(result);
                imgHeart.Source     = Company.IsFavorited ? "ic_heart_detail" : "ic_heart_detail_off";
            }
            catch (Exception ex)
            {
            }
            finally
            {
                Acr.UserDialogs.UserDialogs.Instance.HideLoading();
            }
        }
コード例 #2
0
        private async void OnFavoriteTapped(object sender, EventArgs e)
        {
            Image obj = sender as Image;

            Device.BeginInvokeOnMainThread(() =>
            {
                try
                {
                    obj.ScaleTo(1.3, 75).ContinueWith((t) =>
                    {
                        try
                        {
                            obj.ScaleTo(1.0, 75);
                        }
                        catch
                        {
                        }
                    },
                                                      scheduler: TaskScheduler.FromCurrentSynchronizationContext());
                }
                catch
                {
                }
            });

            try
            {
                Acr.UserDialogs.UserDialogs.Instance.ShowLoading(AppResource.alertLoading);


                string result = await _service.AddRemoveCompanyFavorite(_company.Id);

                _company.IsFavorited = JsonConvert.DeserializeObject <bool>(result);
                imgHeart.Source      = _company.IsFavorited ? "ic_heart_detail" : "ic_heart_detail_off";
            }
            catch (Exception)
            {
            }
            finally
            {
                Acr.UserDialogs.UserDialogs.Instance.HideLoading();
            }
        }