JXMyFile.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // JXMyFile.h.m
  3. //
  4. // Created by flyeagleTang on 14-4-3.
  5. // Copyright (c) 2014年 Reese. All rights reserved.
  6. //
  7. #import "JXMyFile.h"
  8. //#import "JXChatViewController.h"
  9. //#import "AppDelegate.h"
  10. #import "JXLabel.h"
  11. #import "JXImageView.h"
  12. //#import "JXCell.h"
  13. //#import "JXRoomPool.h"
  14. #import "JXTableView.h"
  15. #import "JXNewFriendViewController.h"
  16. #import "menuImageView.h"
  17. #import "QCheckBox.h"
  18. //#import "XMPPRoom.h"
  19. //#import "JXRoomObject.h"
  20. #import "FileListCell.h"
  21. @interface JXMyFile ()
  22. @end
  23. @implementation JXMyFile
  24. - (id)init
  25. {
  26. self = [super init];
  27. if (self) {
  28. self.title = Localized(@"JXMyFileVC_SelFile");
  29. self.heightHeader = JX_SCREEN_TOP;
  30. self.heightFooter = 0;
  31. self.isGotoBack = YES;
  32. //self.view.frame = g_window.bounds;
  33. [self createHeadAndFoot];
  34. self.isShowFooterPull = NO;
  35. _selMenu = 0;
  36. //添加文件的确定按钮,无用
  37. // UIButton* _btn;
  38. // _btn = [UIFactory createCommonButton:@"确定" target:self action:@selector(onAdd)];
  39. // _btn.frame = CGRectMake(JX_SCREEN_WIDTH - 70, 20+10, 60, 24);
  40. // [self.tableHeader addSubview:_btn];
  41. }
  42. return self;
  43. }
  44. - (void)onAdd{
  45. }
  46. - (void)viewDidLoad
  47. {
  48. [super viewDidLoad];
  49. _array=[[NSMutableArray alloc] init];
  50. [self refresh];
  51. }
  52. - (void)viewWillAppear:(BOOL)animated
  53. {
  54. [super viewWillAppear:animated];
  55. }
  56. - (void)didReceiveMemoryWarning
  57. {
  58. [super didReceiveMemoryWarning];
  59. // Dispose of any resources that can be recreated.
  60. }
  61. #pragma mark ---------tableView协议----------------
  62. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  63. {
  64. return 1;
  65. }
  66. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  67. {
  68. return _array.count;
  69. }
  70. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  71. {
  72. FileListCell *cell=nil;
  73. // NSString* cellName = [NSString stringWithFormat:@"msg_%d_%d",_refreshCount,indexPath.row];
  74. NSString* cellName = [NSString stringWithFormat:@"FileListCell"];
  75. cell = [tableView dequeueReusableCellWithIdentifier:cellName];
  76. if(cell==nil){
  77. // cell = [FileListCell alloc];
  78. // cell.bottomTitle = [TimeUtil formatDate:user.timeCreate format:@"MM-dd HH:mm"];
  79. cell = [[NSBundle mainBundle] loadNibNamed:@"FileListCell" owner:self options:nil][0];
  80. }
  81. NSString *s=_array[indexPath.row];
  82. [_table addToPool:cell];
  83. cell.title.text = [s lastPathComponent];
  84. cell.subtitle.text = [s pathExtension];
  85. cell.headImage.image = [UIImage imageNamed:@"im_file_button_normal"];
  86. return cell;
  87. }
  88. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  89. { [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  90. NSString *s=_array[indexPath.row];
  91. if(self.delegate != nil && [self.delegate respondsToSelector:self.didSelect])
  92. [self.delegate performSelectorOnMainThread:self.didSelect withObject:s waitUntilDone:NO];
  93. [self actionQuit];
  94. // _pSelf = nil;
  95. }
  96. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
  97. // [cell retain];
  98. [_table delFromPool:cell];
  99. }
  100. - (void)dealloc {
  101. [_array removeAllObjects];
  102. // [_array release];
  103. // [super dealloc];
  104. }
  105. //读到聊天记录里面的图片
  106. -(void)getArrayData{
  107. //获取路径下的所有文件
  108. _array=[FileInfo getFiles:myTempFilePath];
  109. }
  110. -(void)refresh{
  111. [self stopLoading];
  112. _refreshCount++;
  113. [_array removeAllObjects];
  114. // [_array release];
  115. [self getArrayData];
  116. [_table reloadData];
  117. }
  118. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  119. {
  120. return 60;
  121. }
  122. -(void)scrollToPageUp{
  123. [self refresh];
  124. }
  125. @end