Clean up thumbnail-related logic.

pull/1/head
Matthew Chen 7 years ago
parent 51e8fdcb25
commit b1f2b9e75c

@ -79,6 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
thumbnailImageLargeWithSuccess:^(UIImage *image) {
weakSelf.image = image;
[weakSelf createContents];
[weakSelf updateMinZoomScale];
}
failure:^{
DDLogWarn(@"Could not load media.");
@ -127,6 +128,13 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateMinZoomScale
{
if (!self.image) {
self.scrollView.minimumZoomScale = 1.f;
self.scrollView.maximumZoomScale = 1.f;
self.scrollView.zoomScale = 1.f;
return;
}
CGSize viewSize = self.scrollView.bounds.size;
UIImage *image = self.image;
OWSAssert(image);

@ -146,6 +146,9 @@ private struct OWSThumbnailRequest {
}
return OWSLoadedThumbnail(image: image, filePath: thumbnailPath)
}
Logger.verbose("Creating thumbnail of size: \(thumbnailRequest.thumbnailDimensionPoints)")
let thumbnailDirPath = (thumbnailPath as NSString).deletingLastPathComponent
guard OWSFileSystem.ensureDirectoryExists(thumbnailDirPath) else {
throw OWSThumbnailError.failure(description: "Could not create attachment's thumbnail directory.")

@ -20,7 +20,7 @@ const NSUInteger ThumbnailDimensionPointsLarge()
{
CGSize screenSizePoints = UIScreen.mainScreen.bounds.size;
const CGFloat kMinZoomFactor = 2.f;
return MAX(screenSizePoints.width * kMinZoomFactor, screenSizePoints.height * kMinZoomFactor);
return MAX(screenSizePoints.width, screenSizePoints.height) * kMinZoomFactor;
}
typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail);

Loading…
Cancel
Save