JXMediaCell.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // JXMediaCell.m
  3. //
  4. // Created by flyeagleTang on 14-4-3.
  5. // Copyright (c) 2014年 Reese. All rights reserved.
  6. //
  7. #import "JXMediaCell.h"
  8. #import "JXLabel.h"
  9. #import "JXImageView.h"
  10. #import "AppDelegate.h"
  11. #import "JXMediaObject.h"
  12. @implementation JXMediaCell
  13. //@synthesize title,subtitle,rightTitle,bottomTitle,headImage,bage,userId;
  14. @synthesize bage;
  15. @synthesize media;
  16. @synthesize delegate;
  17. @synthesize head;
  18. @synthesize pauseBtn;
  19. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  20. {
  21. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  22. if(self){
  23. self.selectionStyle = UITableViewCellSelectionStyleBlue;
  24. UIFont* f0 = g_factory.font15;
  25. // UIFont* f1 = g_factory.font15b;
  26. int n = 120;
  27. UIView* v = [[UIView alloc]initWithFrame:CGRectMake(0,0, JX_SCREEN_WIDTH, n)];
  28. v.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
  29. self.selectedBackgroundView = v;
  30. // [v release];
  31. UIView* line = [[UIView alloc]initWithFrame:CGRectMake(0,n-LINE_WH,JX_SCREEN_WIDTH,LINE_WH)];
  32. line.backgroundColor = THE_LINE_COLOR;
  33. [self.contentView addSubview:line];
  34. // [line release];
  35. JXLabel* lb;
  36. // lb = [[JXLabel alloc]initWithFrame:CGRectMake(120, 5, JX_SCREEN_WIDTH-120-60, 20)];
  37. // lb.textColor = [UIColor blackColor];
  38. // lb.userInteractionEnabled = NO;
  39. // lb.backgroundColor = [UIColor clearColor];
  40. // lb.font = f1;
  41. // [self.contentView addSubview:lb];
  42. //// [lb release];
  43. // [lb setText:[media.fileName lastPathComponent]];
  44. // lb.backgroundColor = [UIColor redColor];
  45. lb = [[JXLabel alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-60, 5, 50, 20)];
  46. lb.textColor = [UIColor lightGrayColor];
  47. lb.userInteractionEnabled = NO;
  48. lb.backgroundColor = [UIColor clearColor];
  49. lb.textAlignment = NSTextAlignmentRight;
  50. lb.font = f0;
  51. [self.contentView addSubview:lb];
  52. // [lb release];
  53. lb.text = [NSString stringWithFormat:@"%d''",[media.timeLen intValue]];
  54. // lb.backgroundColor = [UIColor magentaColor];
  55. if ([media.timeLen intValue] <= 0) {
  56. lb.hidden = YES;
  57. }
  58. lb = [[JXLabel alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-130, 95, 120, 20)];
  59. lb.textColor = [UIColor lightGrayColor];
  60. lb.userInteractionEnabled = NO;
  61. lb.backgroundColor = [UIColor clearColor];
  62. lb.textAlignment = NSTextAlignmentRight;
  63. lb.font = f0;
  64. [self.contentView addSubview:lb];
  65. // [lb release];
  66. lb.text = [TimeUtil getTimeStrStyle1:[media.createTime timeIntervalSince1970]];
  67. // lb.backgroundColor = [UIColor cyanColor];
  68. bageImage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"little_red_dot"]];
  69. bageImage.frame = CGRectMake(35, 8-10, 25, 25);
  70. bageImage.backgroundColor = [UIColor clearColor];
  71. [self.contentView addSubview:bageImage];
  72. // [bageImage release];
  73. bageNumber=[[UILabel alloc]initWithFrame:CGRectZero];
  74. bageNumber.userInteractionEnabled = NO;
  75. bageNumber.frame = CGRectMake(0,0, 25, 25);
  76. bageNumber.backgroundColor = [UIColor clearColor];
  77. bageNumber.textAlignment = NSTextAlignmentCenter;
  78. bageNumber.text = bage;
  79. bageNumber.textColor = [UIColor whiteColor];
  80. bageNumber.font = f0;
  81. [bageImage addSubview:bageNumber];
  82. // [bageNumber release];
  83. self.bage = bage;
  84. JXImageView* iv;
  85. iv = [[JXImageView alloc]init];
  86. iv.userInteractionEnabled = YES;
  87. iv.delegate = delegate;
  88. iv.didTouch = @selector(actionFullScreen);
  89. iv.frame = CGRectMake(5,5,110,110);
  90. iv.layer.cornerRadius = 6;
  91. iv.layer.masksToBounds = YES;
  92. [self.contentView addSubview:iv];
  93. // [iv release];
  94. iv.image = [FileInfo getFirstImageFromVideo:media.fileName];
  95. _player= [[JXVideoPlayer alloc] initWithParent:iv];
  96. _player.videoFile = media.fileName;
  97. _player.isVideo = media.isVideo;
  98. _player.timeLen = [media.timeLen intValue];
  99. self.head = iv;
  100. }
  101. return self;
  102. }
  103. -(void)dealloc{
  104. NSLog(@"JXMediaCell.dealloc");
  105. self.media = nil;
  106. self.delegate = nil;
  107. self.bage = nil;
  108. // [_player release];
  109. // [super dealloc];
  110. }
  111. - (void)awakeFromNib
  112. {
  113. // Initialization code
  114. [super awakeFromNib];
  115. }
  116. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  117. {
  118. [super setSelected:selected animated:animated];
  119. // Configure the view for the selected state
  120. }
  121. -(void)setBage:(NSString *)s{
  122. bageImage.hidden = [s intValue]<=0;
  123. bageNumber.text = s;
  124. bage = s;
  125. }
  126. @end