IEnumerator SaveChanges() { LoadAlert.Instance.StartLoad("Saving Changes...", null, -1); Task save = _project.SaveAsync(); while (!save.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (save.IsFaulted || save.Exception != null) { DefaultAlert.Present("Sorry", "There was an error when updating the project. Please try again later"); _project.Name = _previousName; _project.Description = _previousDescription; _project.Client = _previousClient; _project.Closed = _previousClosed; } else { _previousName = _project.Name; _previousDescription = _project.Description; _previousClosed = _project.Closed; SetEditable(); if (_project.Client != _previousClient && switchedClient != null) { switchedClient(this, _previousClient); } } }
IEnumerator CreateClient() { Task task = _client.SaveAsync(); LoadAlert.Instance.StartLoad("Creating Client...", null, -1); while (!task.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (task.IsFaulted || task.Exception != null) { DefaultAlert.Present("Sorry!", "There was an error while " + "trying to create your client. Please try again later."); } else { Deactivate(); if (createdClient != null) { createdClient(_client); } _client = null; } }
IEnumerator SwitchCoroutine(ExpenseListElement element, Project prevProject) { ExpenseList.RemoveListElement(element); prevProject.ItemCount--; element.Item.Project.ItemCount++; List <Project> projects = new List <Project>(); projects.Add(prevProject); projects.Add(element.Item.Project); Task task = projects.SaveAllAsync(); while (!task.IsCompleted) { yield return(null); } if (task.Exception != null) { DefaultAlert.Present("Sorry!", "An error occured and we " + "could not update the projects' item count"); } }
IEnumerator SwitchCoroutines(Project project) { Project prevProj = _item.Project; _item.Project = project; Task task = _item.SaveAsync(); while (!task.IsCompleted) { yield return(null); } if (task.Exception == null) { if (switchedProject != null) { switchedProject(this, prevProj); } } else { DefaultAlert.Present("Sorry!", "An error occured while trying " + "to delete this expense. Pleae try again later"); _item.Project = prevProj; } }
IEnumerator DeleteCoroutine() { LoadAlert.Instance.StartLoad("Deleting expense...", null, -1); Task task = _item.DeleteAsync(); while (!task.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (task.Exception == null) { if (remove != null) { remove(this); } } else { DefaultAlert.Present("Sorry!", "An error occured while trying " + "to delete this expense. Pleae try again later"); } }
IEnumerator ClaimCoins() { yield return(StartCoroutine(OnlineManager.Instance.StartRedeemSteps())); _state = HistoryViewState.REDUCE; enabled = true; DefaultAlert.Present("Hooray!", "You got " + OnlineManager.Instance.CoinsClaimed + " coins!"); }
void LoadTimeout() { DefaultAlert.Present(LANGUAGE_ERROR_HEADER, LANGUAGE_ERROR_BODY, null, null); if (languageFailedToLoad != null) { languageFailedToLoad(); } }
public void Submit() { if (PasswordField.text == ConfirmField.text) { StartCoroutine(UpdateUser()); } else { DefaultAlert.Present("Sorry!", "You password fields do not match. Please try again."); } }
public void Confirm() { if (string.IsNullOrEmpty(InputField.Text) || Helper.CheckIfSpaces(InputField.Text)) { DefaultAlert.Present("Sorry!", "Please input some text.", null, null); return; } Deactivate();//Close(); if (confirm != null) { confirm(InputField.Text); } confirm = null; cancel = null; }
IEnumerator UploadImage(byte[] data) { LoadAlert.Instance.StartLoad("Uploading photo...", null, -1); ParseFile file = new ParseFile(_item.Name + ".png", data); Task task = file.SaveAsync(); while (!task.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (task.Exception == null) { DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again"); } else { _item.Image = file; task = _item.SaveAsync(); while (!task.IsCompleted) { yield return(null); } if (task.Exception == null) { Texture2D tex = new Texture2D(1, 1); tex.LoadImage(data); Image.texture = tex; } else { DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again"); } } }
IEnumerator AddUserCoroutine(string email) { LoadAlert.Instance.StartLoad("Adding " + email, null, -1); ParseQuery <ParseUser> userQuery = new ParseQuery <ParseUser>().WhereEqualTo("email", email); Task <ParseUser> fetch = userQuery.FirstAsync(); while (!fetch.IsCompleted) { yield return(null); } if (fetch.Exception != null) { LoadAlert.Instance.Done(); DefaultAlert.Present("Sorry!", "We could not find that user. " + "Make sure you spelled their email correctly."); } else { _project.ACL.SetReadAccess(fetch.Result, true); _project.ACL.SetWriteAccess(fetch.Result, true); _project.UserCount++; Task save = _project.SaveAsync(); while (!save.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (save.Exception != null) { DefaultAlert.Present("Sorry!", "The database failed " + "to add that user. Please try again later."); } } //_project.ACL.SetReadAccess(Data }
IEnumerator ClaimExercise() { int beforeGems = Avatar.Instance.Gems; yield return(StartCoroutine(OnlineManager.Instance.StartRedeemActiveMinutes())); int gemsClaimed = Avatar.Instance.Gems - beforeGems; ActivityClaimButton.ButtonIconImage.sprite = AssetLookUp.Instance.ClaimedButton; string message = "You got "; if (gemsClaimed == 1) { message += "a gem!"; } else { message += gemsClaimed.ToString() + " gems!"; } DefaultAlert.Present("Hooray!", message); }
public void ClickArrow() { bool canSpend = Avatar.Instance.CanSpendCoins(ARROW_COST); int index = AmmoBeltView.Instance.FindNextOpenIndex(); if (canSpend && index > -1) { _index = index; YesNoAlert.Present("Balloon Arrow", "Are you sure you want to purchase this?", BuyArrow, null); } else { if (!canSpend) { DefaultAlert.Present("Sorry", "You don't have enough coins", null, null, false, "OK"); } else { DefaultAlert.Present("Sorry", "Your ammo bandelier is full", null, null, false, "OK"); } } }
IEnumerator SubmitCoroutine() { LoadAlert.Instance.StartLoad("Marking your expenses as opened."); _project.SubmittedUsers.Add(User.CurrentParseUser.ObjectId); Task task = _project.SaveAsync(); while (!task.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (task.Exception != null) { DefaultAlert.Present("Sorry!", "The database failed to close your expenses."); } else { SubmitText.text = OPEN; } }
public void Action() { StoreItem storeItem = _currentItem.Object as StoreItem; if (storeItem.Purchased) { if (!storeItem.Equipped) { StartCoroutine(StartEquip(storeItem)); } else { StartCoroutine(StartUnequip(storeItem)); } } else { bool canSpendCoins = Avatar.Instance.CanSpendCoins(storeItem.Coins); bool canSpendGems = Avatar.Instance.CanSpendGems(storeItem.Gems); if (canSpendCoins && canSpendGems) { YesNoAlert.Present("Gear", "Are you sure you want to purchase this?", BuyGear, null); } else { if (!canSpendCoins) { DefaultAlert.Present(SORRY, INSUFFICIENT_COINS); } else { DefaultAlert.Present(SORRY, INSUFFICIENT_GEMS); } } } }