VLCLocalNetworkListCell.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // VLCLocalNetworkListCell.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 10.08.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCLocalNetworkListCell.h"
  11. @implementation VLCLocalNetworkListCell
  12. + (VLCLocalNetworkListCell *)cellWithReuseIdentifier:(NSString *)ident
  13. {
  14. NSArray *nibContentArray = [[NSBundle mainBundle] loadNibNamed:@"VLCLocalNetworkListCell" owner:nil options:nil];
  15. NSAssert([nibContentArray count] == 1, @"meh");
  16. NSAssert([[nibContentArray lastObject] isKindOfClass:[VLCLocalNetworkListCell class]], @"meh meh");
  17. VLCLocalNetworkListCell *cell = (VLCLocalNetworkListCell *)[nibContentArray lastObject];
  18. return cell;
  19. }
  20. - (void)awakeFromNib
  21. {
  22. self.titleLabel.text = @"";
  23. self.subtitleLabel.text = @"";
  24. self.thumbnailView.contentMode = UIViewContentModeScaleAspectFit;
  25. self.downloadButton.hidden = YES;
  26. }
  27. - (void)setIsDirectory:(BOOL)isDirectory
  28. {
  29. self.titleLabel.hidden = self.subtitleLabel.hidden = isDirectory;
  30. self.folderTitleLabel.hidden = !isDirectory;
  31. _isDirectory = isDirectory;
  32. }
  33. - (void)setTitle:(NSString *)title
  34. {
  35. BOOL isDir = self.isDirectory;
  36. self.folderTitleLabel.text = self.titleLabel.text = title;
  37. self.titleLabel.hidden = self.subtitleLabel.hidden = isDir;
  38. self.folderTitleLabel.hidden = !isDir;
  39. _title = title;
  40. }
  41. - (void)setSubtitle:(NSString *)subtitle
  42. {
  43. self.subtitleLabel.text = subtitle;
  44. }
  45. - (void)setIcon:(UIImage *)icon
  46. {
  47. self.thumbnailView.image = icon;
  48. }
  49. - (void)setIsDownloadable:(BOOL)isDownloadable
  50. {
  51. self.downloadButton.hidden = !isDownloadable;
  52. }
  53. - (void)triggerDownload:(id)sender
  54. {
  55. NSLog(@"Download requires adaptation of VLCHTTPDownloadViewController");
  56. }
  57. + (CGFloat)heightOfCell
  58. {
  59. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
  60. return 80.;
  61. return 48.;
  62. }
  63. @end