private List <TweetInfo> ParseResponse(NSData data) { var tweets = new List <TweetInfo>(); var json = JObject.Parse(data.ToString()); foreach (var status in json["statuses"]) { var user = status["user"]; var handle = (string)user["screen_name"]; if (!string.IsNullOrEmpty(handle)) { var tweet = new TweetInfo { Text = (string)status["text"], Handle = handle }; tweets.Add(tweet); var sensitive = (bool?)status["possibly_sensitive"]; if (!sensitive.HasValue || !sensitive.Value) { var entities = status["entities"]; if (entities != null) { var media = entities["media"]; if (media != null) { foreach (var mediaItem in media) { var type = (string)mediaItem["type"]; if (type == "photo") { var imageUrlString = (string)mediaItem["media_url_https"]; var format = Path.GetExtension(imageUrlString).Substring(1); var sizes = mediaItem["sizes"]; var largeVariant = sizes["large"]; var w = (int)largeVariant["w"]; var h = (int)largeVariant["h"]; var imageInfo = new TweetImageInfo { Format = format, MediaUrl = imageUrlString, MediaUrlWithoutExtension = imageUrlString.Substring(0, imageUrlString.Length - format.Length - 1), OriginalDimensions = new CGSize(w, h) }; tweet.Images.Add(imageInfo); } } } } } } } return((tweets.Count > 0) ? tweets : null); }
public override void PrepareForReuse() { base.PrepareForReuse(); tweet = null; }