浏览代码

adjusted the detailview to handle different filetypes

Carola Nitz 10 年之前
父节点
当前提交
53f29632fa

+ 16 - 10
VLC for iOS WatchKit Extension/VLCDetailInterfaceController.m

@@ -16,7 +16,7 @@
 #import "VLCThumbnailsCache.h"
 
 @interface VLCDetailInterfaceController ()
-@property (nonatomic, weak) MLFile *file;
+@property (nonatomic, weak) NSManagedObject *file;
 @end
 
 @implementation VLCDetailInterfaceController
@@ -35,10 +35,8 @@
     [super awakeWithContext:context];
 
     [self addNowPlayingMenu];
-    
-    if ([context isKindOfClass:[MLFile class]]) {
-        [self configureWithFile:context];
-    }
+    [self configureWithFile:context];
+
 }
 
 - (void)willActivate {
@@ -53,14 +51,22 @@
     [super didDeactivate];
 }
 
-- (void)configureWithFile:(MLFile *)file {
+- (void)configureWithFile:(NSManagedObject *)file {
     self.file = file;
-
-    [self.titleLabel setText:file.title];
-    self.durationLabel.text = [VLCTime timeWithNumber:file.duration].stringValue;
+    if ([file isKindOfClass:[MLShowEpisode class]]) {
+        [self.titleLabel setText:((MLShowEpisode *)file).name];
+    } else if ([file isKindOfClass:[MLFile class]]) {
+        self.durationLabel.text = [VLCTime timeWithNumber:((MLFile *)file).duration].stringValue;
+        [self.titleLabel setText:((MLFile *)file).title];
+    } else if ([file isKindOfClass:[MLAlbumTrack class]]) {
+        [self.titleLabel setText:((MLAlbumTrack *)file).title];
+    } else {
+        NSAssert(NO, @"check what filetype we try to show here and add it above");
+    }
     BOOL playEnabled = file != nil;
     self.playNowButton.enabled = playEnabled;
-    UIImage *thumbnail = [VLCThumbnailsCache thumbnailForMediaFile:file];
+
+    UIImage *thumbnail = [VLCThumbnailsCache thumbnailForManagedObject:file];
     self.imageView.hidden = thumbnail == nil;
     if (thumbnail) {
         self.imageView.image = thumbnail;

+ 0 - 1
VLC for iOS WatchKit Extension/VLCRowController.h

@@ -13,6 +13,5 @@
 #import <WatchKit/WatchKit.h>
 @interface VLCRowController : NSObject
 @property (nonatomic, weak) IBOutlet WKInterfaceLabel *titleLabel;
-@property (nonatomic, weak) IBOutlet WKInterfaceLabel *durationLabel;
 @property (nonatomic, weak) IBOutlet WKInterfaceGroup *group;
 @end