Ejemplo n.º 1
0
        void UpdateUserInfo()
        {
            var profileRect = new RectangleF(PadX, 0, View.Bounds.Width - 30 - PadX * 2, 100);

            shortProfileView = new ShortProfileView(profileRect, ReferenceUser.Id, true);
            shortProfileView.PictureTapped += delegate { PictureViewer.Load(this, ReferenceUser.Id); };
            shortProfileView.UrlTapped     += delegate { WebViewController.OpenUrl(this, ReferenceUser.Url); };
            shortProfileView.Tapped        += delegate { ActivateController(new FullProfileView(ReferenceUser.Id)); };
            TableView.TableHeaderView       = shortProfileView;
        }
        // Once we have a full tweet, setup the rest of the view.
        void SetTweet(Tweet fullTweet)
        {
            this.tweet = fullTweet;
            userTimeline.UserReference = User.FromId(tweet.UserId);

            shortProfileView.UpdateFromUserId(tweet.UserId);
            shortProfileView.PictureTapped += delegate { PictureViewer.Load(this, tweet.UserId); };
            shortProfileView.Tapped        += LoadFullProfile;
            shortProfileView.UrlTapped     += delegate { WebViewController.OpenUrl(this, User.FromId(tweet.UserId).Url); };

            if (tweet.InReplyToStatus != 0)
            {
                var in_reply = new ConversationRootElement(Locale.Format("In reply to: {0}", tweet.InReplyToUserName), tweet);

                main.Add(in_reply);
            }
        }
Ejemplo n.º 3
0
        void CreateUI()
        {
            System.Threading.Thread.Sleep(2000);
            if (spinner != null)
            {
                spinner.RemoveFromSuperview();
                spinner = null;
            }

            var profileRect      = new RectangleF(PadX, 0, View.Bounds.Width - PadX, 100);
            var shortProfileView = new ShortProfileView(profileRect, user.Id, false);

            shortProfileView.PictureTapped += delegate { PictureViewer.Load(this, user.Id); };
            shortProfileView.UrlTapped     += delegate { WebViewController.OpenUrl(this, user.Url); };

            var main = new Section(shortProfileView);

            if (!String.IsNullOrEmpty(user.Description))
            {
                main.Add(new StyledMultilineElement(user.Description)
                {
                    Lines         = 0,
                    LineBreakMode = UILineBreakMode.WordWrap,
                    Font          = UIFont.SystemFontOfSize(14),
                });
            }
            ;

            var tweetsUrl    = String.Format("http://api.twitter.com/1/statuses/user_timeline.json?skip_user=true&id={0}", user.Id);
            var favoritesUrl = String.Format("http://api.twitter.com/1/favorites.json?id={0}", user.Id);
            var followersUrl = String.Format("http://api.twitter.com/1/statuses/followers.json?id={0}", user.Id);
            var friendsUrl   = String.Format("http://api.twitter.com/1/statuses/friends.json?id={0}", user.Id);

#if false
            followButton = new StyledStringElement(FollowText, ToggleFollow)
            {
                Alignment = UITextAlignment.Center,
                TextColor = UIColor.FromRGB(0x32, 0x4f, 0x85)
            };
#endif
            var sfollow = new Section()
            {
                new ActivityElement()
            };

            Root = new RootElement(user.Screenname)
            {
                main,
                new Section()
                {
                    TimelineRootElement.MakeTimeline(user.Screenname, Locale.Format("{0:#,#} tweets", user.StatusesCount), tweetsUrl, user),
                    TimelineRootElement.MakeFavorites(user.Screenname, Locale.Format("{0:#,#} favorites", user.FavCount), favoritesUrl, null),
                    new UserRootElement(user, Locale.Format("{0:#,#} friends", user.FriendsCount), friendsUrl),
                    new UserRootElement(user, Locale.Format("{0:#,#} followers", user.FollowersCount), followersUrl),
                },
                sfollow,
            };
            var created = user.CreatedAt;
            if (created.HasValue)
            {
                Root.Add(new Section(null, Locale.Format("Joined on {0}", created.Value.ToLongDateString())));
            }

            string url = String.Format("http://api.twitter.com/1/friendships/show.json?target_id={0}&source_screen_name={1}",
                                       user.Id,
                                       OAuth.PercentEncode(TwitterAccount.CurrentAccount.Username));
            TwitterAccount.CurrentAccount.Download(url, res => {
                TableView.BeginUpdates();
                Root.Remove(sfollow);
                if (res != null)
                {
                    ParseFollow(res);
                }

                TableView.EndUpdates();
            });
        }