Beispiel #1
0
        protected override void OnPause()
        {
            refreshCancellationTokenSource?.Cancel();
            snackbar?.Dismiss();

            base.OnPause();
        }
Beispiel #2
0
        private void Snackbar_Retry(View v)
        {
            snackbar?.Dismiss();
            snackbar = null;

            Refresh();
        }
Beispiel #3
0
        public void NotifyPermanent(string message)
        {
            //dismiss previous
            currentSnackBar?.Dismiss();

            //create new
            var snack = MakeAndShowSnackbar(message, int.MaxValue);

            currentSnackBar = snack;
        }
Beispiel #4
0
        protected virtual IDisposable ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            Snackbar snackBar = null;

            activity.RunOnUiThread(() =>
            {
                var view = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
                snackBar = Snackbar.Make(
                    view,
                    Html.FromHtml(cfg.Message),
                    (int)cfg.Duration.TotalMilliseconds
                    );
                this.TrySetToastTextColor(snackBar, cfg);
                if (cfg.BackgroundColor != null)
                {
                    snackBar.View.SetBackgroundColor(cfg.BackgroundColor.Value.ToNative());
                }

                if (cfg.Action != null)
                {
                    snackBar.SetAction(cfg.Action.Text, x =>
                    {
                        cfg.Action?.Action?.Invoke();
                        snackBar.Dismiss();
                    });
                    var color = cfg.Action.TextColor ?? ToastConfig.DefaultActionTextColor;
                    if (color != null)
                    {
                        snackBar.SetActionTextColor(color.Value.ToNative());
                    }
                }
                snackBar.Show();
            });
            return(new DisposableAction(() =>
            {
                if (snackBar.IsShown)
                {
                    activity.RunOnUiThread(() =>
                    {
                        try
                        {
                            snackBar.Dismiss();
                        }
                        catch
                        {
                            // catch and swallow
                        }
                    });
                }
            }));
        }
Beispiel #5
0
        private void Render(string error)
        {
            if (string.IsNullOrEmpty(error))
            {
                if (_snackbar == null)
                {
                    return;
                }
                if (_snackbar.IsShownOrQueued)
                {
                    _snackbar.Dismiss();
                }
                return;
            }

            if (_snackbar == null)
            {
                _snackbar = Snackbar.Make(_container, error, Snackbar.LengthIndefinite);
            }
            else
            {
                _snackbar.SetText(error);
            }

            _snackbar.Show();
        }
Beispiel #6
0
        private void UndoButton_Clicked(object sender, EventArgs e)
        {
            Snackbar snackbar = Snackbar.Make(statInputSwitcher, myViewModel.Undo(), Snackbar.LengthLong);

            snackbar.SetAction("Dismis", v => snackbar.Dismiss());
            snackbar.Show();
        }
Beispiel #7
0
 private void hideLoadingMessage()
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         mLoadingMessageSnackbar.Dismiss();
         mLoadingMessageSnackbar = null;
     });
 }
Beispiel #8
0
 private void HideLoadingMessage()
 {
     this.RunOnUiThread(() =>
     {
         loadingMessageSnackbar?.Dismiss();
         loadingMessageSnackbar = null;
     });
 }
 private void hideLoadingMessage()
 {
     this.RunOnUiThread(() =>
     {
         mLoadingMessageSnackbar.Dismiss();
         mLoadingMessageSnackbar = null;
     });
 }
Beispiel #10
0
        public void HideSnackbar()
        {
            if (_snackbar != null)
            {
                _snackbar.Dismiss();
            }

            _snackbar = null;
        }
Beispiel #11
0
        async void DismissSnackbar()
        {
            await Task.Delay(6000);

            if (_GPSSnackbar != null)
            {
                _GPSSnackbar.Dismiss();
            }
        }
        private void HideLoadingMessage()
        {
            if (loadingMessageSnackbar == null)
            {
                return;
            }

            loadingMessageSnackbar.Dismiss();
            loadingMessageSnackbar = null;
        }
        protected virtual IDisposable ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            Snackbar snackBar = null;

            activity.SafeRunOnUi(() =>
            {
                var view = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
                var msg  = this.GetSnackbarText(cfg);

                snackBar = Snackbar.Make(
                    view,
                    msg,
                    (int)cfg.Duration.TotalMilliseconds
                    );
                if (cfg.BackgroundColor != null)
                {
                    snackBar.View.SetBackgroundColor(cfg.BackgroundColor.Value.ToNative());
                }

                if (cfg.Position == ToastPosition.Top)
                {
                    // watch for this to change in future support lib versions
                    var layoutParams = snackBar.View.LayoutParameters as FrameLayout.LayoutParams;
                    if (layoutParams != null)
                    {
                        layoutParams.Gravity = GravityFlags.Top;
                        layoutParams.SetMargins(0, 80, 0, 0);
                        snackBar.View.LayoutParameters = layoutParams;
                    }
                }
                if (cfg.Action != null)
                {
                    snackBar.SetAction(cfg.Action.Text, x =>
                    {
                        cfg.Action?.Action?.Invoke();
                        snackBar.Dismiss();
                    });
                    var color = cfg.Action.TextColor;
                    if (color != null)
                    {
                        snackBar.SetActionTextColor(color.Value.ToNative());
                    }
                }

                snackBar.Show();
            });
            return(new DisposableAction(() =>
            {
                if (snackBar.IsShown)
                {
                    activity.SafeRunOnUi(snackBar.Dismiss);
                }
            }));
        }
Beispiel #14
0
        protected virtual IDisposable ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            Snackbar snackBar = null;

            activity.SafeRunOnUi(() =>
            {
                var view = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
                var msg  = this.GetSnackbarText(cfg);


                snackBar = Snackbar.Make(
                    view,
                    msg,
                    (int)cfg.Duration.TotalMilliseconds
                    );
                if (cfg.BackgroundColor != null)
                {
                    snackBar.View.SetBackgroundColor(cfg.BackgroundColor.Value.ToNative());
                }

                this.SetLayoutMargins(snackBar, cfg);

                if (cfg.Action != null)
                {
                    snackBar.SetAction(cfg.Action.Text, x =>
                    {
                        cfg.Action?.Action?.Invoke();
                        snackBar.Dismiss();
                    });
                    var color = cfg.Action.TextColor;
                    if (color != null)
                    {
                        snackBar.SetActionTextColor(color.Value.ToNative());
                    }
                }

                snackBar.Show();
            });
            return(new DisposableAction(() =>
            {
                if (snackBar.IsShown)
                {
                    activity.SafeRunOnUi(snackBar.Dismiss);
                }
            }));
        }
Beispiel #15
0
        private void GoogleMap_MyLocationButtonClick(object sender, GoogleMap.MyLocationButtonClickEventArgs e)
        {
            snackbar?.Dismiss();

            float    zoom     = googleMap.CameraPosition.Zoom;
            Location location = googleMap.MyLocation;

            if (location == null)
            {
                snackbar = Snackbar.Make(View, "Données GPS non disponibles", Snackbar.LengthIndefinite);
                snackbar.Show();

                return;
            }

            CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(new LatLng(location.Latitude, location.Longitude), Math.Max(zoom, TramUrWayApplication.MyLocationZoom));

            googleMap.AnimateCamera(cameraUpdate);
        }
Beispiel #16
0
        private void SetStatisticLayout()
        {
            switch (myCurrentStatToGet)
            {
            case EStatisticType.DefensiveRebound:
                statInputSwitcher.DisplayedChild = statInputSwitcher.IndexOfChild(statInputSwitcher.FindViewById <LinearLayout>(Resource.Id.twoChoice));
                actionButtonLayout.Visibility    = ViewStates.Visible;
                statInputSwitcher.CurrentView.FindViewById <MultiLineRadioGroup>(Resource.Id.radioGroup1).SetToDefault();
                break;

            case EStatisticType.Goal:
            case EStatisticType.ConcededGoal:
            case EStatisticType.ConcededShot:
            case EStatisticType.Interception:
            case EStatisticType.Turnover:
            case EStatisticType.Shot:
            case EStatisticType.Assist:
            case EStatisticType.Rebound:
                statInputSwitcher.DisplayedChild = statInputSwitcher.IndexOfChild(statInputSwitcher.FindViewById <LinearLayout>(Resource.Id.four4Choice));
                SetPlayers();
                break;

            case EStatisticType.GoalType:
                statInputSwitcher.DisplayedChild = statInputSwitcher.IndexOfChild(statInputSwitcher.FindViewById <LinearLayout>(Resource.Id.goaltype));
                statInputSwitcher.CurrentView.FindViewById <MultiLineRadioGroup>(Resource.Id.radioGroup1).SetToDefault();
                break;

            default:
                statInputSwitcher.DisplayedChild = statInputSwitcher.IndexOfChild(statInputSwitcher.FindViewById <LinearLayout>(Resource.Id.buttonLayout));
                actionButtonLayout.Visibility    = ViewStates.Gone;

                Snackbar snackbar = Snackbar.Make(statInputSwitcher, myViewModel.ExecuteCommand(), Snackbar.LengthLong);
                snackbar.SetAction("Dismis", v => snackbar.Dismiss());
                snackbar.Show();
                break;
            }
            TextView header = statInputSwitcher.CurrentView.FindViewById <TextView>(Resource.Id.headerText);

            if (header != null)
            {
                header.Text = myCurrentStatToGet.GetDescription();
            }
        }
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
 {
     if (_rationalSnackBar != null && _rationalSnackBar.IsShown)
     {
         _rationalSnackBar.Dismiss();
     }
     switch (requestCode)
     {
     case STORAGE_PERMISSION_CODE:
     {
         if (grantResults[0] == Permission.Granted)
         {
             ClearPreviousDataOnFirstRun();
         }
         else
         {
             Snackbar.Make(_splashScreenParent, Resource.String.permission_denied_alert, Snackbar.LengthLong).SetAction("OK", (view) => { }).Show();
         }
         LaunchBookshelf();
         break;
     }
     }
 }
        public static void ShowSnackbar(Activity activity, SnackbarConfig config)
        {
            var view = activity.Window.DecorView.RootView.FindViewById(global::Android.Resource.Id.Content);

            if (_snackbar == null)
            {
                _snackbar = Snackbar.Make(view, config.Message, (int)config.Duration.TotalMilliseconds);
            }

            if (_snackbar.IsShownOrQueued)
            {
                _snackbar = Snackbar.Make(view, config.Message, (int)config.Duration.TotalMilliseconds);
            }

            _snackbar.SetDuration((int)config.Duration.TotalMilliseconds);
            _snackbar.SetText(config.Message);

            if (!string.IsNullOrWhiteSpace(config.ActionText))
            {
                _snackbar.SetAction(config.ActionText, (v) =>
                {
                    config.Action?.Invoke();

                    _snackbar.Dismiss();
                });

                if (config.ActionTextColor.HasValue)
                {
                    _snackbar.SetActionTextColor(config.ActionTextColor.Value.ToNativeColor());
                }
            }

            if (config.TextColor.HasValue)
            {
                //TextView textView = _snackbar.View.FindViewById<TextView>(Resource.Id.snackbar_text);
                //textView.SetTextColor(config.TextColor.Value.ToNativeColor());

                // TODO
            }

            if (config.BackgroundColor.HasValue)
            {
                //TextView textView = _snackbar.View.FindViewById<TextView>(Resource.Id.snackbar_text);
                //textView.SetBackgroundColor(config.BackgroundColor.Value.ToNativeColor());

                // TODO
            }

            //if (config.Position != ToastPosition.Default)
            //{
            //    // watch for this to change in future support lib versions
            //    var layoutParams = _snackbar.View.LayoutParameters as FrameLayout.LayoutParams;
            //    if (layoutParams != null)
            //    {
            //        if (config.Position == ToastPosition.Top)
            //        {
            //            layoutParams.Gravity = GravityFlags.Top;
            //            layoutParams.SetMargins(0, 80, 0, 0);
            //        }
            //        else if (config.Position == ToastPosition.Center)
            //        {
            //            layoutParams.Gravity = GravityFlags.Center;
            //        }
            //        else if (config.Position == ToastPosition.Bottom)
            //        {
            //            layoutParams.Gravity = GravityFlags.Bottom;
            //            layoutParams.SetMargins(0, 0, 0, 30);
            //        }

            //        _snackbar.View.LayoutParameters = layoutParams;
            //    }
            //}

            _snackbar.Show();
        }
Beispiel #19
0
        protected override void OnPause()
        {
            snackbar?.Dismiss();

            base.OnPause();
        }
 public static void Hide()
 {
     _snackbar?.Dismiss();
 }