示例#1
0
        public static Toast DartsToast(Activity activity, string text, ToastLength toastLength)
        {
            Toast toast = Toast.MakeText(activity, text, toastLength);

            toast.SetGravity(GravityFlags.Center, 0, 0);
            return(toast);
        }
 private void ShowToast(string text, ToastLength duration = ToastLength.Short)
 {
     using (var toast = Toast.MakeText(this, text, duration))
     {
         toast.Show();
     }
 }
示例#3
0
 private void DoToastMessage(string text, ToastLength toastLength = ToastLength.Short)
 {
     try
     {
         // thread to force invoke into ui thread
         Task.Run(() =>
         {
             if (!this.IsFinishing)
             {
                 //if (Looper.MainLooper.IsCurrentThread)
                 {
                     // On UI thread.
                     RunOnUiThread(() =>
                     {
                         try
                         {
                             Toast toast = Toast.MakeText(this, text, toastLength);
                             toast.Show();
                         }
                         catch
                         {
                         }
                     });
                 }
             }
         });
     } catch {}
 }
        void loginSend(object sender, EventArgs eventArgs)
        {
            int          status         = 0;
            var          refreshedToken = FirebaseInstanceId.Instance.Token;
            login_result result         = new login_result();
            String       email          = FindViewById <EditText>(Resource.Id.input_email).Text;
            String       password       = FindViewById <EditText>(Resource.Id.input_password).Text;
            String       address        = "https://carshareserver.azurewebsites.net/api/Login?email=" + email + "&password="******"&token=" + refreshedToken;

            result.get_from_cloud(address);
            status = result.status;
            if (status != 1)
            {
                Context     context  = Application.Context;
                string      text     = "Wrong Email or Password";
                ToastLength duration = ToastLength.Long;
                var         toast    = Toast.MakeText(context, text, duration);
                toast.Show();
            }
            else
            {
                Preferences.Set("login_hash", result.login_hash);
                Preferences.Set("user_id", result.id);
                Intent main = new Intent(this, typeof(MainActivity));
                StartActivity(main);
                Finish();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.search_Layout);

            var searchField  = FindViewById <EditText>(Resource.Id.searchBarEditText);
            var searchButton = FindViewById <Button>(Resource.Id.searchButton);
            var listView     = FindViewById <ListView>(Resource.Id.searchListView);

            searchButton.Click += async delegate
            {
                var searchText  = searchField.Text;
                var queryString = "https://swapi.co/api/films/?search=" + searchText;
                var data        = await DataService.GetStarWarsFilms(queryString);

                listView.Adapter = new StarWarsFilmsAdapter(this, data.Results);
            };

            listView.ItemClick += (object sender, ItemClickEventArgs e) =>
            {
                var a = Convert.ToString(listView.GetItemIdAtPosition(e.Position));
                var b = Convert.ToString(e.Position);

                Context context = Application.Context;

                ToastLength duration = ToastLength.Short;
                var         toast    = Toast.MakeText(context, b, duration);
                toast.Show();
            };
        }
示例#6
0
        private async void ConnectButton_ClickAsync(object sender, EventArgs e)
        {
            if (bluetoothController.conncetionState == ConncetionSate.failed)
            {
                await bluetoothController.ConnectAsync(SelectedID);

                if (bluetoothController.conncetionState == ConncetionSate.sucsesful)
                {
                    Context     context  = Application.Context;
                    string      text     = "Успешно!";
                    ToastLength duration = ToastLength.Short;
                    var         toast    = Toast.MakeText(context, text, duration);
                    toast.Show();
                    TextView.Text = "Состояние: подключено";
                }
                else
                {
                    Context     context  = Application.Context;
                    string      text     = "Не удалось подключиться!";
                    ToastLength duration = ToastLength.Short;
                    var         toast    = Toast.MakeText(context, text, duration);
                    toast.Show();
                }
            }
        }
示例#7
0
 /// <summary>
 /// Showing Toast messages
 /// </summary>
 /// <param name="context">Context of activity or Application</param>
 /// <param name="toastMsg">Toast message</param>
 /// <param name="toastLength">Toast Length</param>
 public void ShowToast(Context context, string toastMsg, ToastLength toastLength)
 {
     if (context != null)
     {
         Toast.MakeText(context, toastMsg, toastLength).Show();
     }
 }
示例#8
0
        private void ShowOrUpdateToast(string message, ToastLength length)
        {
            var startTimer = false;

            if (_ToastTimer == null || !_ToastTimer.IsValid)
            {   // close any alert (EXCEPT working toast!) before the showing new toast
                CancelAlertController();

                _AlertController = UIAlertController.Create(null, message, UIAlertControllerStyle.ActionSheet);
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(_AlertController, true, () => {
                    // handle outside click
                    _AlertController.View?.Superview?.Subviews?.FirstOrDefault()?.AddGestureRecognizer(new UITapGestureRecognizer(CancelAlertController));
                });
                startTimer = true;
            }
            else if (_ToastTimer != null && _ToastTimer.IsValid &&
                     _AlertController != null && _AlertController == UIApplication.SharedApplication.KeyWindow.RootViewController.PresentedViewController)
            {
                _ToastTimer.Invalidate();
                _AlertController.Message = message;
                startTimer = true;
            }

            if (startTimer)
            {
                var toastMilliseconds = length == ToastLength.Long ? DialogConstants.TOAST_LONG_LENGTH : DialogConstants.TOAST_SHORT_LENGTH;
                _ToastTimer = NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds(toastMilliseconds), ToastTimeComplete);
            }
        }
示例#9
0
        public void ShowToast(string message, ToastLength length, PlatformCode usingPlatforms = PlatformCode.All)
        {
            if (!usingPlatforms.HasFlag(PlatformCode.Ios))
            {
                return;
            }

            Utilities.Dispatch(async() => {
                var shouldWait = false;

                do
                {
                    lock (_ToastLock)
                    {
                        shouldWait = _HasToast;
                        _HasToast  = true;
                    }

                    if (shouldWait)
                    {
                        await Task.Delay(DialogConstants.TOAST_CHECK_NEXT_DELAY);
                    }
                }while (shouldWait);

                ShowOrUpdateToast(message, length);

                var toastTime = length == ToastLength.Long ? DialogConstants.TOAST_LONG_LENGTH : DialogConstants.TOAST_SHORT_LENGTH;
                await Task.Delay(toastTime / 2);

                lock (_ToastLock)
                {
                    _HasToast = false;
                }
            });
        }
        public void getItemData(string barcode)
        {
            string url = "http://192.168.102.79/StoreImages/itemCode.php?code=" + barcode;

            WebClient client         = new WebClient();
            string    downloadString = client.DownloadString(url);
            var       item           = JsonConvert.DeserializeObject <Examples>(downloadString);
            string    precio         = item.precio;
            string    producto       = item.name;
            string    codigo         = item.code;
            string    categoriaData  = item.categoria;
            string    uomCode        = item.uom;

            if (producto == "")
            {
                Context     context  = Application.Context;
                string      text     = "No se encontro producto";
                ToastLength duration = ToastLength.Long;

                var toast = Toast.MakeText(context, text, duration);
                toast.Show();

                sendToMain();
            }

            productoView = FindViewById <TextView>(Resource.Id.textViewNombreProductos);
            precioView   = FindViewById <TextView>(Resource.Id.textViewPrecio);
            medida       = FindViewById <TextView>(Resource.Id.textViewMedida);

            productoView.Text = producto;
            precioView.Text   = "$" + precio;
            medida.Text       = "MEDIDA: " + uomCode;
        }
示例#11
0
        public static void ShowAlert(this Context context, ErrorBase error, ToastLength length)
        {
            if (error == null || error is CanceledError)
            {
                return;
            }

            var message = error.Message;

            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            var lm = AppSettings.LocalizationManager;

            if (!lm.ContainsKey(message))
            {
                if (error is BlockchainError blError)
                {
                    AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(blError.Message)}{Environment.NewLine}Full Message:{blError.FullMessage}");
                }
                else
                {
                    AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(message)}");
                }
                message = nameof(LocalizationKeys.UnexpectedError);
            }

            Toast.MakeText(context, lm.GetText(message), length).Show();
        }
示例#12
0
        public static void ShowToast(string content, ToastLength length = ToastLength.Short)
        {
            var toast = Toast.MakeText(_context, content, length);

            toast.SetGravity(GravityFlags.Center, 0, 0);
            toast.Show();
        }
示例#13
0
        public void CreateToast(Context context, string message)
        {
            ToastLength duration = ToastLength.Short;

            var toast = Toast.MakeText(context, message, duration);

            toast.Show();
        }
示例#14
0
 private void Showpopup(string msg, ToastLength length)
 {
     this.RunOnUiThread(() =>
     {
         var toast = Toast.MakeText(this, msg, length);
         toast.Show();
     });
 }
示例#15
0
 public static void ShowAlert(this Context context, OperationResult response, ToastLength length)
 {
     if (response == null)
     {
         return;
     }
     ShowAlert(context, response.Error, length);
 }
示例#16
0
 public static void ShowAlert(this Context context, ErrorBase error, ToastLength length)
 {
     if (error == null)
     {
         return;
     }
     ShowAlert(context, error.Message, length);
 }
示例#17
0
 public void ShowToastMessage(String message, ToastLength ts)
 {
     context.RunOnUiThread(() =>
     {
         toastMessenger = Toast.MakeText(context, message, ts);
         toastMessenger.Show();
     });
 }
示例#18
0
 public static void Toast(this Context context, string text, ToastLength duration = ToastLength.Short)
 {
     if (mContext == null)
     {
         return;
     }
     Android.Widget.Toast.MakeText(context, text, duration).Show();
 }
示例#19
0
        public static void ShowToast(Context context, View view, ToastLength duration = ToastLength.Short)
        {
            var toast = new Toast(context);

            toast.View     = view;
            toast.Duration = duration;
            toast.Show();
        }
示例#20
0
        public static void ToastMessage(string message)
        {
            Android.Content.Context context = Android.App.Application.Context;
            string      tostMessage         = message;
            ToastLength duration            = ToastLength.Long;


            Toast.MakeText(context, tostMessage, duration).Show();
        }
示例#21
0
        public static void ShowToast(Context context, string text, ToastLength length)
        {
            Handler handler = new Handler(Looper.MainLooper);

            handler.Post(() =>
            {
                Toast.MakeText(context, text, length).Show();
            });
        }
示例#22
0
        public static void draw()
        {
            Context     context  = Application.Context;
            string      text     = "Draw cool";
            ToastLength duration = ToastLength.Short;
            var         toast    = Toast.MakeText(context, text, duration);

            toast.Show();
        }
示例#23
0
        public static void Toast(string title, string message, ToolTipIcon icon, ToastLength length)
        {
            if (nIcon == null)
            {
                throw new WarningException("Toaster must be initialized with Initialize() method.");
            }

            nIcon.ShowBalloonTip((int)length, title, message, icon);
        }
示例#24
0
 private static void Show(Context context, string text, ToastLength length)
 {
     if (OnlyToast != null)
     {
         OnlyToast.Cancel();
     }
     OnlyToast = Toast.MakeText(context, text, length);
     OnlyToast.Show();
 }
示例#25
0
    /// <summary>
    /// Shows an android Toast message on the screen.
    /// </summary>
    /// <param name="message"> The message to be shown.</param>
    /// <param name="length"> The length for which the message appears.</param>
    public void Toast(string message, ToastLength length)
    {
        AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");

        currentActivity  = UnityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
        this.toastString = message;
        this.toastLength = Enum.GetName(typeof(ToastLength), (int)length);
        currentActivity.Call("runOnUiThread", new AndroidJavaRunnable(showToast));
    }
示例#26
0
        /// <summary>
        /// Shows a toast
        /// </summary>
        /// <param name="toastText">Text to show on the toast</param>
        /// <param name="toastLength">Length of the toast</param>
        public static void ShowToast(string toastText, ToastLength toastLength)
        {
#if UNITY_EDITOR
            return;
#elif UNITY_ANDROID
            ShowToast_Android(toastText, toastLength == ToastLength.Long);
#elif UNITY_IOS
#endif
        }
示例#27
0
        public static void player1Wins()
        {
            Context     context  = Application.Context;
            string      text     = "Player 2 cool";
            ToastLength duration = ToastLength.Short;
            var         toast    = Toast.MakeText(context, text, duration);

            toast.Show();
        }
示例#28
0
        public static void ShowToast(string message, ToastLength length)
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            m_ToastMessage = message;
            m_ToastLength  = length;
            var activity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            activity.Call("runOnUiThread", new AndroidJavaRunnable(ShowToast));
#endif
        }
示例#29
0
        public static void ShowAlert(this Context context, string message, ToastLength length)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            Toast.MakeText(context, message, length).Show();
        }
示例#30
0
        public static void ShowToast(Context aContext, string aText, ToastLength aToastLength)
        {
            Toast lToast = Toast.MakeText(aContext, aText, aToastLength);

            lToast.View.SetBackgroundResource(Resource.Drawable.default_toast);
            TextView lView = (TextView)lToast.View.FindViewById <TextView>(Android.Resource.Id.Message);

            lView.Gravity = GravityFlags.Center;
            lToast.Show();
        }
示例#31
0
 public static void ShowMessage(int stringID, ToastLength duration)
 {
     if (CustomApplication.Instance.ApplicationIsInForeground)
     {
         Activity currentActivity = CustomApplication.Instance.CurrentActivity;
         if (currentActivity != null)
         {
             currentActivity.RunOnUiThread(() => { Toast.MakeText(currentActivity, stringID, duration).Show(); });
         }
     }
 }
示例#32
0
 public static void ShowMessage(string message, ToastLength duration)
 {
     if (CustomApplication.Instance.ApplicationIsInForeground)
     {
         Activity currentActivity = CustomApplication.Instance.CurrentActivity;
         if (currentActivity != null)
         {
             currentActivity.RunOnUiThread(() => { Toast.MakeText(currentActivity, message, duration).Show(); });
         }
     }
     else
     {
         DebugLog.Instance.MyLog(message);
     }
 }
			static public void ShowToast(Activity activity, string message, ToastLength duration = ToastLength.Short){
				LayoutInflater inflater = activity.LayoutInflater;
				View layout = inflater.Inflate(Resource.Layout.toast, (ViewGroup) activity.FindViewById(Resource.Id.toast_layout_root));
				TextView text = (TextView) layout.FindViewById(Resource.Id.toast_text);
				text.SetText(message, TextView.BufferType.Normal);
				Toast toast = new Toast(activity.ApplicationContext);
				toast.SetGravity(GravityFlags.CenterVertical, 0, 0);
				toast.Duration = duration;
				toast.View = layout;
				toast.Show();
			}
		private void ShowToast(string message, ToastLength duration = ToastLength.Short){
			LayoutInflater inflater = LayoutInflater;
			View layout = inflater.Inflate(Resource.Layout.toast, (ViewGroup) FindViewById(Resource.Id.toast_layout_root));
			//ImageView image = (ImageView) layout.FindViewById(Resource.Id.toast_image);
			//image.SetImageResource(Resource.Drawable.Icon);
			TextView text = (TextView) layout.FindViewById(Resource.Id.toast_text);
			text.SetText(message, TextView.BufferType.Normal);
			Toast toast = new Toast(ApplicationContext);
			toast.SetGravity(GravityFlags.CenterVertical, 0, 0);
			toast.Duration = duration;
			toast.View = layout;
			toast.Show();
		}
		public void toastJson(Context context, JsonValue json, ToastLength length, string alternativeMessage) {
			Context c = (context != null) ? context : mainActivity;
			string message = (json.ContainsKey("message")) ? json["message"].ToString() : alternativeMessage;
			Toast.MakeText(c, message, length).Show();
		}
示例#36
0
 private static double DurationFromToastLength(ToastLength toastLength)
 {
     double duration=kDefaultLength;
     switch (toastLength)
     {
         case ToastLength.Long: duration = kDefaultLengthLong; break;
         case ToastLength.Short: duration = kDefaultLengthShort; break;
     }
     return duration;
 }
示例#37
0
 public static void ShowToast(this UIView self,String message,ToastLength toastLength,CGPoint position,string title=null,UIImage image=null)
 {
     UIView toast = self.MakeViewForMessage(message,title,image);
     self.ShowToastViewAtPosition(toast,DurationFromToastLength(toastLength),position);
 }
示例#38
0
 /// <summary>
 /// Shows the android toast message.
 /// </summary>
 /// <param name="message">Message string to show in the toast.</param>
 /// <param name="length">Toast message time length.</param>
 private static void _ShowAndroidToastMessage(string message, ToastLength length)
 {
     AndroidJavaObject unityActivity = GetUnityActivity();
     
     if (unityActivity != null)
     {
         try
         {
             AndroidJavaClass toastClass = new AndroidJavaClass("android.widget.Toast");
             unityActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
             {
                 AndroidJavaObject toastObject = toastClass.CallStatic<AndroidJavaObject>("makeText", unityActivity, message, (int)length);
                 toastObject.Call("show");
             }));
         }
         catch (AndroidJavaException e)
         {
             Debug.Log("AndroidJavaException : " + e.Message);
         }
     }
 }
示例#39
0
 /// <summary>
 /// Shows the android toast message.
 /// </summary>
 /// <param name="message">Message string to show in the toast.</param>
 /// <param name="length">Toast message time length.</param>
 public static void ShowAndroidToastMessage(string message, ToastLength length)
 {
     _ShowAndroidToastMessage(message, length);
 }