1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-03 09:57:46 +01:00
Telegram/Telegraph/TGUserAvatarGalleryItem.m

42 lines
1.2 KiB
Mathematica
Raw Normal View History

2015-10-01 18:19:52 +02:00
#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