Feed icons! '/favicon.ico' download, storage and display.

This commit is contained in:
relikd
2018-12-12 02:16:31 +01:00
parent 13a4191b93
commit 2bd7078cbd
13 changed files with 144 additions and 67 deletions

View File

@@ -33,4 +33,5 @@
- (NSArray<FeedArticle*>*)sortedArticles;
- (int)markAllItemsRead;
- (int)markAllItemsUnread;
- (NSImage*)iconImage16;
@end

View File

@@ -21,11 +21,14 @@
// SOFTWARE.
#import "Feed+Ext.h"
#import "Constants.h"
#import "DrawImage.h"
#import "FeedMeta+Ext.h"
#import "FeedGroup+Ext.h"
#import "FeedIcon+CoreDataClass.h"
#import "FeedArticle+CoreDataClass.h"
#import "Constants.h"
#import <Cocoa/Cocoa.h>
#import <RSXML/RSXML.h>
@implementation Feed (Ext)
@@ -214,4 +217,19 @@
return newCount - oldCount;
}
/**
@return Return @c 16x16px image. Either from core data storage or generated default RSS icon.
*/
- (NSImage*)iconImage16 {
NSData *imgData = self.icon.icon;
if (imgData) {
return [[NSImage alloc] initWithData:imgData];
} else {
static NSImage *defaultRSSIcon;
if (!defaultRSSIcon)
defaultRSSIcon = [RSSIcon iconWithSize:16];
return defaultRSSIcon;
}
}
@end

View File

@@ -33,6 +33,7 @@ typedef NS_ENUM(int16_t, FeedGroupType) {
+ (instancetype)newGroup:(FeedGroupType)type inContext:(NSManagedObjectContext*)context;
- (void)setName:(NSString*)name andRefreshString:(NSString*)refreshStr;
- (NSImage*)groupIconImage16;
// Handle children and parents
- (NSString*)indexPathString;
- (NSMutableArray<FeedGroup*>*)allParents;

View File

@@ -24,6 +24,8 @@
#import "FeedMeta+Ext.h"
#import "Feed+Ext.h"
#import <Cocoa/Cocoa.h>
@implementation FeedGroup (Ext)
/// Enum tpye getter see @c FeedGroupType
- (FeedGroupType)typ { return (FeedGroupType)self.type; }
@@ -46,6 +48,16 @@
if (![self.refreshStr isEqualToString:refreshStr]) self.refreshStr = refreshStr;
}
/// @return Return static @c 16x16px NSImageNameFolder image.
- (NSImage*)groupIconImage16 {
static NSImage *groupIcon;
if (!groupIcon) {
groupIcon = [NSImage imageNamed:NSImageNameFolder];
groupIcon.size = NSMakeSize(16, 16);
}
return groupIcon;
}
#pragma mark - Handle Children And Parents -