public ActivityPost ParseFromAJO(AndroidJavaObject ajo)
        {
            using (ajo)
            {
                Id          = ajo.CallStr("getId");
                Text        = ajo.CallStr("getText");
                ImageUrl    = ajo.CallStr("getImageUrl");
                ButtonTitle = ajo.CallStr("getButtonTitle");
#pragma warning disable 0618
                ButtonAction = ajo.CallStr("getButtonAction");
#pragma warning restore 0618
                var action = ajo.CallAJO("getAction");
                if (action != null)
                {
                    Action = new GetSocialAction().ParseFromAJO(action);
                }
                CreatedAt     = DateUtils.FromUnixTime(ajo.CallLong("getCreatedAt"));
                Author        = new PostAuthor().ParseFromAJO(ajo.CallAJO("getAuthor"));
                CommentsCount = ajo.CallInt("getCommentsCount");
                LikesCount    = ajo.CallInt("getLikesCount");
                IsLikedByMe   = ajo.CallBool("isLikedByMe");

                StickyStart = DateUtils.FromUnixTime(ajo.CallLong("getStickyStart"));
                StickyEnd   = DateUtils.FromUnixTime(ajo.CallLong("getStickyEnd"));
                FeedId      = ajo.CallStr("getFeedId");
                Mentions    = ajo.CallAJO("getMentions").FromJavaList().ConvertAll(mentionAjo =>
                {
                    using (mentionAjo)
                    {
                        return(new Mention().ParseFromAJO(mentionAjo));
                    }
                }).ToList();
            }
            return(this);
        }
        public ActivityPost ParseFromJson(Dictionary <string, object> json)
        {
            Id   = (string)json["Id"];
            Text = json["Text"] as string;

            ImageUrl    = json["ImageUrl"] as string;
            ButtonTitle = json["ButtonTitle"] as string;
#pragma warning disable 0618
            ButtonAction = json["ButtonAction"] as string;
#pragma warning restore 0618
            var action = json["Action"] as Dictionary <string, object>;
            if (action != null)
            {
                Action = new GetSocialAction().ParseFromJson(action);
            }
            CreatedAt = DateUtils.FromUnixTime((long)json["CreatedAt"]);

            var authorDic = json["Author"] as Dictionary <string, object>;
            Author = new PostAuthor().ParseFromJson(authorDic);

            CommentsCount = (int)(long)json["CommentsCount"];
            LikesCount    = (int)(long)json["LikesCount"];
            IsLikedByMe   = (bool)json["IsLikedByMe"];

            StickyStart = DateUtils.FromUnixTime((long)json["StickyStart"]);
            StickyEnd   = DateUtils.FromUnixTime((long)json["StickyEnd"]);
            Mentions    = GSJsonUtils.ParseList <Mention>(json["Mentions"] as string);
            FeedId      = json["FeedId"] as string;

            return(this);
        }
Пример #3
0
 internal ActivityPost(string id, string text, string imageUrl, DateTime createdAt, string buttonTitle, string buttonAction, PostAuthor author, int commentsCount, int likesCount, bool isLikedByMe, DateTime stickyStart, DateTime stickyEnd, List <Mention> mentions, string feedId)
 {
     Id            = id;
     Text          = text;
     ImageUrl      = imageUrl;
     CreatedAt     = createdAt;
     ButtonTitle   = buttonTitle;
     ButtonAction  = buttonAction;
     Author        = author;
     CommentsCount = commentsCount;
     LikesCount    = likesCount;
     IsLikedByMe   = isLikedByMe;
     StickyStart   = stickyStart;
     StickyEnd     = stickyEnd;
     Mentions      = mentions;
     FeedId        = feedId;
 }