// Update is called once per frame void UpdateThread(Fresvii.AppSteroid.Models.Thread thread) { this.Thread = thread; if (isApp) { userIcon.Set(thread.App.IconUrl); } else { if(thread.User != null) userIcon.Set(thread.User.ProfileImageUrl); } if (string.IsNullOrEmpty(thread.Title)) { text.text = thread.Comment.Text; } else { text.text = thread.Title; } }
public void SetThread(FresviiGUIThreadCard threadCard) { this.threadCard = threadCard; this.Thread = threadCard.Thread; }
private IEnumerator SubscribeCoroutine() { while (string.IsNullOrEmpty(Thread.Id)) yield return 1; FASForum.Subscribe(Thread.Id, (thread, error) => { buttonSubscribe.interactable = true; if (error == null) { this.Thread = thread; } else { subscribeButtonImage.color = Thread.Subscribed ? subscribeColor : unsubscribeColor; Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FASText.Get("UnknownError"), (del)=>{ }); } }); }
public void SetThraed(Fresvii.AppSteroid.Models.Thread thread) { this.Thread = thread; clipImage.delayCount = 2; if (Thread.User != null && Thread.Comment != null) { userIcon.Set(Thread.User.ProfileImageUrl); userName.text = (string.IsNullOrEmpty(Thread.Title)) ? Thread.User.Name : Thread.Title; likeCount.text = Thread.Comment.LikeCount.ToString(); commentCount.text = Thread.CommentCount.ToString(); comment.text = Thread.Comment.Text; buttonVideoPlayback.SetActive(false); if (Thread.Comment.VideoState == Fresvii.AppSteroid.Models.Comment.VideoStatus.Ready) { if (Thread.Comment.Video != null) { if (clipImage.GetTexture() == null && !string.IsNullOrEmpty(Thread.Comment.Video.ThumbnailUrl)) { clipImage.Set(Thread.Comment.Video.ThumbnailUrl); } buttonVideoPlayback.SetActive(!string.IsNullOrEmpty(Thread.Comment.Video.VideoUrl)); } } else if (Thread.Comment.VideoState == Fresvii.AppSteroid.Models.Comment.VideoStatus.Removed) { clipImage.SetTexture(videoRemoved); } else if (clipImage.GetTexture() != null && string.IsNullOrEmpty(clipImage.Url)) { clipImage.dontDestroy = false; } else if (!string.IsNullOrEmpty(Thread.Comment.ImageThumbnailUrl)) { clipImage.Set(Thread.Comment.ImageThumbnailUrl); } else { clipImage.gameObject.SetActive(clipImage.GetTexture() != null); } if (string.IsNullOrEmpty(thread.Comment.Text)) { comment.gameObject.SetActive(false); comment.rectTransform.sizeDelta = Vector2.zero; } else { comment.gameObject.SetActive(true); } buttonGoToThread.interactable = !string.IsNullOrEmpty(thread.Id); buttonLike.colors = (this.Thread.Comment.Like) ? likeOn : likeOff; } SetLayout(); }
public void OnClickSubscribeButton() { buttonSubscribe.interactable = false; List<string> buttons = new List<string>(); if (this.Thread.Subscribed) { buttons.Add(FASText.Get("Unsubscribe")); } else { buttons.Add(FASText.Get("Subscribe")); } if (this.Thread.User.Id == FAS.CurrentUser.Id) { buttons.Add(FASText.Get("EditTitle")); buttons.Add(FASText.Get("Delete")); } buttons.Add(FASText.Get("Cancel")); AUIPopUpBalloon.Show(buttons.ToArray(), buttonSubscribeCenter, (selected) => { if (selected == FASText.Get("Unsubscribe")) { Unsubscribe(); } else if (selected == FASText.Get("Subscribe")) { Subscribe(); } else if (selected == FASText.Get("EditTitle")) { buttonSubscribe.interactable = true; AUIKeyboardInput.Show(Thread.Title, false, (text) => { string origTitle = Thread.Title; Thread.Title = text; SetThraed(Thread); FASForum.EditThreadTitle(Thread.Id, text, (thread, error) => { if (error == null) { this.Thread = thread; } else { Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FASText.Get("OK"), FASText.Get("Cancel"), FASText.Get("Close")); Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FASText.Get("UnknownError"), (del)=>{ }); Thread.Title = origTitle; } SetThraed(Thread); }); }); } else if (selected == FASText.Get("Delete")) { DeleteThread(); } else { buttonSubscribe.interactable = true; } }); }
private IEnumerator SubscribeCoroutine() { while (string.IsNullOrEmpty(Thread.Id)) yield return 1; FASForum.Subscribe(Thread.Id, delegate(Fresvii.AppSteroid.Models.Thread _thread, Fresvii.AppSteroid.Models.Error _error) { if (_error == null) { this.Thread = _thread; } else { Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("UnknownError"), delegate(bool del) { }); } }); }
public void Init(Fresvii.AppSteroid.Models.Thread thread, float scaleFactor, string postFix, FresviiGUIForum forum, float cardWidth) { if (Application.platform == RuntimePlatform.IPhonePlayer) { guiStyleUserName.font = null; guiStyleUserName.fontStyle = FontStyle.Bold; guiStyleTimeSpan.font = null; guiStyleCommentText.font = null; likeCountIconPosition.y += scaleFactor; commentCountIconPosition.y += scaleFactor; } this.Thread = thread; this.scaleFactor = scaleFactor; this.postFix = postFix; this.Forum = forum; this.popUpOffset *= scaleFactor; userIconPosition = FresviiGUIUtility.RectScale(userIconPosition, scaleFactor); commentLButtonPosition = FresviiGUIUtility.RectScale(commentLButtonPosition, scaleFactor); likeLButtonPosition = FresviiGUIUtility.RectScale(likeLButtonPosition, scaleFactor); userNamePosition = FresviiGUIUtility.RectScale(userNamePosition, scaleFactor); timespanPosition = FresviiGUIUtility.RectScale(timespanPosition, scaleFactor); commentTextPosition = FresviiGUIUtility.RectScale(commentTextPosition, scaleFactor); likeCountIconPosition = FresviiGUIUtility.RectScale(likeCountIconPosition, scaleFactor); likeCountLabelPosition = FresviiGUIUtility.RectScale(likeCountLabelPosition, scaleFactor); commentCountIconPosition = FresviiGUIUtility.RectScale(commentCountIconPosition, scaleFactor); commentCountLabelPosition = FresviiGUIUtility.RectScale(commentCountLabelPosition, scaleFactor); clipImagePosition = FresviiGUIUtility.RectScale(clipImagePosition, scaleFactor); margin *= scaleFactor; miniMargin *= scaleFactor; guiStyleUserName.fontSize = (int)(guiStyleUserName.fontSize * scaleFactor); guiStyleUserName.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardUserName); guiStyleTimeSpan.fontSize = (int)(guiStyleTimeSpan.fontSize * scaleFactor); guiStyleTimeSpan.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardText2); guiStyleCommentText.fontSize = (int)(guiStyleCommentText.fontSize * scaleFactor); guiStyleCommentText.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardText1); lineWidth *= scaleFactor; bottomButtonHeight *= scaleFactor; menuButtonMargin *= scaleFactor; imageHeight = defaultImageHeight * scaleFactor; SetCommentText(cardWidth); userIconHitPosition = new Rect(0, 0, userIconPosition.x + userIconPosition.width + margin, userIconPosition.y + userIconPosition.height + margin); palette = FresviiGUIColorPalette.Palette; texCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardBackground); texCoordsLine = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardSeperateLine1); texCoodsProgressBar = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardProgressBar); isLike = thread.Comment.Like; iTween.ValueTo(this.gameObject, iTween.Hash("from", 0.0f, "to", 1.0f, "time", 0.5f, "easetype", imageTweenEasetype, "onupdatetarget", this.gameObject, "onupdate", "OnUpdateCardAlpha", "oncompletetarget", this.gameObject)); if(clipImage != null) iTween.ValueTo(this.gameObject, iTween.Hash("from", 0.0f, "to", 1.0f, "time", 0.5f, "easetype", imageTweenEasetype, "onupdatetarget", this.gameObject, "onupdate", "OnUpdateAlpha", "oncompletetarget", this.gameObject)); }
public void CreateThread(string text, Texture2D clipImage, Fresvii.AppSteroid.Models.Video video) { Fresvii.AppSteroid.Models.Thread thread = new Fresvii.AppSteroid.Models.Thread(); thread.User = FAS.CurrentUser; Fresvii.AppSteroid.Models.Comment comment = new Fresvii.AppSteroid.Models.Comment(); thread.Comment = comment; thread.Comment.Text = text; if (video != null) { if (thread.Comment.Video == null) { thread.Comment.Video = new Fresvii.AppSteroid.Models.Video(); } thread.Comment.Video.VideoUrl = video.VideoUrl; } thread.Comment.User = FAS.CurrentUser; thread.CreatedAt = thread.UpdateAt = thread.LastUpdateAt = System.DateTime.Now; thread.Subscribed = true; FresviiGUIThreadCard card = ((GameObject)Instantiate(Resources.Load("GuiPrefabs/ThreadCard"))).GetComponent<FresviiGUIThreadCard>(); card.transform.parent = this.transform; card.clipImage = clipImage; card.Init(thread, scaleFactor, postFix, this, Screen.width - 2 * sideMargin); card.IsVideo = (video != null); cards.Add(card); SortCards(); iTween.ValueTo(this.gameObject, iTween.Hash("from", scrollViewRect.y, "to", 0.0f, "time", tweenTime, "easetype", tweenEaseType, "onupdatetarget", this.gameObject, "onupdate", "OnUpdateScrollViewPosition", "oncompletetarget", this.gameObject)); if (video == null) { FASForum.CreateThread(text, clipImage, delegate(Fresvii.AppSteroid.Models.Thread _thread, Fresvii.AppSteroid.Models.Error _error) { if (_error != null) { Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("ThreadCreateError"), delegate(bool del) { }); if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error) Debug.LogError(_error.ToString()); } else { card.Thread = _thread; threads.Add(_thread); threadIds.Add(_thread.Id); } }); } else { card.DataUploadProgressStart(); FASForum.CreateVideoThread(text, video.Id, delegate(Fresvii.AppSteroid.Models.Thread _thread, Fresvii.AppSteroid.Models.Error _error) { if (_error != null) { Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("ThreadCreateError"), delegate(bool del) { }); if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error) Debug.LogError(_error.ToString()); cards.Remove(card); Destroy(card.gameObject); } else { card.Thread = _thread; threads.Add(_thread); threadIds.Add(_thread.Id); card.DataUploadProgressEnd(); } }); } }