浏览代码

Deploy NSByteCountFormatter instead of calculating file sizes ourselves as this results in a more appealing appearance

Felix Paul Kühne 11 年之前
父节点
当前提交
da74fe8d79

+ 1 - 1
Sources/VLCLocalServerFolderListViewController.m

@@ -206,7 +206,7 @@
             else
                 mediaSize = [mediaItem.size longLongValue];
 
-            [cell setSubtitle: [NSString stringWithFormat:@"%0.2f MB  (%@)", (float)(mediaSize / 1e6), mediaItem.duration]];
+            [cell setSubtitle: [NSString stringWithFormat:@"%@ (%@)", [NSByteCountFormatter stringFromByteCount:mediaSize countStyle:NSByteCountFormatterCountStyleFile], mediaItem.duration]];
             [cell setIsDirectory:NO];
             cell.isDownloadable = YES;
             if (![mediaItem.albumArt isEqualToString:NULL]) {

+ 1 - 1
Sources/VLCPlaylistCollectionViewCell.m

@@ -218,7 +218,7 @@
     VLCPlaylistViewController *delegate = (VLCPlaylistViewController*)self.collectionView.delegate;
 
     if (delegate.isEditing)
-        self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %i MB", [VLCTime timeWithNumber:[mediaFile duration]], (int)([mediaFile fileSizeInBytes] / 1e6)];
+        self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@", [VLCTime timeWithNumber:[mediaFile duration]], [NSByteCountFormatter stringFromByteCount:[mediaFile fileSizeInBytes] countStyle:NSByteCountFormatterCountStyleFile]];
     else {
         self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[mediaFile duration]]];
         if (mediaFile.videoTrack) {

+ 1 - 1
Sources/VLCPlaylistTableViewCell.m

@@ -224,7 +224,7 @@
         self.titleLabel.text = mediaFile.title;
 
     if (self.isEditing)
-        self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %i MB", [VLCTime timeWithNumber:[mediaFile duration]], (int)([mediaFile fileSizeInBytes] / 1e6)];
+        self.subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@", [VLCTime timeWithNumber:[mediaFile duration]], [NSByteCountFormatter stringFromByteCount:[mediaFile fileSizeInBytes] countStyle:NSByteCountFormatterCountStyleFile]];
     else {
         self.subtitleLabel.text = [NSString stringWithFormat:@"%@", [VLCTime timeWithNumber:[mediaFile duration]]];
         if (mediaFile.videoTrack) {