Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        public bool FetchHelperShouldContinueLoadingAfterFetching(TIPImageViewFetchHelper helper, ITIPImageFetchResult previewImageResult)
        {
            if (previewImageResult.ImageIsTreatedAsPlaceholder)
            {
                return(true);
            }

            var request = helper.FetchRequest;

            if (request.GetOptions().HasFlag(TIPImageFetchOptions.TreatAsPlaceholder))
            {
                // would be a downgrade, stop
                return(false);
            }

            var originalDimensions = previewImageResult.ImageOriginalDimensions;
            var viewDimensions     = TIPImageUtils.TIPDimensionsFromView(helper.FetchImageView);

            if (originalDimensions.Height >= viewDimensions.Height && originalDimensions.Width >= viewDimensions.Width)
            {
                return(false);
            }

            return(true);
        }