Browse Source

thumbnails cache: add basic watch support and add it to the respective target

Felix Paul Kühne 10 years ago
parent
commit
f07de47f4a
2 changed files with 26 additions and 5 deletions
  1. 24 5
      Sources/VLCThumbnailsCache.m
  2. 2 0
      VLC for iOS.xcodeproj/project.pbxproj

+ 24 - 5
Sources/VLCThumbnailsCache.m

@@ -2,7 +2,7 @@
  * VLCThumbnailsCache.m
  * VLC for iOS
  *****************************************************************************
- * Copyright (c) 2013-2014 VideoLAN. All rights reserved.
+ * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
  * $Id$
  *
  * Authors: Gleb Pinigin <gpinigin # gmail.com>
@@ -11,6 +11,7 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
+#import "VLC for iOS-Prefix.pch"
 #import "VLCThumbnailsCache.h"
 #import <CommonCrypto/CommonDigest.h>
 #import "UIImage+Blur.h"
@@ -18,16 +19,32 @@
 static NSInteger MaxCacheSize;
 static NSCache *_thumbnailCache;
 static NSCache *_thumbnailCacheMetadata;
+static NSInteger _currentDeviceIdiom;
 
 @implementation VLCThumbnailsCache
 
 #define MAX_CACHE_SIZE_IPHONE 21  // three times the number of items shown on iPhone 5
 #define MAX_CACHE_SIZE_IPAD   27  // three times the number of items shown on iPad
+#define MAX_CACHE_SIZE_WATCH  15  // three times the number of items shown on 42mm Watch
 
 +(void)initialize
 {
-    MaxCacheSize = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)?
-                                MAX_CACHE_SIZE_IPAD: MAX_CACHE_SIZE_IPHONE;
+    _currentDeviceIdiom = [[UIDevice currentDevice] userInterfaceIdiom];
+
+    MaxCacheSize = 0;
+
+    switch (_currentDeviceIdiom) {
+        case UIUserInterfaceIdiomPad:
+            MaxCacheSize = MAX_CACHE_SIZE_IPAD;
+            break;
+        case UIUserInterfaceIdiomPhone:
+            MaxCacheSize = MAX_CACHE_SIZE_IPHONE;
+            break;
+
+        default:
+            MaxCacheSize = MAX_CACHE_SIZE_WATCH;
+            break;
+    }
 
     _thumbnailCache = [[NSCache alloc] init];
     _thumbnailCacheMetadata = [[NSCache alloc] init];
@@ -179,12 +196,12 @@ static NSCache *_thumbnailCacheMetadata;
 {
     UIImage *clusterThumb;
     CGSize imageSize;
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+    if (_currentDeviceIdiom == UIUserInterfaceIdiomPad) {
         if ([UIScreen mainScreen].scale==2.0)
             imageSize = CGSizeMake(682., 384.);
         else
             imageSize = CGSizeMake(341., 192.);
-    } else {
+    } else if (_currentDeviceIdiom == UIUserInterfaceIdiomPhone) {
         if (SYSTEM_RUNS_IOS7_OR_LATER) {
             if ([UIScreen mainScreen].scale==2.0)
                 imageSize = CGSizeMake(480., 270.);
@@ -196,6 +213,8 @@ static NSCache *_thumbnailCacheMetadata;
             else
                 imageSize = CGSizeMake(129., 73.);
         }
+    } else {
+        imageSize = CGSizeMake(272., 120.);
     }
 
     UIGraphicsBeginImageContext(imageSize);

+ 2 - 0
VLC for iOS.xcodeproj/project.pbxproj

@@ -425,6 +425,7 @@
 		7DE1862C175BA9A9006C0173 /* badgeUnread@2x~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DE1862E175BA9A9006C0173 /* badgeUnread@2x~iphone.png */; };
 		7DE1862F175BA9AC006C0173 /* badgeUnread~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DE18631175BA9AC006C0173 /* badgeUnread~ipad.png */; };
 		7DE18632175BA9AF006C0173 /* badgeUnread~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DE18634175BA9AF006C0173 /* badgeUnread~iphone.png */; };
+		7DE715ED1AD2DAE50075E716 /* VLCThumbnailsCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D37849D183A98DD009EE944 /* VLCThumbnailsCache.m */; };
 		7DEB3B5D17647B240038FC70 /* bottomBlackBar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DEB3B5B17647B240038FC70 /* bottomBlackBar@2x.png */; };
 		7DEB3B5E17647B240038FC70 /* bottomBlackBar.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DEB3B5C17647B240038FC70 /* bottomBlackBar.png */; };
 		7DEB3B6017647DE30038FC70 /* iTunesArtwork@2x in Resources */ = {isa = PBXBuildFile; fileRef = 7DEB3B5F17647DE30038FC70 /* iTunesArtwork@2x */; };
@@ -3579,6 +3580,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				DD6FA7B01ACD641C006DEB2E /* VLCNowPlayingInterfaceController.m in Sources */,
+				7DE715ED1AD2DAE50075E716 /* VLCThumbnailsCache.m in Sources */,
 				DDF157B11ACB162700AAFBC6 /* MediaLibrary.xcdatamodeld in Sources */,
 				DDE490731ACE964200B1B5E3 /* VLCBaseInterfaceController.m in Sources */,
 				DDE4906C1ACDB63F00B1B5E3 /* VLCNotificationRelay.m in Sources */,