Bladeren bron

fix watch table background image flickering on DB and thumbnail updates

Tobias Conradi 9 jaren geleden
bovenliggende
commit
7b68b27f78

+ 2 - 1
Sources/VLCThumbnailsCache.m

@@ -112,9 +112,10 @@
 {
     UIImage *rawThumbnail = [self thumbnailForManagedObject:object refreshCache:refreshCache];
     CGSize rawSize = rawThumbnail.size;
+    CGFloat rawScale = rawThumbnail.scale;
 
     /* scaling is potentially expensive, so we should avoid re-doing it for the same size over and over again */ 
-    if (rawSize.width <= rect.size.width && rawSize.height <= rect.size.height)
+    if (rawSize.width*rawScale <= rect.size.width*scale && rawSize.height*rawScale <= rect.size.height*scale)
         return rawThumbnail;
 
     UIImage *scaledImage = [UIImage scaleImage:rawThumbnail toFitRect:rect scale:scale];

+ 2 - 2
VLC WatchKit Native Extension/Classes/VLCRowController.h

@@ -20,8 +20,8 @@
 @property (nonatomic, copy) NSString *mediaTitle;
 @property (nonatomic) CGFloat playbackProgress;
 
-@property (nonatomic, weak, readonly) id mediaLibraryObject;
+@property (nonatomic, weak, readonly) NSManagedObject *mediaLibraryObject;
 
-- (void) configureWithMediaLibraryObject:(id)object;
+- (void) configureWithMediaLibraryObject:(NSManagedObject *)object;
 
 @end

+ 3 - 3
VLC WatchKit Native Extension/Classes/VLCRowController.m

@@ -17,7 +17,7 @@
 #import <WatchConnectivity/WatchConnectivity.h>
 
 @interface VLCRowController()
-@property (nonatomic, weak, readwrite) id mediaLibraryObject;
+@property (nonatomic, weak, readwrite) NSManagedObject *mediaLibraryObject;
 @property (nonatomic, readonly) CGRect thumbnailSize;
 @property (nonatomic, readonly) CGFloat rowWidth;
 @property (nonatomic, readonly) CGFloat scale;
@@ -51,7 +51,7 @@
     _scale = screenScale;
 }
 
-- (void)configureWithMediaLibraryObject:(id)storageObject
+- (void)configureWithMediaLibraryObject:(NSManagedObject *)storageObject
 {
     NSString *title = nil;
     float playbackProgress = 0.0;
@@ -88,7 +88,7 @@
 
     /* FIXME: add placeholder image once designed */
 
-    if (storageObject != self.mediaLibraryObject) {
+    if (![storageObject.objectID.URIRepresentation isEqual: self.mediaLibraryObject.objectID.URIRepresentation]) {
         self.group.backgroundImage = [UIImage imageNamed:@"tableview-gradient"];
     }