public void OnClick_MyBookSelfItem(int bookId) { TextButtonSelectBook.text = "Delete this book"; AndroidNativeFunctions.ShowProgressDialog("Loading . . ."); currentBookID = bookId; StartCoroutine(LoadBookDetail(bookId, action1 => { var bookDetail = JsonUtility.FromJson <BookData>(action1.downloadHandler.text); StartCoroutine(LoadBookPicture(bookDetail.image, action3 => { var texture = DownloadHandlerTexture.GetContent(action3); BookDetail_BookPicture.sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); })); BookDetail_BookName.text = bookDetail.book_name; BookDetail_BookDescription.text = bookDetail.description; StartCoroutine(LoadUserProfile(int.Parse(bookDetail.user_creator), action2 => { print(action2.downloadHandler.text); var userProfile = JsonUtility.FromJson <UserProfile>(action2.downloadHandler.text); StartCoroutine(LoadBookPicture(userProfile.image, action3 => { var texture = DownloadHandlerTexture.GetContent(action3); BookDetail_ProfilePicture.sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); AndroidNativeFunctions.HideProgressDialog(); UIManager.ShowBookDetail(); })); BookDetail_ProfileName.text = userProfile.name; })); })); }
public void OnClick_NotificationItem(int i) { AndroidNativeFunctions.ShowProgressDialog("Loading . . ."); StartCoroutine(SeeOfferAPI(i.ToString(), action => { print(action.downloadHandler.text); var con = JsonUtility.FromJson <confirmation>(action.downloadHandler.text); numberOfTransaction = int.Parse(con.me.number); confirmation_OfferBookName.text = con.offer.book_name; confirmation_OfferBookDescription.text = con.offer.description; confirmation_OfferName.text = con.offer.name; confirmation_MeBookDescription.text = con.me.description; confirmation_MeBookName.text = con.me.book_name; StartCoroutine(LoadBookPicture(con.offer.image, pic => { var texture = DownloadHandlerTexture.GetContent(pic); confirmation_offerPicture.sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); StartCoroutine(LoadBookPicture(con.offer.user_image, pic2 => { var texture1 = DownloadHandlerTexture.GetContent(pic2); confirmation_userPicture.sprite = Sprite.Create(texture1, new Rect(0.0f, 0.0f, texture1.width, texture1.height), new Vector2(0.5f, 0.5f), 100.0f); StartCoroutine(LoadBookPicture(con.me.image, pic3 => { var texture2 = DownloadHandlerTexture.GetContent(pic3); confirmation_mePicture.sprite = Sprite.Create(texture2, new Rect(0.0f, 0.0f, texture2.width, texture2.height), new Vector2(0.5f, 0.5f), 100.0f); UIManager.ShowConfirmation(); AndroidNativeFunctions.HideProgressDialog(); })); })); })); })); }
public void OnClick_MyBookItem(int bookId) { var OfferData = new offerData() { book_deal = currentBookID.ToString(), book_offer = bookId.ToString(), user_deal = currentUserID.ToString() }; AndroidNativeFunctions.ShowProgressDialog("Loading . . ."); StartCoroutine(SentOfferAPI(OfferData, action => { var TemList = new List <Transform>(); int x = MarketPage.childCount; for (int i = 0; i < x; i++) { TemList.Add(MarketPage.GetChild(i)); } for (int i = 0; i < x; i++) { Destroy(TemList[i].gameObject); } TemList.Clear(); x = MyBookPage.childCount; for (int i = 0; i < x; i++) { TemList.Add(MyBookPage.GetChild(i)); } for (int i = 0; i < x; i++) { Destroy(TemList[i].gameObject); } TemList.Clear(); x = MyBookSelectPage.childCount; for (int i = 0; i < x; i++) { TemList.Add(MyBookSelectPage.GetChild(i)); } for (int i = 0; i < x; i++) { Destroy(TemList[i].gameObject); } LoadBook(); UIManager.ShowDialog(); AndroidNativeFunctions.HideProgressDialog(); })); }
private static IEnumerator LoginAPI(LoginData loginData, Action <UnityWebRequest> callBack) { var request = new UnityWebRequest($"{Config.URL()}/users/login", "POST"); request.uploadHandler = new UploadHandlerRaw(new UTF8Encoding().GetBytes(JsonUtility.ToJson(loginData))); request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); request.SendWebRequest(); AndroidNativeFunctions.ShowProgressDialog($"Loading . . ."); while (!request.isDone) { yield return(null); } AndroidNativeFunctions.HideProgressDialog(); callBack(request); }
void Window1() { if (GUI.Button(NewRect(5, 5, 40, 10), "Start App", style)) { AndroidNativeFunctions.StartApp("com.google.android.youtube", false); } if (GUI.Button(NewRect(5, 20, 40, 10), "Get Installed Apps", style)) { List <PackageInfo> packageInfo = AndroidNativeFunctions.GetInstalledApps(); for (int i = 0; i < packageInfo.Count; i++) { print("firstInstallTime:" + packageInfo[i].firstInstallTime + " , lastUpdateTime: " + packageInfo[i].lastUpdateTime + " , packageName: " + packageInfo[i].packageName + " , versionCode: " + packageInfo[i].versionCode + " , versionName: " + packageInfo[i].versionName); } } if (GUI.Button(NewRect(5, 35, 40, 10), "Get App Info", style)) { PackageInfo packageInfo = AndroidNativeFunctions.GetAppInfo(); //PackageInfo packageInfo = AndroidNativeFunctions.GetAppInfo("com.google.android.youtube"); print("firstInstallTime:" + packageInfo.firstInstallTime + " , lastUpdateTime: " + packageInfo.lastUpdateTime + " , packageName: " + packageInfo.packageName + " , versionCode: " + packageInfo.versionCode + " , versionName: " + packageInfo.versionName); } if (GUI.Button(NewRect(5, 50, 40, 10), "Get Device Info", style)) { DeviceInfo deviceInfo = AndroidNativeFunctions.GetDeviceInfo(); print(" CODENAME: " + deviceInfo.CODENAME + " , INCREMENTAL: " + deviceInfo.INCREMENTAL + " , RELEASE: " + deviceInfo.RELEASE + " , SDK: " + deviceInfo.SDK); } if (GUI.Button(NewRect(5, 65, 40, 10), "Get Android ID", style)) { print("Android ID: " + AndroidNativeFunctions.GetAndroidID()); } if (GUI.Button(NewRect(55, 5, 40, 10), "Share Text", style)) { AndroidNativeFunctions.ShareText("Hello World", "Subject", "Share Text"); } if (GUI.Button(NewRect(55, 20, 40, 10), "Share Image", style)) { AndroidNativeFunctions.ShareImage("Hello World", "Subject", "Share Text", shareTexture); } if (GUI.Button(NewRect(55, 35, 40, 10), "Show Progress Dialog", style)) { AndroidNativeFunctions.ShowProgressDialog("Wait 2 seconds please"); Invoke("HideProgressDialog", 2); } if (GUI.Button(NewRect(55, 50, 40, 10), "Show Toast", style)) { AndroidNativeFunctions.ShowToast("Hello World", false); } if (GUI.Button(NewRect(55, 65, 40, 10), "Immersive Mode", style)) { AndroidNativeFunctions.ImmersiveMode(); } if (GUI.Button(NewRect(5, 80, 40, 10), "<<", style)) { window = 3; } if (GUI.Button(NewRect(55, 80, 40, 10), ">>", style)) { window = 2; } }