public void UpdateCell(Tweet tweet) { _userAvatarUri = tweet.UserAvatarUrl; _userNameLabel.Text = tweet.UserName; _userTweetTextLabel.Text = tweet.TweetText; var d = DateTime.Now - tweet.PostTweetTime; if (d.Days != 0) _userTweetPostTimeLabel.Text = d.Days.ToString () + " д"; else if (d.Hours != 0) _userTweetPostTimeLabel.Text = d.Hours.ToString () + " ч"; else if (d.Minutes != 0) _userTweetPostTimeLabel.Text = d.Minutes.ToString () + " м"; else _userTweetPostTimeLabel.Text = d.Seconds.ToString () + " с"; var img = ImageLoader.DefaultRequestImage (tweet.UserAvatarUrl, this); if (img == null) img = UIImage.FromBundle ("Content/Main/avatar.png"); else img = img.SetMask ("Content/Main/mask_avatar_mini.png"); _userAvatarView.Image = img; }
public void ShowNewTweetInfo(Tweet t) { _url = t.UserAvatarUrl.ToString (); _userName.Text = t.UserName; _userTweetText.Text = t.TweetText; _userTweetPostTime.Text = t.PostTweetTime.ToShortDateString (); _userTweetShortUrl.Text = "http://bit.ly/X2IfBq"; SetFrames (); var img = ImageLoader.DefaultRequestImage (t.UserAvatarUrl, this); if (img != null) _userAvatar.Image = img; else _userAvatar.Image = UIImage.FromBundle ("Content/Main/avatar.png"); }
private List<Tweet> ParseJsonToTweetsList(string jsonStr, bool isRefresh) { List<Tweet> list = new List<Tweet> (); try { JObject ob = JObject.Parse (jsonStr); JArray o = (JArray)ob["statuses"]; foreach (var token in o) { Tweet t = new Tweet (); t.UserName = (string)token.SelectToken ("user").SelectToken ("name"); t.TweetText = (string)token.SelectToken ("text"); t.PostTweetTime = DateTime.ParseExact ((string)token.SelectToken ("created_at"), "ddd MMM dd HH:mm:ss zzz yyyy", System.Globalization.CultureInfo.InvariantCulture); t.UserAvatarUrl = new Uri ((string)token.SelectToken ("user").SelectToken ("profile_image_url")); list.Add (t); } if (!isRefresh) _maxId = ob["search_metadata"]["next_results"].ToString (); if (isRefresh || String.IsNullOrEmpty (_refreshUrl)) _refreshUrl = ob["search_metadata"]["refresh_url"].ToString (); } catch { throw new JsonReaderException ("Error parse id_str"); } return list; }