VLCLocalNetworkListCell.m 2.3 KB

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