public void SetComment(Fresvii.AppSteroid.Models.Comment comment, AUICommunityTop communityTop)
        {
            this.communityTop = communityTop;

            if (this.Comment == null || this.Comment.Id != comment.Id)
            {
                this.Comment = comment;
            }
        }
        public void SetComment(Fresvii.AppSteroid.Models.Comment comment, AUIForum auiForum)
        {
            this.Comment = comment;

            this.auiForum = auiForum;

            if (this.gameObject.activeInHierarchy)
            {
                StartCoroutine(Set());
            }
        }
        public void AddComment(string threadId, string text, Texture2D clipImage, Fresvii.AppSteroid.Models.Video video)
        {
            if (text.Length > Fresvii.AppSteroid.Models.Comment.TextMaxLength)
            {
                Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("TextTooLong"), delegate(bool del) { });

                return;
            }

            pollingWait = true;

            FresviiGUICommentCard card = ((GameObject)Instantiate(Resources.Load("GuiPrefabs/CommentCard"))).GetComponent<FresviiGUICommentCard>();

            card.transform.parent = this.transform;

            Fresvii.AppSteroid.Models.Comment comment = new Fresvii.AppSteroid.Models.Comment();

            comment.Text = text;

            comment.User = FAS.CurrentUser;

            comment.CreatedAt = comment.UpdateAt = System.DateTime.Now;

            card.ClipImage = clipImage;

            card.Init(comment, scaleFactor, Thread, Screen.width - 2f * sideMargin, this);

            if (video != null)
            {
                if (card.Comment.Video == null)
                {
                    card.Comment.Video = new Fresvii.AppSteroid.Models.Video();
                }

                card.Comment.Video.VideoUrl = video.VideoUrl;

                card.IsVideo = true;
            }

            cards.Add(card);

            comments.Add(comment);

            float scrollViewHeight = CalcScrollViewHeight();

            scrollViewHeight += threadBottomMenu.height;

            if(baseRect.height < scrollViewHeight)
                iTween.ValueTo(this.gameObject, iTween.Hash("from", scrollViewRect.y, "to", - scrollViewHeight + baseRect.height, "time", tweenTime, "easetype", tweenEaseType, "onupdatetarget", this.gameObject, "onupdate", "OnUpdateScrollPosition"));

            threadCard.Thread.LastUpdateAt = System.DateTime.Now;

            threadCard.Forum.SortCards();

            threadCard.Forum.ResetScrollPosition();

            if (video == null)
            {
                FASForum.AddComment(threadId, text, clipImage, delegate(Fresvii.AppSteroid.Models.Comment _comment, Fresvii.AppSteroid.Models.Error error)
                {
                    if (error != null)
                    {
                        Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

                        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.ShowSubmitDialog(FresviiGUIText.Get("ThreadNone"), delegate(bool del) { });

                            threadCard.DeleteThreadNonConfirm();
                        }
                        else
                        {
                            Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("CommentCreateError"), delegate(bool del) { });
                        }

                        cards.Remove(card);

                        Destroy(card.gameObject);
                    }
                    else
                    {
                        if (card == null)
                        {
                            return;
                        }
                        else
                        {
                            card.Comment = _comment;

                            commentIds.Add(_comment.Id);

                            LoadLatestComments();
                        }
                    }
                });
            }
            else
            {
                FASForum.AddComment(threadId, text, video.Id,

                    delegate(Fresvii.AppSteroid.Models.Comment _comment, Fresvii.AppSteroid.Models.Error error)
                    {
                        if (error != null)
                        {
                            Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

                            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.ShowSubmitDialog(FresviiGUIText.Get("ThreadNone"), delegate(bool del) { });

                                threadCard.DeleteThreadNonConfirm();
                            }
                            else
                            {
                                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("CommentCreateError"), delegate(bool del) { });
                            }

                            cards.Remove(card);

                            Destroy(card.gameObject);
                        }
                        else
                        {
                            if (card == null)
                            {
                                return;
                            }
                            else
                            {
                                card.Comment = _comment;

                                commentIds.Add(_comment.Id);

                                LoadLatestComments();
                            }
                        }
                    });
            }

            Thread.Subscribed = true;

            threadCard.Thread.Subscribed = true;

            threadCard.Thread.CommentCount += 1;
        }
Exemplo n.º 4
0
        IEnumerator ShowComment()
        {
            yield return new WaitForEndOfFrame();

            AUIForumCommentCell cell = commentCells.Find(x => x.Comment.Id == showComment.Id);

            if (cell != null)
            {
                if (- contents.GetComponent<RectTransform>().sizeDelta.y + AUIManager.Instance.sizedCanvas.rect.height - cell.GetComponent<RectTransform>().anchoredPosition.y > 0)
                {
                    //scrollView.GoToBottom(0f);
                    contents.SetScorllPosition(new Vector2(contents.GetComponent<RectTransform>().anchoredPosition.x, contents.GetComponent<RectTransform>().sizeDelta.y - AUIManager.Instance.sizedCanvas.rect.height));
                }
                else
                {
                    contents.SetScorllPosition(-cell.GetComponent<RectTransform>().anchoredPosition - new Vector2(0f, contents.padding.top));
                }
            }

            showComment = null;
        }
Exemplo n.º 5
0
        void OnInputDone(string text, Texture2D clipImage, Fresvii.AppSteroid.Models.Video video)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FASText.Get("Offline"), (del)=> {});

                return;
            }

            var item = GameObject.Instantiate(prfbCommentCell) as RectTransform;

            contents.AddItem(item);

            AUIForumCommentCell cell = item.GetComponent<AUIForumCommentCell>();

            cell.ThreadManager = this;

            Fresvii.AppSteroid.Models.Comment comment = new Fresvii.AppSteroid.Models.Comment();

            comment.User = FAS.CurrentUser;

            comment.Text = text;

            comment.CreatedAt = comment.UpdateAt = System.DateTime.Now;

            comment.Video = video;

            cell.SetClipImage(clipImage);

            cell.SetComment(comment);

            commentCells.Add(cell);

            if (video == null)
            {
                if (clipImage != null)
                {
                    Fresvii.AppSteroid.Util.DialogManager.ShowProgressSpinnerDialog("", FASText.Get("Uploading"), false);
                }

                FASForum.AddComment(ThreadCell.Thread.Id, text, clipImage, (_comment, _error)=>
                {
                    Fresvii.AppSteroid.Util.DialogManager.HideProgressSpinnerDialog();

                    if (_error != null)
                    {
                        Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FASText.Get("OK"), FASText.Get("Cancel"), FASText.Get("Close"));

                        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(FASText.Get("OK"), FASText.Get("Cancel"), FASText.Get("Close"));

                                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FASText.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.ShowSubmitDialog(FASText.Get("ThreadNone"), delegate(bool del) { });

                            DeleteThread();
                        }
                        else
                        {
                            Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FASText.Get("CommentCreateError"), delegate(bool del) { });
                        }

                        cell.DeleteCell();
                    }
                    else
                    {
                        cell.SetComment(_comment);
                    }
                });
            }
            else
            {
                FASForum.AddComment(ThreadCell.Thread.Id, text, video.Id, (_comment, _error) =>
                {
                    if (_error != null)
                    {
                        Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FASText.Get("OK"), FASText.Get("Cancel"), FASText.Get("Close"));

                        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(FASText.Get("OK"), FASText.Get("Cancel"), FASText.Get("Close"));

                                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FASText.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.ShowSubmitDialog(FASText.Get("ThreadNone"), delegate(bool del) { });

                            DeleteThread();
                        }
                        else
                        {
                            Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FASText.Get("CommentCreateError"), delegate(bool del) { });
                        }

                        cell.DeleteCell();
                    }
                    else
                    {
                        cell.SetComment(_comment);
                    }
                });

            }

            scrollView.GoToBottom(newCommentTweenDuration);
        }
Exemplo n.º 6
0
        public void ShowThread(string threadId, Fresvii.AppSteroid.Models.Comment comment, bool animation, Action<Fresvii.AppSteroid.Models.Error> showThreadRedayCallback)
        {
            segmentedControl.SetIndex(0);

            OnSegmentedControlChanged(0);

            this.showThreadWithAnimation = true;

            this.showThreadId = threadId;

            this.showComment = comment;

            this.showThreadRedayCallback = showThreadRedayCallback;
        }
        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();
                    }
                });
            }
        }