using System;
using System.Collections;
using UnityEngine;

namespace AssemblyCSharp
{
	public class SoonToast : MonoBehaviour {
		
		// Use this for initialization
		void Start() {
		}

		string toastString { get; set; }
		AndroidJavaObject currentActivity;

		public void MyShowToast()
		{
			if (Application.platform == RuntimePlatform.Android) {
				showToastOnUiThread("This feature is coming soon!");
			}
		}

		void showToastOnUiThread(string toastString){
			AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");

			currentActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
			this.toastString = toastString;

			currentActivity.Call ("runOnUiThread", new AndroidJavaRunnable (showToast));
		}

		void showToast(){
			Debug.Log ("Running on UI thread");
			AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");
			AndroidJavaClass Toast = new AndroidJavaClass("android.widget.Toast");
			AndroidJavaObject javaString=new AndroidJavaObject("java.lang.String",toastString);
			AndroidJavaObject toast = Toast.CallStatic<AndroidJavaObject> ("makeText", context, javaString, Toast.GetStatic<int>("LENGTH_SHORT"));
			toast.Call ("show");
		}

	}
}

