Exemplo n.º 1
0
        public static void ShowToast(string message, ToastDuration duration = ToastDuration.Short)
        {
            CheckInstance();

            ToastsQueue.Enqueue(ToastStructure.CreateToast(message, duration));
            if (toastCoroutine == null)
            {
                toastCoroutine = Instance.StartCoroutine(ShowToastsQueueCoroutine());
            }
        }
Exemplo n.º 2
0
 private static void ShowToast(ToastStructure toast)
 {
     // Instance.Log("ShowToast", "Showing " + toast.message + " for a " + toast.duration + " time.");
     UnityActivity?.Call("runOnUiThread", new AndroidJavaRunnable(() =>
     {
         ToastObject.Call("setText", toast.message);
         ToastObject.Call("setDuration", (int)toast.duration);
         ToastObject.Call("show");
     }));
 }
Exemplo n.º 3
0
        private static IEnumerator ShowToastsQueueCoroutine()
        {
            while (ToastsQueue.Count > 0)
            {
                ToastStructure toast = ToastsQueue.Dequeue();
                ShowToast(toast);
                yield return(new WaitForSeconds(toast.DurationInSeconds()));
            }

            AndroidManager.toastCoroutine = null;
        }
Exemplo n.º 4
0
 /// <summary>Shows a toast according to the given toast structure.</summary>
 private static void ShowToast(ToastStructure toast)
 {
     // Instance.Log("ShowToast", "Queue Remains: " + ToastsQueue.Count + "\nShowing: " + toast);
     CurrentActivity?.Call("runOnUiThread", new AndroidJavaRunnable(() =>
     {
         ToastObject.Call("setText", toast.message);
         ToastObject.Call("setDuration", (int)toast.duration);
         ToastObject.Call("show");
     }));
     // Instance.Log("ShowToast", "Toasted: " + toast);
 }
Exemplo n.º 5
0
        private static IEnumerator ShowToastsQueueCoroutine()
        {
            while (ToastsQueue.Count > 0)
            {
                ToastStructure toast = ToastsQueue.Dequeue();
                try
                { ShowToast(toast); }
                catch (Exception exception)
                { Instance.Error("ShowToastsQueueCoroutine", "Failed to send " + toast + "\n" + exception); }
                yield return(new WaitForSeconds(toast.DurationInSeconds() + 0.5f));
            }

            toastCoroutine = null;
        }