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();
        }));
    }
Exemplo n.º 4
0
    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 HideProgressDialog()
 {
     AndroidNativeFunctions.HideProgressDialog();
 }