|
|
@ -4,7 +4,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
#import "TSAnimatedAdapter.h"
|
|
|
|
#import "TSAnimatedAdapter.h"
|
|
|
|
#import "AttachmentUploadView.h"
|
|
|
|
#import "AttachmentUploadView.h"
|
|
|
|
#import "FLAnimatedImage.h"
|
|
|
|
|
|
|
|
#import "JSQMediaItem+OWS.h"
|
|
|
|
#import "JSQMediaItem+OWS.h"
|
|
|
|
#import "TSAttachmentStream.h"
|
|
|
|
#import "TSAttachmentStream.h"
|
|
|
|
#import "UIColor+OWS.h"
|
|
|
|
#import "UIColor+OWS.h"
|
|
|
@ -13,12 +12,13 @@
|
|
|
|
#import <MobileCoreServices/MobileCoreServices.h>
|
|
|
|
#import <MobileCoreServices/MobileCoreServices.h>
|
|
|
|
#import <SignalServiceKit/MIMETypeUtil.h>
|
|
|
|
#import <SignalServiceKit/MIMETypeUtil.h>
|
|
|
|
#import <SignalServiceKit/NSData+Image.h>
|
|
|
|
#import <SignalServiceKit/NSData+Image.h>
|
|
|
|
|
|
|
|
#import <YYImage/YYImage.h>
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
@interface TSAnimatedAdapter ()
|
|
|
|
@interface TSAnimatedAdapter ()
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, nullable) FLAnimatedImageView *cachedImageView;
|
|
|
|
@property (nonatomic, nullable) YYAnimatedImageView *cachedImageView;
|
|
|
|
@property (nonatomic) TSAttachmentStream *attachment;
|
|
|
|
@property (nonatomic) TSAttachmentStream *attachment;
|
|
|
|
@property (nonatomic, nullable) AttachmentUploadView *attachmentUploadView;
|
|
|
|
@property (nonatomic, nullable) AttachmentUploadView *attachmentUploadView;
|
|
|
|
@property (nonatomic) BOOL incoming;
|
|
|
|
@property (nonatomic) BOOL incoming;
|
|
|
@ -101,20 +101,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
OWSAssert([NSThread isMainThread]);
|
|
|
|
OWSAssert([NSThread isMainThread]);
|
|
|
|
|
|
|
|
|
|
|
|
if (self.cachedImageView == nil) {
|
|
|
|
if (self.cachedImageView == nil) {
|
|
|
|
// Use Flipboard FLAnimatedImage library to display gifs
|
|
|
|
NSString *_Nullable filePath = [self.attachment filePath];
|
|
|
|
NSData *fileData = [NSData dataWithContentsOfURL:[self.attachment mediaURL]];
|
|
|
|
if (![NSData ows_isValidImageAtPath:filePath]) {
|
|
|
|
if (!fileData) {
|
|
|
|
return nil;
|
|
|
|
DDLogError(@"%@ Could not load image: %@", [self tag], [self.attachment mediaURL]);
|
|
|
|
}
|
|
|
|
|
|
|
|
YYImage *_Nullable animatedGif = filePath ? [YYImage imageWithContentsOfFile:filePath] : nil;
|
|
|
|
|
|
|
|
if (!animatedGif) {
|
|
|
|
|
|
|
|
DDLogError(@"%@ Could not load image: %@", [self tag], filePath);
|
|
|
|
UIView *view = [UIView new];
|
|
|
|
UIView *view = [UIView new];
|
|
|
|
view.backgroundColor = [UIColor colorWithWhite:0.85f alpha:1.f];
|
|
|
|
view.backgroundColor = [UIColor colorWithWhite:0.85f alpha:1.f];
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (![fileData ows_isValidImage]) {
|
|
|
|
YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc] init];
|
|
|
|
return nil;
|
|
|
|
imageView.image = animatedGif;
|
|
|
|
}
|
|
|
|
|
|
|
|
FLAnimatedImage *animatedGif = [FLAnimatedImage animatedImageWithGIFData:fileData];
|
|
|
|
|
|
|
|
FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init];
|
|
|
|
|
|
|
|
imageView.animatedImage = animatedGif;
|
|
|
|
|
|
|
|
CGSize size = [self mediaViewDisplaySize];
|
|
|
|
CGSize size = [self mediaViewDisplaySize];
|
|
|
|
imageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
imageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
imageView.frame = CGRectMake(0.0, 0.0, size.width, size.height);
|
|
|
|
imageView.frame = CGRectMake(0.0, 0.0, size.width, size.height);
|
|
|
|