mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Replace FLAnimatedImage with YYImage.
// FREEBIE
This commit is contained in:
parent
aa43fd69fd
commit
48e6cea207
|
@ -4,7 +4,6 @@
|
|||
|
||||
#import "TSAnimatedAdapter.h"
|
||||
#import "AttachmentUploadView.h"
|
||||
#import "FLAnimatedImage.h"
|
||||
#import "JSQMediaItem+OWS.h"
|
||||
#import "TSAttachmentStream.h"
|
||||
#import "UIColor+OWS.h"
|
||||
|
@ -13,12 +12,13 @@
|
|||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
#import <SignalServiceKit/MIMETypeUtil.h>
|
||||
#import <SignalServiceKit/NSData+Image.h>
|
||||
#import <YYImage/YYImage.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TSAnimatedAdapter ()
|
||||
|
||||
@property (nonatomic, nullable) FLAnimatedImageView *cachedImageView;
|
||||
@property (nonatomic, nullable) YYAnimatedImageView *cachedImageView;
|
||||
@property (nonatomic) TSAttachmentStream *attachment;
|
||||
@property (nonatomic, nullable) AttachmentUploadView *attachmentUploadView;
|
||||
@property (nonatomic) BOOL incoming;
|
||||
|
@ -101,20 +101,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSAssert([NSThread isMainThread]);
|
||||
|
||||
if (self.cachedImageView == nil) {
|
||||
// Use Flipboard FLAnimatedImage library to display gifs
|
||||
NSData *fileData = [NSData dataWithContentsOfURL:[self.attachment mediaURL]];
|
||||
if (!fileData) {
|
||||
DDLogError(@"%@ Could not load image: %@", [self tag], [self.attachment mediaURL]);
|
||||
NSString *_Nullable filePath = [self.attachment filePath];
|
||||
if (![NSData ows_isValidImageAtPath:filePath]) {
|
||||
return nil;
|
||||
}
|
||||
YYImage *_Nullable animatedGif = filePath ? [YYImage imageWithContentsOfFile:filePath] : nil;
|
||||
if (!animatedGif) {
|
||||
DDLogError(@"%@ Could not load image: %@", [self tag], filePath);
|
||||
UIView *view = [UIView new];
|
||||
view.backgroundColor = [UIColor colorWithWhite:0.85f alpha:1.f];
|
||||
return view;
|
||||
}
|
||||
if (![fileData ows_isValidImage]) {
|
||||
return nil;
|
||||
}
|
||||
FLAnimatedImage *animatedGif = [FLAnimatedImage animatedImageWithGIFData:fileData];
|
||||
FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init];
|
||||
imageView.animatedImage = animatedGif;
|
||||
YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc] init];
|
||||
imageView.image = animatedGif;
|
||||
CGSize size = [self mediaViewDisplaySize];
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
imageView.frame = CGRectMake(0.0, 0.0, size.width, size.height);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#import "FullImageViewController.h"
|
||||
#import "AttachmentSharing.h"
|
||||
#import "FLAnimatedImage.h"
|
||||
#import "TSAnimatedAdapter.h"
|
||||
#import "TSMessageAdapter.h"
|
||||
#import "TSPhotoAdapter.h"
|
||||
|
@ -12,6 +11,7 @@
|
|||
#import "UIUtil.h"
|
||||
#import "UIView+OWS.h"
|
||||
#import <SignalServiceKit/NSData+Image.h>
|
||||
#import <YYImage/YYImage.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -170,10 +170,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (void)initializeImageView {
|
||||
if (self.isAnimated) {
|
||||
if ([self.fileData ows_isValidImage]) {
|
||||
// Present the animated image using Flipboard/FLAnimatedImage
|
||||
FLAnimatedImage *animatedGif = [FLAnimatedImage animatedImageWithGIFData:self.fileData];
|
||||
FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init];
|
||||
imageView.animatedImage = animatedGif;
|
||||
YYImage *animatedGif = [YYImage imageWithData:self.fileData];
|
||||
YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc] init];
|
||||
imageView.image = animatedGif;
|
||||
imageView.frame = self.originRect;
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
imageView.clipsToBounds = YES;
|
||||
|
|
|
@ -138,16 +138,19 @@ class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
|
||||
private func createAnimatedPreview() {
|
||||
guard attachment.isValidImage else {
|
||||
return
|
||||
}
|
||||
let data = attachment.data
|
||||
// Use Flipboard FLAnimatedImage library to display gifs
|
||||
guard let animatedImage = FLAnimatedImage(gifData:data) else {
|
||||
createGenericPreview()
|
||||
return
|
||||
}
|
||||
let animatedImageView = FLAnimatedImageView()
|
||||
animatedImageView.animatedImage = animatedImage
|
||||
guard let dataUrl = attachment.dataUrl else {
|
||||
createGenericPreview()
|
||||
return
|
||||
}
|
||||
guard let image = YYImage(contentsOfFile:dataUrl.path) else {
|
||||
createGenericPreview()
|
||||
return
|
||||
}
|
||||
let animatedImageView = YYAnimatedImageView()
|
||||
animatedImageView.image = image
|
||||
animatedImageView.contentMode = .scaleAspectFit
|
||||
self.addSubview(animatedImageView)
|
||||
animatedImageView.autoPinWidthToSuperview()
|
||||
|
|
Loading…
Reference in a new issue