public void ShowActionSheet(FresviiGUICommentCard card) { HasPopUp = true; List<string> buttons = new List<string>(); if (!string.IsNullOrEmpty(card.Comment.Text)) { buttons.Add(FresviiGUIText.Get("CopyText")); } if(card.ClipImage != null) { buttons.Add(FresviiGUIText.Get("SaveImage")); } if (card.IsMine()) { buttons.Add(FresviiGUIText.Get("EditText")); if (card.ClipImage != null) { buttons.Add(FresviiGUIText.Get("ChangeImageFromLibrary")); buttons.Add(FresviiGUIText.Get("ChangeImageFromCamera")); } else { buttons.Add(FresviiGUIText.Get("AddImageFromLibrary")); buttons.Add(FresviiGUIText.Get("AddImageFromCamera")); } if (card.Comment.Id != Thread.Comment.Id) { buttons.Add(FresviiGUIText.Get("Delete")); } } if (!string.IsNullOrEmpty(card.IncludingUrl)) { buttons.Add(FresviiGUIText.Get("OpenLink")); } buttons.Add(FresviiGUIText.Get("Report")); actionSheet = Fresvii.AppSteroid.Gui.ActionSheet.Show(scaleFactor, postFix, this.GuiDepth - 30, buttons.ToArray(), (selectedButton) => { HasPopUp = false; if (selectedButton == FresviiGUIText.Get("CopyText")) // copy { #if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS) Fresvii.AppSteroid.Util.Clipboard.SetText(card.Comment.Text); #endif } else if (selectedButton == FresviiGUIText.Get("SaveImage")) { Fresvii.AppSteroid.Util.ImagePicker.SaveImageData(this, card.ClipImage.EncodeToPNG(), System.IO.Path.GetFileName(card.Comment.ImageThumbnailUrl)); } else if (selectedButton == FresviiGUIText.Get("EditText")) // edit { FASGesture.Pause(); GetComponent<FresviiGUIPopUpTextInput>().Show(card.Comment.Text, true, delegate(string text) { FASGesture.Resume(); string origText = card.Comment.Text; card.Comment.Text = text; threadBottomMenu.ClearTextInputField(); FASForum.EditComment(card.Comment.Id, text, "", delegate(Fresvii.AppSteroid.Models.Comment comment, Fresvii.AppSteroid.Models.Error error) { if (error == null) { card.Comment = comment; } else if (error.Code == (int)Fresvii.AppSteroid.Models.Error.ErrorCode.WWWTimeOut) { if (this != null && this.gameObject != null) { if (this.gameObject.activeInHierarchy && this.enabled) { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("TimeOut"), delegate(bool del) { }); } } } else if (error.Code == (int)Fresvii.AppSteroid.Models.Error.ErrorCode.NotFound || (Application.platform == RuntimePlatform.Android && error.Detail.IndexOf("FileNotFound") >= 0)) { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("ThreadNone"), delegate(bool del) { }); threadCard.DeleteThreadNonConfirm(); } else { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("CommentCreateError"), delegate(bool del) { }); card.Comment.Text = origText; } }); }); } else if (selectedButton == FresviiGUIText.Get("ChangeImageFromLibrary") || selectedButton == FresviiGUIText.Get("ChangeImageFromCamera") || selectedButton == FresviiGUIText.Get("AddImageFromLibrary") || selectedButton == FresviiGUIText.Get("AddImageFromCamera")) { Fresvii.AppSteroid.Util.ImagePicker.Type type = (selectedButton == FresviiGUIText.Get("ChangeImageFromLibrary") || selectedButton == FresviiGUIText.Get("AddImageFromLibrary")) ? Fresvii.AppSteroid.Util.ImagePicker.Type.Gallery : Fresvii.AppSteroid.Util.ImagePicker.Type.Camera; Fresvii.AppSteroid.Util.ImagePicker.Show(this, type, (image) => { Texture2D origImage = card.ClipImage; if (image != null) { card.ClipImage = image; FASForum.EditComment(card.Comment.Id, "", image, (comment, error) => { if (error == null) { if (!string.IsNullOrEmpty(card.Comment.ImageThumbnailUrl)) { FresviiGUIManager.Instance.resourceManager.ReleaseTexture(card.Comment.ImageThumbnailUrl); } card.Comment = comment; } else if (error.Code == (int)Fresvii.AppSteroid.Models.Error.ErrorCode.WWWTimeOut) { if (this != null && this.gameObject != null) { if (this.gameObject.activeInHierarchy && this.enabled) { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("TimeOut"), delegate(bool del) { }); } } } else if (error.Code == (int)Fresvii.AppSteroid.Models.Error.ErrorCode.NotFound || (Application.platform == RuntimePlatform.Android && error.Detail.IndexOf("FileNotFound") >= 0)) { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("ThreadNone"), delegate(bool del) { }); threadCard.DeleteThreadNonConfirm(); } else { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("CommentEditError"), delegate(bool del) { }); card.ClipImage = origImage; } }); } }); } else if (selectedButton == FresviiGUIText.Get("Delete")) { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("Delete"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSelectDialog(FresviiGUIText.Get("ConfirmDeleteComment"), delegate(bool del) { if (del) { if (threadCard.Thread.CommentCount >= 1) { threadCard.Thread.CommentCount -= 1; } card.DeleteCard(); } }); } else if(selectedButton == FresviiGUIText.Get("Report")) { StartCoroutine(ReportDelay(card.Comment.Id)); } else if (selectedButton == FresviiGUIText.Get("OpenLink")) { Application.OpenURL(card.IncludingUrl); } }); FASGesture.Stop(); }
public void RemoveCard(FresviiGUICommentCard card) { cards.Remove(card); Destroy(card.gameObject); if(cards.Count == 0){ FresviiGUIForum.Instance.DeleteThread(threadCard); BackToForum(); } }