1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-02 09:27:55 +01:00
Telegram/Telegraph/TGUserAvatarGalleryItem.m
2015-10-01 19:19:52 +03:00

42 lines
1.2 KiB
Objective-C

#import "TGUserAvatarGalleryItem.h"
#import "TGUserAvatarGalleryItemView.h"
#import "TGRemoteImageView.h"
@implementation TGUserAvatarGalleryItem
- (instancetype)initWithLegacyThumbnailUrl:(NSString *)legacyThumbnailUrl legacyUrl:(NSString *)legacyUrl imageSize:(CGSize)imageSize isCurrent:(bool)isCurrent
{
NSMutableString *imageUri = [[NSMutableString alloc] initWithString:@"peer-avatar://?"];
[imageUri appendFormat:@"legacy-cache-url=%@", legacyUrl];
[imageUri appendFormat:@"&legacy-thumbnail-cache-url=%@", legacyThumbnailUrl];
[imageUri appendFormat:@"&width=%d&height=%d", (int)imageSize.width, (int)imageSize.height];
self = [super initWithUri:imageUri imageSize:imageSize];
if (self != nil)
{
_legacyThumbnailUrl = legacyThumbnailUrl;
_legacyUrl = legacyUrl;
_isCurrent = isCurrent;
}
return self;
}
- (Class)viewClass
{
return [TGUserAvatarGalleryItemView class];
}
- (NSString *)filePath
{
return [[TGRemoteImageView sharedCache] pathForCachedData:_legacyUrl];
}
- (BOOL)isEqual:(id)object
{
return [object isKindOfClass:[TGUserAvatarGalleryItem class]] && ((_isCurrent && ((TGUserAvatarGalleryItem *)object)->_isCurrent) || [super isEqual:object]);
}
@end