// // Queues a request to fetch the lists, and inserts // the results into the existing section // void FetchLists() { account.Download("http://api.twitter.com/1/" + account.Username + "/lists.json", res => { if (res == null) { return; } var json = JsonValue.Load(res); var jlists = json ["lists"]; try { int pos = 0; foreach (JsonObject list in jlists) { string name = list ["full_name"]; string listname = list ["name"]; string url = "http://api.twitter.com/1/" + account.Username + "/lists/" + listname + "/statuses.json"; lists.Insert(pos++, UITableViewRowAnimation.Fade, TimelineRootElement.MakeList(name, listname, url)); } } catch (Exception e) { Console.WriteLine(e); } }); }
public DetailTweetViewController(Tweet partialTweet) : base(UITableViewStyle.Grouped, null, true) { bool isMine = false; if (partialTweet.IsSearchResult) { Tweet.LoadFullTweet(partialTweet.Id, fullTweet => SetTweet(fullTweet)); } else { isMine = partialTweet.UserId == TwitterAccount.CurrentAccount.AccountId; // Hack until we figure out why DELETE is not working with OAuth // and making the server return 401 Unauthorized isMine = false; } var handlers = new EventHandler [] { Reply, Retweet, Direct, Delete }; var profileRect = new RectangleF(PadX, 0, View.Bounds.Width - PadX, 100); var detailRect = new RectangleF(PadX, 0, View.Bounds.Width - 30 - PadX * 2, 0); shortProfileView = new ShortProfileView(profileRect, partialTweet, true); profileRect.Height += 8; var triangle = new TriangleView(UIColor.White, UIColor.FromRGB(171, 171, 171)) { Frame = new RectangleF(43, shortProfileView.Bounds.Height + 1, 16, 8) }; var containerView = new UIView(profileRect); containerView.Add(shortProfileView); containerView.Add(triangle); main = new Section(containerView) { new UIViewElement(null, new DetailTweetView(detailRect, partialTweet, TapHandler, TapAndHoldHandler, this), false) { Flags = UIViewElement.CellFlags.DisableSelection } }; Section replySection = new Section(); if (partialTweet.Kind == TweetKind.Direct) { replySection.Add(new StringElement(Locale.GetText("Direct Reply"), delegate { Direct(this, EventArgs.Empty); })); } else { replySection.Add(new UIViewElement(null, new ButtonsView(isMine ? 4 : 3, buttons, handlers), true) { Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent }); } userTimeline = TimelineRootElement.MakeTimeline(partialTweet.Screename, Locale.GetText("User's timeline"), "http://api.twitter.com/1/statuses/user_timeline.json?skip_user=true&screen_name=" + partialTweet.Screename, User.FromTweet(partialTweet)); tweet = partialTweet; if (!partialTweet.IsSearchResult) { SetTweet(partialTweet); } Root = new RootElement(partialTweet.Screename) { main, replySection, new Section() { userTimeline } }; }
public DetailTweetViewController(Tweet partialTweet) : base(UITableViewStyle.Grouped, null, true) { bool isMine = false; if (partialTweet.IsSearchResult) Tweet.LoadFullTweet (partialTweet.Id, fullTweet => SetTweet (fullTweet)); else { isMine = partialTweet.UserId == TwitterAccount.CurrentAccount.AccountId; // Hack until we figure out why DELETE is not working with OAuth // and making the server return 401 Unauthorized isMine = false; } var handlers = new EventHandler [] { Reply, Retweet, Direct, Delete }; var profileRect = new RectangleF (PadX, 0, View.Bounds.Width-PadX, 100); var detailRect = new RectangleF (PadX, 0, View.Bounds.Width-30-PadX*2, 0); shortProfileView = new ShortProfileView (profileRect, partialTweet, true); profileRect.Height += 8; var triangle = new TriangleView (UIColor.White, UIColor.FromRGB (171, 171, 171)) { Frame = new RectangleF (43, shortProfileView.Bounds.Height+1, 16, 8) }; var containerView = new UIView (profileRect); containerView.Add (shortProfileView); containerView.Add (triangle); main = new Section (containerView){ new UIViewElement (null, new DetailTweetView (detailRect, partialTweet, TapHandler, TapAndHoldHandler, this), false) { Flags = UIViewElement.CellFlags.DisableSelection } }; Section replySection = new Section (); if (partialTweet.Kind == TweetKind.Direct) replySection.Add (new StringElement (Locale.GetText ("Direct Reply"), delegate { Direct (this, EventArgs.Empty); })); else replySection.Add (new UIViewElement (null, new ButtonsView (isMine ? 4 : 3, buttons, handlers), true) { Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent }); userTimeline = TimelineRootElement.MakeTimeline (partialTweet.Screename, Locale.GetText ("User's timeline"), "http://api.twitter.com/1/statuses/user_timeline.json?skip_user=true&screen_name=" + partialTweet.Screename, User.FromTweet (partialTweet)); tweet = partialTweet; if (!partialTweet.IsSearchResult) SetTweet (partialTweet); Root = new RootElement (partialTweet.Screename){ main, replySection, new Section () { userTimeline } }; }
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(); }); }