public TweetImageFetchRequest(TweetImageInfo image, UIView view, bool placeholder) { var scale = UIScreen.MainScreen.Scale; tweetImage = image; targetContentMode = view.ContentMode; targetDimensions = TIPImageUtils.TIPDimensionsFromView(view); forcePlaceholder = placeholder; if (forcePlaceholder) { imageUrl = new NSUrl("placeholder://placeholder.com/placeholder.jpg"); } else { if (tweetImage.MediaUrl.StartsWith("https://pbs.twimg.com/media/", StringComparison.OrdinalIgnoreCase)) { var variantName = DetermineVariant(tweetImage.OriginalDimensions, targetDimensions, targetContentMode); imageUrl = new NSUrl($"{tweetImage.MediaUrlWithoutExtension}?format={tweetImage.Format}&name={variantName}"); } else { imageUrl = new NSUrl(tweetImage.MediaUrl); } } }
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 ZoomingTweetImageViewController(TweetImageInfo imageInfo) { tweetImageInfo = imageInfo; NavigationItem.Title = "Tweet Image"; }