WeiboViewControlle.m 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132
  1. //
  2. // WeiboViewControlle.m
  3. // wq
  4. //
  5. // Created by weqia on 13-8-28.
  6. // Copyright (c) 2013年 Weqia. All rights reserved.
  7. //
  8. #import "WeiboViewControlle.h"
  9. #import "WeiboCell.h"
  10. #import "ObjUrlData.h"
  11. #import "JSONKit.h"
  12. #import "LXActionSheet.h"
  13. #import "addMsgVC.h"
  14. #import "JXTextView.h"
  15. #import <MediaPlayer/MediaPlayer.h>
  16. #import "photosViewController.h"
  17. //#import "mvViewController.h"
  18. //#import "userInfoVC.h"
  19. #import "JXUserInfoVC.h"
  20. //#import "JXCell.h"
  21. #import "webpageVC.h"
  22. #import "JXBlogRemind.h"
  23. #import "JXTabMenuView.h"
  24. #import "JXBlogRemindVC.h"
  25. #import "JX_DownListView.h"
  26. #import "JXReportUserVC.h"
  27. #import "JXActionSheetVC.h"
  28. #import "JXMenuView.h"
  29. #import "ImageResize.h"
  30. #import "JXCameraVC.h"
  31. #import "HBHttpRequestCache.h"
  32. #define TopHeight 7
  33. #define CellHeight 45
  34. #define TopImageInset JX_SCREEN_WIDTH/5*1.8
  35. @interface WeiboViewControlle ()<UIAlertViewDelegate,JXActionSheetVCDelegate,JXSelectMenuViewDelegate,JXMenuViewDelegate,WeiboCellDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,JXCameraVCDelegate>
  36. {
  37. BOOL _first;
  38. NSString * phoneNumber;
  39. UIWebView * webView;
  40. NSMutableArray * _images; //测试用
  41. NSMutableArray * _contents;
  42. UIImageView *_topBackImageView;
  43. }
  44. @property (nonatomic,copy)NSString *urlStr;
  45. @property (nonatomic, strong) JXMessageObject *remindMsg;
  46. @property (nonatomic, strong) NSMutableArray *remindArray;
  47. @property (nonatomic, strong) WeiboData *currentData;
  48. @property (nonatomic, strong) JXActionSheetVC *actionVC;
  49. @property (nonatomic, strong) WeiboCell *lastCell; // 用于点赞、评论控件, 记录上个cell
  50. //@property (nonatomic, strong) NSMutableArray *collectArray;
  51. @property (nonatomic, assign) BOOL isFirstGoin;
  52. @property (nonatomic, strong) NSString *topImageUrl;
  53. @property (nonatomic, assign) CGFloat lastOffsetY;
  54. @property (nonatomic, assign) CGFloat deltaY;
  55. @end
  56. @implementation WeiboViewControlle
  57. @synthesize replyDataTemp,selectWeiboData,deleteWeibo,refreshCount,refreshCellIndex,selectWeiboCell,user;
  58. - (id)init
  59. {
  60. self = [super init];
  61. if (self) {
  62. _pool = [[NSMutableArray alloc]init];
  63. refreshCellIndex = -1;
  64. //self.isGotoBack = NO;
  65. // self.title = Localized(@"WeiboViewControlle_MyFriend");
  66. self.title = Localized(@"JX_LifeCircle");
  67. self.heightFooter = 0;
  68. self.heightHeader = 0;
  69. if (self.isDetail) {
  70. self.heightHeader = JX_SCREEN_TOP;
  71. self.isGotoBack = YES;
  72. self.title = Localized(@"JX_Detail");
  73. }
  74. // _input.delegate = self;
  75. #ifdef IS_SHOW_MENU
  76. self.isGotoBack = YES;
  77. #endif
  78. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  79. [self createHeadAndFoot];
  80. if (!self.isDetail) {
  81. #ifdef IS_SHOW_MENU
  82. [self setupHeadView];
  83. #endif
  84. // [self buildAddMsg];
  85. }else {
  86. self.isShowFooterPull = NO;
  87. }
  88. [self buildInput];
  89. _first = YES;
  90. replyDataTemp = [[WeiboReplyData alloc]init];
  91. _datas=[[NSMutableArray alloc]init];
  92. [g_notify addObserver:self selector:@selector(doRefresh:) name:kUpdateUserNotifaction object:nil];
  93. [g_notify addObserver:self selector:@selector(urlTouch:) name:kCellTouchUrlNotifaction object:nil];
  94. [g_notify addObserver:self selector:@selector(phoneTouch:) name:kCellTouchPhoneNotifaction object:nil];
  95. [g_notify addObserver:self selector:@selector(remindNotif:) name:kXMPPMessageWeiboRemind object:nil];
  96. [g_notify addObserver:self selector:@selector(didEnterBackground:) name:kApplicationDidEnterBackground object:nil];
  97. _remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
  98. if (_remindArray.count > 0 && !self.isNotShowRemind) {
  99. [self createTableHeadShowRemind];
  100. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  101. // [g_mainVC.tb setBadge:2 title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
  102. int number = 0;
  103. if (g_App.linkArray.count == 0) {
  104. number = 2;
  105. }else if(g_App.linkArray.count == 1){
  106. number = 3;
  107. }else if(g_App.linkArray.count == 2){
  108. number = 100;
  109. }
  110. [g_mainVC.tb setBadge:number title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
  111. });
  112. }else {
  113. [self createTableHeadShowRemind];
  114. }
  115. [self getWeiboBackImage];
  116. }
  117. return self;
  118. }
  119. - (void)setupHeadView {
  120. self.tableHeader = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_TOP)];
  121. self.tableHeader.backgroundColor = [UIColor whiteColor];
  122. [self.view addSubview:self.tableHeader];
  123. JXLabel* p = [[JXLabel alloc]initWithFrame:CGRectMake(40, JX_SCREEN_TOP - 32, self_width-40*2, 20)];
  124. p.backgroundColor = [UIColor clearColor];
  125. p.textAlignment = NSTextAlignmentCenter;
  126. p.textColor = [UIColor blackColor];
  127. p.text = self.title;
  128. p.font = [UIFont systemFontOfSize:18.0];
  129. p.userInteractionEnabled = YES;
  130. [self.tableHeader addSubview:p];
  131. if (self.isGotoBack) {
  132. self.gotoBackBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 46, 46, 46)];
  133. [self.gotoBackBtn setBackgroundImage:[UIImage imageNamed:@"title_back_black_big"] forState:UIControlStateNormal];
  134. [self.gotoBackBtn addTarget:self action:@selector(actionQuit) forControlEvents:UIControlEventTouchUpInside];
  135. [self.gotoBackBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  136. self.gotoBackBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
  137. [self.tableHeader addSubview:self.gotoBackBtn];
  138. }
  139. if (!self.isDetail && [self.user.userId isEqualToString:MY_USER_ID]) {
  140. UIButton* btn = [UIFactory createButtonWithImage:@"im_003_more_button_black"
  141. highlight:nil
  142. target:self
  143. selector:@selector(onAddMsg:)];
  144. btn.frame = CGRectMake(JX_SCREEN_WIDTH - 18-15*2, JX_SCREEN_TOP - 18-15*2, 18+15*2, 18+15*2);
  145. [self.tableHeader addSubview:btn];
  146. }
  147. }
  148. -(instancetype)initCollection{
  149. if (self = [super init]) {
  150. self.isCollection = YES;
  151. self.title = Localized(@"JX_MyCollection");
  152. self.isGotoBack = YES;
  153. self.heightHeader = JX_SCREEN_TOP;
  154. self.heightFooter = 0;
  155. self.datas = [NSMutableArray array];
  156. self.user = g_myself;
  157. [self createHeadAndFoot];
  158. [self createTableHeadShowRemind];
  159. self.footer.hidden = YES;
  160. [self getWeiboBackImage];
  161. }
  162. return self;
  163. }
  164. -(void)dealloc{
  165. [_pool removeAllObjects];
  166. [g_notify removeObserver:self name:kUpdateUserNotifaction object:nil];
  167. [g_notify removeObserver:self name:kCellTouchUrlNotifaction object:nil];
  168. [g_notify removeObserver:self name:kXMPPMessageWeiboRemind object:nil];
  169. [g_notify removeObserver:self name:kApplicationDidEnterBackground object:nil];
  170. // NSLog(@"WeiboViewControlle.dealloc");
  171. // [super dealloc];
  172. }
  173. - (void)getWeiboBackImage {
  174. [g_server getUser:user.userId toView:self];
  175. }
  176. - (void)viewDidAppear:(BOOL)animated
  177. {
  178. [super viewDidAppear:animated];
  179. [g_notify addObserver:self selector:@selector(changeKeyBoard:) name:UIKeyboardWillShowNotification object:nil];
  180. }
  181. - (void)viewDidDisappear:(BOOL)animated{
  182. [super viewDidDisappear:animated];
  183. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  184. [g_notify removeObserver:self name:UIKeyboardWillShowNotification object:nil];
  185. [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];
  186. [[HBHttpRequestCache shareCache] clearMemoryCache];
  187. }
  188. - (void)actionQuit {
  189. [self didEnterBackground:nil];
  190. [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];
  191. [super actionQuit];
  192. }
  193. - (void) remindNotif:(NSNotification *)notif {
  194. JXMessageObject *msg = notif.object;
  195. self.remindMsg = msg;
  196. _remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
  197. if (!self.isNotShowRemind) {
  198. [self createTableHeadShowRemind];
  199. }else {
  200. [self showTopImage];
  201. }
  202. [self getServerData];
  203. }
  204. // 进入后台
  205. - (void)didEnterBackground:(NSNotification *)notif {
  206. // 暂停语音播放
  207. for (NSInteger i = 0; i < _datas.count; i ++) {
  208. WeiboCell *cell = [_table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
  209. if (cell) {
  210. if (cell.audioPlayer != nil) {
  211. [cell.audioPlayer stop];
  212. }
  213. }
  214. }
  215. }
  216. -(void)getServerData{
  217. // [_wait start];
  218. if (self.isCollection) {
  219. [g_server userCollectionListWithType:0 pageIndex:0 toView:self];
  220. }else if (self.isDetail) {
  221. [g_server getMessage:self.detailMsgId toView:self];
  222. }else{
  223. [g_App.jxServer listMessage:0 messageId:[self getLastMessageId:_datas] toView:self];
  224. }
  225. }
  226. -(void)scrollToPageUp{
  227. // [self doHideKeyboard];
  228. [_wait start];
  229. [super scrollToPageUp];
  230. }
  231. #pragma mark ------------------数据成功返回----------------------
  232. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  233. [_wait stop];
  234. // [super stopLoading];
  235. if([aDownload.action isEqualToString:act_UploadFile]){
  236. JXUserObject *user = [[JXUserObject alloc] init];
  237. user.msgBackGroundUrl = [(NSDictionary *)[dict[@"images"] firstObject] objectForKey:@"oUrl"];
  238. [g_server updateUser:user toView:self];
  239. }
  240. if ([aDownload.action isEqualToString:act_UserUpdate]) {
  241. NSString *urlStr = [NSString stringWithFormat:@"%@",dict[@"msgBackGroundUrl"]];
  242. if (IsStringNull(urlStr)) {
  243. [g_server getHeadImageLarge:user.userId userName:user.userNickname imageView:_topBackImageView];
  244. }else {
  245. [g_server getImage:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] imageView:_topBackImageView];
  246. }
  247. }
  248. //添加新回复
  249. if([aDownload.action isEqualToString:act_CommentAdd]){
  250. [replyDataTemp setMatch];
  251. for (NSInteger i = 0; i < _datas.count; i ++) {
  252. WeiboData *data = _datas[i];
  253. if ([data.messageId isEqualToString:selectWeiboData.messageId]) {
  254. selectWeiboData = data;
  255. self.selectWeiboCell = [_table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
  256. break;
  257. }
  258. }
  259. if (selectWeiboData.replys.count >= 20) {
  260. selectWeiboData.replys = [NSMutableArray arrayWithArray:[selectWeiboData.replys subarrayWithRange:NSMakeRange(0, 19)]];
  261. }
  262. // 数据结构问题,需服务器改
  263. replyDataTemp.replyId = [dict objectForKey:@"resultObject"];
  264. [selectWeiboData.replys insertObject:replyDataTemp atIndex:0];
  265. selectWeiboData.page = 0;
  266. selectWeiboData.commentCount += 1;
  267. selectWeiboData.replyHeight=[selectWeiboData heightForReply];
  268. if ([selectWeiboData.replys count] != 0) {
  269. [self.selectWeiboCell refresh];
  270. }
  271. replyDataTemp = [[WeiboReplyData alloc]init];
  272. }
  273. if ([aDownload.action isEqualToString:act_CommentDel]){
  274. [replyDataTemp setMatch];
  275. [selectWeiboData.replys removeObjectAtIndex:self.deleteReply];
  276. selectWeiboData.page = 0;
  277. selectWeiboData.commentCount -= 1;
  278. selectWeiboData.replyHeight=[selectWeiboData heightForReply];
  279. [self.selectWeiboCell refresh];
  280. replyDataTemp = [[WeiboReplyData alloc]init];
  281. }
  282. if([aDownload.action isEqualToString:act_PraiseAdd]){
  283. [self doAddPraiseOK];
  284. }
  285. if([aDownload.action isEqualToString:act_PraiseDel]){
  286. [self doDelPraiseOK];
  287. }
  288. if([aDownload.action isEqualToString:act_GiftAdd]){
  289. }
  290. if([aDownload.action isEqualToString:act_userEmojiAdd]){
  291. WeiboData *data = _datas[self.lastCell.tag];
  292. data.isCollect = YES;
  293. [_datas replaceObjectAtIndex:self.lastCell.tag withObject:data];
  294. [_table reloadRow:(int)self.lastCell.tag section:0];
  295. [g_server showMsg:Localized(@"JX_CollectionSuccess") delay:1.3f];
  296. }
  297. if([aDownload.action isEqualToString:act_CommentList]){
  298. for(int i=0;i<[array1 count];i++){
  299. WeiboReplyData * reply=[[WeiboReplyData alloc]init];
  300. NSDictionary* dict = [array1 objectAtIndex:i];
  301. reply.type=1;
  302. reply.addHeight = 60;
  303. [reply getDataFromDict:dict];
  304. [reply setMatch];
  305. [self.selectWeiboData.replys addObject:reply];
  306. }
  307. [self.selectWeiboCell refresh];
  308. }
  309. if([aDownload.action isEqualToString:act_MsgDel]){
  310. [_datas removeObject:selectWeiboData];
  311. refreshCount++;
  312. [_table reloadData];
  313. }
  314. if([aDownload.action isEqualToString:act_MsgList] || [aDownload.action isEqualToString:act_MsgListUser] || [aDownload.action isEqualToString:act_MsgGet]){
  315. self.isShowFooterPull = [array1 count] >= jx_page_size;
  316. if(_page==0)
  317. [_datas removeAllObjects];
  318. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  319. //数据莫名为空
  320. if(_datas != nil){
  321. NSMutableArray * tempData = [[NSMutableArray alloc] init];
  322. NSInteger displayNum = 12;
  323. if (array1.count > displayNum) {
  324. for (int i=0; i< displayNum; i++) {
  325. NSDictionary* row = [array1 objectAtIndex:i];
  326. WeiboData * weibo=[[WeiboData alloc]init];
  327. [weibo getDataFromDict:row];
  328. [tempData addObject:weibo];
  329. }
  330. if (tempData.count > 0){
  331. [_datas addObjectsFromArray:tempData];
  332. [self loadWeboData:_datas complete:nil formDb:NO];
  333. }else {
  334. if (dict) {
  335. WeiboData *data = [[WeiboData alloc] init];
  336. [data getDataFromDict:dict];
  337. [tempData addObject:data];
  338. [_datas addObjectsFromArray:tempData];
  339. [self loadWeboData:_datas complete:nil formDb:NO];
  340. }
  341. }
  342. [_table reloadData];
  343. [tempData removeAllObjects];
  344. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  345. for (NSInteger i=displayNum; i<[array1 count]; i++) {
  346. NSDictionary* row = [array1 objectAtIndex:i];
  347. WeiboData * weibo=[[WeiboData alloc]init];
  348. [weibo getDataFromDict:row];
  349. [tempData addObject:weibo];
  350. }
  351. if (tempData.count > 0){
  352. [_datas addObjectsFromArray:tempData];
  353. [self loadWeboData:_datas complete:nil formDb:NO];
  354. }else {
  355. if (dict) {
  356. WeiboData *data = [[WeiboData alloc] init];
  357. [data getDataFromDict:dict];
  358. [tempData addObject:data];
  359. [_datas addObjectsFromArray:tempData];
  360. [self loadWeboData:_datas complete:nil formDb:NO];
  361. }
  362. }
  363. });
  364. }else{
  365. for (NSInteger i=0; i<[array1 count]; i++) {
  366. NSDictionary* row = [array1 objectAtIndex:i];
  367. WeiboData * weibo=[[WeiboData alloc]init];
  368. [weibo getDataFromDict:row];
  369. [tempData addObject:weibo];
  370. }
  371. if (tempData.count > 0){
  372. [_datas addObjectsFromArray:tempData];
  373. [self loadWeboData:_datas complete:nil formDb:NO];
  374. }else {
  375. if (dict) {
  376. WeiboData *data = [[WeiboData alloc] init];
  377. [data getDataFromDict:dict];
  378. [tempData addObject:data];
  379. [_datas addObjectsFromArray:tempData];
  380. [self loadWeboData:_datas complete:nil formDb:NO];
  381. }
  382. }
  383. [_table reloadData];
  384. }
  385. }
  386. // for (int i=0; i<[array1 count]; i++) {
  387. // NSDictionary* row = [array1 objectAtIndex:i];
  388. // WeiboData * weibo=[[WeiboData alloc]init];
  389. // [weibo getDataFromDict:row];
  390. // [tempData addObject:weibo];
  391. // }
  392. // if (tempData.count > 0){
  393. // [_datas addObjectsFromArray:tempData];
  394. // [self loadWeboData:_datas complete:nil formDb:NO];
  395. // }else {
  396. // if (dict) {
  397. // WeiboData *data = [[WeiboData alloc] init];
  398. // [data getDataFromDict:dict];
  399. // [tempData addObject:data];
  400. // [_datas addObjectsFromArray:tempData];
  401. // [self loadWeboData:_datas complete:nil formDb:NO];
  402. // }
  403. // }
  404. // }
  405. // [_table reloadData];
  406. }
  407. if ([aDownload.action isEqualToString:act_userCollectionList]) {
  408. if (_page ==0) {
  409. [_datas removeAllObjects];
  410. }
  411. NSMutableArray * tempData = [[NSMutableArray alloc] init];
  412. for (int i=0; i<[array1 count]; i++) {
  413. NSDictionary* row = [array1 objectAtIndex:i];
  414. NSString * msgStr = row[@"msg"];
  415. // NSDictionary * msgDict = [[[SBJsonParser alloc]init]objectWithString:msgStr];
  416. //
  417. // JXMessageObject *msg=[[JXMessageObject alloc] init];
  418. //// [msg fromDictionary:bodyDict];
  419. // [msg fromXmlDict:msgDict];
  420. int collectType = [row[@"type"] intValue];
  421. NSTimeInterval createTime = [row[@"createTime"] doubleValue];
  422. NSString * emojiId = row[@"emojiId"];
  423. NSString *url = row[@"url"];
  424. NSString *fileLength = row[@"fileLength"];
  425. NSString *fileName = row[@"fileName"];
  426. NSString *fileSize = row[@"fileSize"];
  427. NSString *collectContent = row[@"collectContent"];
  428. WeiboData * weibo=[[WeiboData alloc]init];
  429. weibo.createTime = createTime;
  430. weibo.objectId = emojiId;
  431. if (collectContent.length > 0) {
  432. weibo.content = collectContent;
  433. }
  434. // [weibo getDataFromDict:row];
  435. [self weiboData:weibo WithUrl:url msg:msgStr collectType:collectType fileLength:fileLength fileName:fileName fileSize:fileSize];
  436. [tempData addObject:weibo];
  437. }
  438. if (tempData.count > 0){
  439. [_datas addObjectsFromArray:tempData];
  440. [self loadWeboData:_datas complete:nil formDb:NO];
  441. }
  442. [_table reloadData];
  443. }
  444. if ([aDownload.action isEqualToString:act_WeiboDeleteCollect]) {
  445. [g_server showMsg:Localized(@"JX_weiboCancelCollect") delay:1.3f];
  446. WeiboData *data = _datas[self.lastCell.tag];
  447. data.isCollect = NO;
  448. [_datas replaceObjectAtIndex:self.lastCell.tag withObject:data];
  449. [_table reloadRow:(int)self.lastCell.tag section:0];
  450. }
  451. if ([aDownload.action isEqualToString:act_userEmojiDelete]) {
  452. [g_server showMsg:Localized(@"JXAlert_DeleteOK") delay:1.3f];
  453. NSIndexPath * indexPath = [_table indexPathForCell:selectWeiboCell];
  454. [_datas removeObject:selectWeiboData];
  455. // [_table deleteRow:(int)indexPath.row section:(int)indexPath.section];
  456. [_table reloadData];
  457. }
  458. if([aDownload.action isEqualToString:act_PhotoList]){
  459. if([array1 count]>0){
  460. [photosViewController showPhotos:array1];
  461. }else{
  462. }
  463. }
  464. if( [aDownload.action isEqualToString:act_UserGet] ){
  465. JXUserObject* p = [[JXUserObject alloc]init];
  466. [p getDataFromDict:dict];
  467. if (!self.isFirstGoin) {
  468. self.isFirstGoin = YES;
  469. _topImageUrl = p.msgBackGroundUrl;
  470. [self showTopImage];
  471. return;
  472. }
  473. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  474. vc.user = p;
  475. vc.fromAddType = 6;
  476. vc = [vc init];
  477. // [g_window addSubview:vc.view];
  478. [g_navigation pushViewController:vc animated:YES];
  479. [_pool addObject:vc];
  480. // [p release];
  481. }
  482. if([aDownload.action isEqualToString:act_Report]){
  483. [_wait stop];
  484. [g_App showAlert:Localized(@"JXUserInfoVC_ReportSuccess")];
  485. }
  486. }
  487. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  488. [_wait hide];
  489. // [super stopLoading];
  490. return show_error;
  491. }
  492. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  493. [_wait hide];
  494. // [super stopLoading];
  495. return show_error;
  496. }
  497. -(void) didServerConnectStart:(JXConnection*)aDownload{
  498. // [_wait start];
  499. }
  500. -(void)weiboData:(WeiboData *)weiboData WithUrl:(NSString *)dataUrl msg:(NSString *)msg collectType:(int)collectType fileLength:(NSString *)fileLength fileName:(NSString *)fileName fileSize:(NSString *)fileSize{
  501. // weiboData.messageId = msg.messageId;
  502. weiboData.userId = MY_USER_ID;
  503. weiboData.userNickName = MY_USER_NAME;
  504. // weiboData.createTime = [[dict objectForKey:@"time"] longLongValue];
  505. // weiboData.deviceModel = [dict objectForKey:@"model"];
  506. // weiboData.location = [dict objectForKey:@"location"];
  507. // weiboData.flag = [[dict objectForKey:@"flag"] intValue];
  508. // weiboData.visible = [[dict objectForKey:@"visible"] intValue];
  509. // weiboData.isPraise = [[dict objectForKey:@"isPraise"] boolValue];
  510. // weiboData.isLoved = [[dict objectForKey:@"isLoved"] boolValue];
  511. // weiboData.loveCount = [[[dict objectForKey:@"count"] objectForKey:@"collect"] intValue];
  512. // weiboData.shareCount = [[[dict objectForKey:@"count"] objectForKey:@"share"] intValue];
  513. // weiboData.playCount = [[[dict objectForKey:@"count"] objectForKey:@"play"] intValue];
  514. // weiboData.forwardCount = [[[dict objectForKey:@"count"] objectForKey:@"forward"] intValue];
  515. // weiboData.praiseCount = [[[dict objectForKey:@"count"] objectForKey:@"praise"] intValue];
  516. // weiboData.commentCount = [[[dict objectForKey:@"count"] objectForKey:@"comment"] intValue];
  517. // weiboData.giftCount = [[[dict objectForKey:@"count"] objectForKey:@"money"] intValue];
  518. // weiboData.giftTotalPrice = [[[dict objectForKey:@"count"] objectForKey:@"total"] intValue];
  519. // weiboData.title = @"titletitle";
  520. // weiboData.type = [[[dict objectForKey:@"body"] objectForKey:@"type"] intValue];
  521. // self.audios = [[dict objectForKey:@"body"] objectForKey:@"audios"];
  522. // self.videos = [[dict objectForKey:@"body"] objectForKey:@"videos"];
  523. // weiboData.time = [[dict objectForKey:@"body"] objectForKey:@"time"];
  524. // weiboData.address = [[dict objectForKey:@"body"] objectForKey:@"address"];
  525. // weiboData.remark = [[dict objectForKey:@"body"] objectForKey:@"remark"];
  526. // NSDictionary* row = nil;
  527. // CollectTypeEmoji = 6,//表情
  528. // CollectTypeImage = 1,//图片
  529. // CollectTypeVideo = 2,//视频
  530. // CollectTypeFile = 3,//文件
  531. // CollectTypeVoice = 4,//语音
  532. // CollectTypeText = 5,//文本
  533. if (collectType == 1) {//图片
  534. weiboData.type = weibo_dataType_image;
  535. // weiboData.images = [NSMutableArray arrayWithObject:msg.content];
  536. NSArray *urlArr = [dataUrl componentsSeparatedByString:@","];
  537. for (int i = 0; i < urlArr.count; i++) {
  538. ObjUrlData * url=[[ObjUrlData alloc] init];
  539. url.url= urlArr[i];
  540. url.mime=@"image/pic";
  541. [weiboData.smalls addObject:url];
  542. [weiboData.larges addObject:url];
  543. [weiboData.images addObject:url];
  544. }
  545. }else if (collectType == 2) {//视频
  546. weiboData.type = weibo_dataType_video;
  547. ObjUrlData * url=[[ObjUrlData alloc] init];
  548. url.url= dataUrl;
  549. url.fileSize = fileSize;
  550. url.timeLen = @([fileLength intValue]);
  551. [weiboData.videos addObject:url];
  552. }else if (collectType == 3) {//文件
  553. weiboData.type = weibo_dataType_file;
  554. ObjUrlData * url=[[ObjUrlData alloc] init];
  555. url.url= msg;
  556. url.fileSize = fileSize;
  557. url.type = @"4";
  558. if (fileName.length > 0) {
  559. url.name = [fileName lastPathComponent];
  560. }else {
  561. url.name = [msg lastPathComponent];
  562. }
  563. [weiboData.files addObject:url];
  564. }else if (collectType == 4) {//语音
  565. weiboData.type = weibo_dataType_audio;
  566. ObjUrlData * url=[[ObjUrlData alloc] init];
  567. url.url= dataUrl;
  568. url.fileSize =fileSize;
  569. url.timeLen = @([fileLength intValue]);
  570. [weiboData.audios addObject:url];
  571. }else if (collectType == 5) {//文本
  572. weiboData.type = weibo_dataType_text;
  573. weiboData.content= msg;
  574. }else if (collectType == 6) {//表情
  575. }
  576. // NSArray* p = nil;
  577. // weiboData.images = [[dict objectForKey:@"body"] objectForKey:@"images"];
  578. //
  579. // for(int i=0;i<[p count];i++){
  580. // row = [p objectAtIndex:i];
  581. //
  582. // ObjUrlData * url=[[ObjUrlData alloc] init];
  583. // url.url= [row objectForKey:@"tUrl"];
  584. // url.mime=@"image/pic";
  585. // [smalls addObject:url];
  586. //
  587. // url =[[ObjUrlData alloc]init];
  588. // url.url= [row objectForKey:@"oUrl"];
  589. // url.mime=@"image/pic";
  590. // [larges addObject:url];
  591. // }
  592. // p = [[dict objectForKey:@"body"] objectForKey:@"audios"];
  593. // for(int i=0;i<[p count];i++){
  594. // row = [p objectAtIndex:i];
  595. //
  596. // ObjUrlData * url=[[ObjUrlData alloc] init];
  597. // url.url= [row objectForKey:@"oUrl"];
  598. // url.fileSize = [row objectForKey:@"size"];
  599. // url.timeLen = [row objectForKey:@"length"];
  600. // [audios addObject:url];
  601. // }
  602. // p = [[dict objectForKey:@"body"] objectForKey:@"videos"];
  603. // for(int i=0;i<[p count];i++){
  604. // row = [p objectAtIndex:i];
  605. //
  606. // ObjUrlData * url=[[ObjUrlData alloc] init];
  607. // url.url= [row objectForKey:@"oUrl"];
  608. // url.fileSize = [row objectForKey:@"size"];
  609. // url.timeLen = [row objectForKey:@"length"];
  610. // [videos addObject:url];
  611. // }
  612. if( ([weiboData.audios count]>0 || [weiboData.videos count]>0) && [weiboData.images count]<=0){//假如没图,则用头像代替
  613. ObjUrlData * url=[[ObjUrlData alloc]init];
  614. // url.url= @"http://www.feizl.com/upload2007/2013_02/130227014423722.jpg";
  615. url.url= [g_server getHeadImageOUrl:MY_USER_ID];
  616. url.mime=@"image/pic";
  617. [weiboData.smalls addObject:url];
  618. }
  619. // p = [dict objectForKey:@"praises"];
  620. // for(int i=0;i<[p count];i++){
  621. // WeiboReplyData * reply=[[WeiboReplyData alloc]init];
  622. // reply.type=reply_data_praise;
  623. // // reply.addHeight = self.minHeightForComment;
  624. // reply.messageId=self.messageId;
  625. // row = [p objectAtIndex:i];
  626. // [reply getDataFromDict:row];
  627. // [praises addObject:reply];
  628. // }
  629. // p = [dict objectForKey:@"gifts"];
  630. // for(int i=0;i<[p count];i++){
  631. // WeiboReplyData * reply=[[WeiboReplyData alloc]init];
  632. // reply.type=reply_data_gift;
  633. // // reply.addHeight = self.minHeightForComment;
  634. // reply.messageId=self.messageId;
  635. // row = [p objectAtIndex:i];
  636. // [reply getDataFromDict:row];
  637. // [gifts addObject:reply];
  638. // }
  639. // p = [dict objectForKey:@"comments"];
  640. // for(NSInteger i = p.count - 1; i >= 0; i--){
  641. // WeiboReplyData * reply=[[WeiboReplyData alloc]init];
  642. // reply.type=reply_data_comment;
  643. // reply.addHeight = self.minHeightForComment;
  644. // reply.messageId=self.messageId;
  645. // row = [p objectAtIndex:i];
  646. // [reply getDataFromDict:row];
  647. // [replys addObject:reply];
  648. // }
  649. }
  650. -(void)viewWillAppear:(BOOL)animated
  651. {
  652. [super viewWillAppear:animated];
  653. if (!self.isDetail && !self.isCollection) {
  654. //使大头像显示不全,让下方不被tabbar遮挡
  655. _table.contentInset = UIEdgeInsetsMake(-TopImageInset + (THE_DEVICE_HAVE_HEAD ? -44 : -20), 0, 49, 0);
  656. }
  657. // _table.contentOffset = CGPointMake(0,JX_SCREEN_WIDTH/16.0*8.0);
  658. [UIApplication sharedApplication].statusBarHidden = NO;
  659. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  660. if (self.isCollection || self.isDetail) {
  661. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  662. }
  663. }
  664. - (void)viewDidLoad
  665. {
  666. [super viewDidLoad];
  667. [self scrollToPageUp];
  668. //监听键盘状态
  669. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardWillHideNotification object:nil];
  670. }
  671. - (void)keyboardDidHide:(NSNotification *)notification
  672. {
  673. [self doHideKeyboard];
  674. }
  675. //- (void)textFieldDidEndEditing:(UITextField *)textField{
  676. // [self doHideKeyboard];
  677. //}
  678. - (void)didReceiveMemoryWarning
  679. {
  680. [super didReceiveMemoryWarning];
  681. // Dispose of any resources that can be recreated.
  682. }
  683. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  684. {
  685. //#warning Potentially incomplete method implementation.
  686. // Return the number of sections.
  687. return 1;
  688. }
  689. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  690. {
  691. //#warning Incomplete method implementation.
  692. // Return the number of rows in the section.
  693. return [_datas count];
  694. }
  695. #pragma mark - Table view --------代理-------- data source
  696. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  697. {
  698. // NSString *CellIdentifier = [NSString stringWithFormat:@"WeiboCell_%d_%ld",refreshCount,indexPath.row];
  699. NSString *CellIdentifier = nil;
  700. if (self.isCollection)
  701. CellIdentifier = [NSString stringWithFormat:@"collectionCell"];
  702. else
  703. CellIdentifier = [NSString stringWithFormat:@"WeiboCell"];
  704. WeiboCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  705. if(cell==nil){
  706. cell = [WeiboCell alloc];
  707. cell = [cell initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  708. }
  709. if (self.isSend) {
  710. cell.contentView.userInteractionEnabled = NO;
  711. }else {
  712. cell.contentView.userInteractionEnabled = YES;
  713. }
  714. WeiboData * weibo;
  715. if ([_datas count] > indexPath.row) {
  716. weibo=[_datas objectAtIndex:indexPath.row];
  717. }
  718. cell.delegate = self;
  719. cell.controller=self;
  720. cell.tableViewP = tableView;
  721. cell.tag = indexPath.row;
  722. cell.isPraise = weibo.isPraise;
  723. cell.isCollect = weibo.isCollect;
  724. cell.weibo = weibo;
  725. [cell setupData];
  726. float height=[self tableView:tableView heightForRowAtIndexPath:indexPath];
  727. UIView * view=[cell.contentView viewWithTag:1200];
  728. if(view==nil){
  729. UIView* line = [[UIView alloc]init];
  730. line.backgroundColor = THE_LINE_COLOR;
  731. line.frame=CGRectMake(0, height-LINE_WH, JX_SCREEN_WIDTH, LINE_WH);
  732. [cell.contentView addSubview:line];
  733. line.tag=1200;
  734. }else{
  735. view.frame=CGRectMake(0, height-LINE_WH, JX_SCREEN_WIDTH, LINE_WH);
  736. }
  737. if (self.isCollection) {
  738. cell.btnReply.hidden = YES;
  739. cell.btnLike.hidden = YES;
  740. cell.btnReport.hidden = YES;
  741. cell.btnCollection.hidden = YES;
  742. }
  743. if (self.isCollection || [weibo.userId isEqualToString:MY_USER_ID]) {
  744. cell.delBtn.hidden = NO;
  745. }else {
  746. cell.delBtn.hidden = YES;
  747. }
  748. if (self.isSend) {
  749. cell.delBtn.hidden = YES;
  750. }
  751. [self doAutoScroll:indexPath];
  752. return cell;
  753. }
  754. - (void)videoStartPlayer {
  755. [_videoPlayer switch];
  756. }
  757. - (void)weiboCell:(WeiboCell *)weiboCell clickVideoWithIndex:(NSInteger)index {
  758. self.videoIndex = index;
  759. _videoPlayer = [JXVideoPlayer alloc];
  760. _videoPlayer.videoFile = [[_datas objectAtIndex:index] getMediaURL];
  761. _videoPlayer.type = JXVideoTypeWeibo;
  762. _videoPlayer.didVideoPlayEnd = @selector(didVideoPlayEnd);
  763. _videoPlayer.isShowHide = YES;
  764. _videoPlayer.delegate = self;
  765. _videoPlayer = [_videoPlayer initWithParent:self.view];
  766. [self performSelector:@selector(videoStartPlayer) withObject:self afterDelay:0.2];
  767. }
  768. - (void)weiboCell:(WeiboCell *)weiboCell shareUrlActionWithUrl:(NSString *)url title:(NSString *)title {
  769. webpageVC *webVC = [webpageVC alloc];
  770. webVC.isGotoBack= YES;
  771. webVC.isSend = YES;
  772. webVC.title = title;
  773. webVC.url = url;
  774. webVC = [webVC init];
  775. [g_navigation.navigationView addSubview:webVC.view];
  776. // [g_navigation pushViewController:webVC animated:YES];
  777. }
  778. #pragma mark - Table view delegate
  779. -(void)doHideMenu{
  780. [self resignFirstResponder];
  781. UIMenuController *menuController = [UIMenuController sharedMenuController];
  782. [menuController setMenuVisible:NO];
  783. }
  784. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  785. {
  786. if (self.menuView) {
  787. [self.menuView dismissBaseView];
  788. self.lastCell = nil;
  789. }
  790. [self doHideMenu];
  791. [self doHideKeyboard];
  792. if (self.isCollection) {
  793. if ([self.delegate respondsToSelector:@selector(weiboVC:didSelectWithData:)]) {
  794. WeiboData *data = _datas[indexPath.row];
  795. _currentData = data;
  796. [g_App showAlert:Localized(@"JXWantSendCollectionMessage") delegate:self tag:2457 onlyConfirm:NO];
  797. }
  798. }
  799. return;
  800. }
  801. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  802. {
  803. //依据数据的多少修改cell的高度
  804. if ([_datas count] != 0 && [_datas count] > indexPath.row) {
  805. WeiboData * data=[_datas objectAtIndex:indexPath.row];
  806. // 评论点击打开更多时,replyHeight还是记录的之前的,这里更新下高度
  807. data.replyHeight = [data heightForReply];
  808. float n = [WeiboCell getHeightByContent:data];
  809. if (self.isCollection) {
  810. n -= 20;
  811. if (data.type == weibo_dataType_text) {
  812. n -= 10;
  813. }
  814. }
  815. return n+20;
  816. }
  817. return 0;
  818. }
  819. #pragma -mark 回调方法
  820. - (void)urlTouch:(NSNotification *)notification{
  821. self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_OpenUrl")]];
  822. self.actionVC.delegate = self;
  823. self.actionVC.tag = 105;
  824. NSMutableString *str = notification.object;
  825. if ([str rangeOfString:@"http"].location == NSNotFound) {
  826. self.urlStr = [NSString stringWithFormat:@"http://%@",str];
  827. }else {
  828. self.urlStr = [str copy];
  829. }
  830. [g_App.window addSubview:self.actionVC.view];
  831. }
  832. - (void)phoneTouch:(NSNotification *)notification{
  833. self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_CallPhone")]];
  834. self.actionVC.delegate = self;
  835. self.actionVC.tag = 102;
  836. phoneNumber=notification.object;
  837. [g_App.window addSubview:self.actionVC.view];
  838. }
  839. - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index {
  840. if (actionSheet.tag==105){
  841. if(0==index){
  842. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  843. webpageVC *webVC = [webpageVC alloc];
  844. webVC.isGotoBack= YES;
  845. webVC.isSend = YES;
  846. webVC.title = Localized(@"JXEmoji_OpenUrl");
  847. webVC.url = self.urlStr;
  848. webVC = [webVC init];
  849. [g_navigation.navigationView addSubview:webVC.view];
  850. // [g_navigation pushViewController:webVC animated:YES];
  851. });
  852. }
  853. }else if (actionSheet.tag==102){
  854. if(0==index){
  855. NSString * string=[NSString stringWithFormat:@"tel:%@",phoneNumber];
  856. if(webView==nil)
  857. webView=[[UIWebView alloc]initWithFrame:self.view.bounds];
  858. [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
  859. webView.hidden=YES;
  860. [self.view addSubview:webView];
  861. }
  862. }else if (actionSheet.tag == 111){
  863. if (index == 0) {
  864. UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
  865. ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  866. ipc.delegate = self;
  867. ipc.allowsEditing = YES;
  868. //选择图片模式
  869. ipc.modalPresentationStyle = UIModalPresentationCurrentContext;
  870. if (IS_PAD) {
  871. UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:ipc];
  872. [pop presentPopoverFromRect:CGRectMake((self.view.frame.size.width - 320) / 2, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  873. }else {
  874. [self presentViewController:ipc animated:YES completion:nil];
  875. }
  876. }else {
  877. JXCameraVC *vc = [JXCameraVC alloc];
  878. vc.cameraDelegate = self;
  879. vc.isPhoto = YES;
  880. vc = [vc init];
  881. [self presentViewController:vc animated:YES completion:nil];
  882. }
  883. }
  884. }
  885. -(void)coreLabel:(HBCoreLabel*)coreLabel linkClick:(NSString*)linkStr
  886. {
  887. }
  888. -(void)coreLabel:(HBCoreLabel *)coreLabel phoneClick:(NSString *)linkStr
  889. {
  890. self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_CallPhone")]];
  891. self.actionVC.delegate = self;
  892. self.actionVC.tag = 102;
  893. phoneNumber=linkStr;
  894. [g_App.window addSubview:self.actionVC.view];
  895. }
  896. -(void)coreLabel:(HBCoreLabel *)coreLabel mobieClick:(NSString *)linkStr
  897. {
  898. self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_CallPhone"),Localized(@"JX_SendMessage")]];
  899. self.actionVC.delegate = self;
  900. self.actionVC.tag = 103;
  901. phoneNumber=linkStr;
  902. [g_App.window addSubview:self.actionVC.view];
  903. }
  904. //-(void)footViewBeginLoad:(PageLoadFootView*)footView
  905. //{
  906. // // [self loadFromDb:NO];
  907. //}
  908. -(void)loadWeboData:(NSArray*)webos complete:(void(^)())complete formDb:(BOOL)fromDb
  909. {
  910. //用i循环遍历
  911. for(int i = 0 ; i < [webos count];i++){
  912. WeiboData * weibo = [webos objectAtIndex:i];
  913. weibo.match=nil;
  914. [weibo setMatch];
  915. weibo.uploadFailed=NO;
  916. weibo.linesLimit=YES;
  917. weibo.replyHeight=[weibo heightForReply];
  918. if (weibo.type == weibo_dataType_video) {
  919. ObjUrlData * obj =[weibo.smalls firstObject];
  920. UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:obj.url]]];
  921. if (img.size.height > img.size.width) {
  922. weibo.videoHeight = 200;
  923. }else {
  924. weibo.videoHeight = 150;
  925. }
  926. }else {
  927. weibo.imageHeight=[HBShowImageControl heightForFileStr:weibo.smalls];
  928. if (weibo.type == weibo_dataType_audio) {
  929. weibo.imageHeight = 30;
  930. }
  931. }
  932. if(weibo.type == weibo_dataType_file) weibo.fileHeight = 100;
  933. if (weibo.type == weibo_dataType_share) {
  934. weibo.shareHeight = 70;
  935. }
  936. }
  937. //需要在遍历时改变内容,所以弃用
  938. // for(WeiboData * weibo in webos){
  939. // weibo.match=nil;
  940. // [weibo setMatch];
  941. // weibo.uploadFailed=NO;
  942. // weibo.linesLimit=YES;
  943. // weibo.imageHeight=[HBShowImageControl heightForFileStr:weibo.smalls];
  944. // weibo.replyHeight=[weibo heightForReply];
  945. // }
  946. dispatch_async(dispatch_get_main_queue(), ^{
  947. refreshCount++;
  948. [self.tableView reloadData];
  949. if(complete){
  950. complete();
  951. }
  952. });
  953. }
  954. - (void)loadWeboData:(NSArray *) webos {
  955. [self loadWeboData:webos complete:nil formDb:NO];
  956. }
  957. #pragma mark ---------------发说说------------
  958. - (void)onAddMsg:(UIButton *)btn{
  959. if (self.menuView) {
  960. [self.menuView dismissBaseView];
  961. self.menuView = nil;
  962. }
  963. // //标题数组
  964. // NSMutableArray * titleArr = [[NSMutableArray alloc]initWithArray:@[Localized(@"JX_SendWord"),Localized(@"JX_SendImage"),Localized(@"JX_SendVoice"),Localized(@"JX_SendVideo"),Localized(@"JX_NewCommentAndPraise")]];
  965. JX_SelectMenuView *menuView = [[JX_SelectMenuView alloc] initWithTitle:@[
  966. // Localized(@"JX_SendWord"),
  967. Localized(@"JX_SendImage"),
  968. Localized(@"JX_SendVoice"),
  969. Localized(@"JX_SendVideo"),
  970. Localized(@"JX_SendFile"),
  971. Localized(@"JX_NewCommentAndPraise")]
  972. image:@[@"menu_add_msg",@"menu_add_voice",@"menu_add_video",@"menu_add_file",@"menu_add_reply"]
  973. cellHeight:45];
  974. menuView.delegate = self;
  975. [g_App.window addSubview:menuView];
  976. // UIWindow *window = [[UIApplication sharedApplication].delegate window];
  977. // CGRect moreFrame = [self.tableHeader convertRect:btn.frame toView:window];
  978. //
  979. // JX_DownListView * downListView = [[JX_DownListView alloc] initWithFrame:self.view.bounds];
  980. // downListView.listContents = titleArr;
  981. //
  982. // __weak typeof(self) weakSelf = self;
  983. // [downListView downlistPopOption:^(NSInteger index, NSString *content) {
  984. //
  985. // [weakSelf moreListActionWithIndex:index];
  986. //
  987. // } whichFrame:moreFrame animate:YES];
  988. // [downListView show];
  989. //
  990. //模糊背景
  991. // _bgBlackAlpha = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT)];
  992. // _bgBlackAlpha.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
  993. // [self.view addSubview:_bgBlackAlpha];
  994. //
  995. // //自定义View
  996. // _selectView = [JX_SelectMenuView creatViewWithCount:[titleArr count] title:titleArr point:CGPointMake(JX_SCREEN_WIDTH - JX_SCREEN_WIDTH/2 - 5, JX_SCREEN_TOP - 5) topHeight:TopHeight cellHeight:CellHeight];
  997. // _selectView.alpha = 0.0;
  998. // [_bgBlackAlpha addSubview:_selectView];
  999. // //动画
  1000. // [UIView animateWithDuration:0.3 animations:^{
  1001. // _selectView.alpha = 1;
  1002. // }];
  1003. }
  1004. - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
  1005. switch (index) {
  1006. case 0:
  1007. case 1:
  1008. case 2:
  1009. case 3:{
  1010. addMsgVC* vc = [[addMsgVC alloc] init];
  1011. //在发布信息后调用,并使其刷新
  1012. vc.block = ^{
  1013. [self scrollToPageUp];
  1014. };
  1015. vc.dataType = (int)index + 2;
  1016. vc.delegate = self;
  1017. vc.didSelect = @selector(hideKeyShowAlert);
  1018. // [g_window addSubview:vc.view];
  1019. [g_navigation pushViewController:vc animated:YES];
  1020. vc.view.hidden = NO;
  1021. }
  1022. break;
  1023. case 4:{
  1024. JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
  1025. vc.remindArray = self.remindArray;
  1026. vc.isShowAll = YES;
  1027. // [g_window addSubview:vc.view];
  1028. [g_navigation pushViewController:vc animated:YES];
  1029. }
  1030. break;
  1031. default:
  1032. break;
  1033. }
  1034. }
  1035. - (void) moreListActionWithIndex:(NSInteger)index {
  1036. }
  1037. - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  1038. UITouch * touch = touches.anyObject;
  1039. if (_selectView == nil) {
  1040. return;
  1041. }
  1042. CGPoint location = [touch locationInView:_selectView];
  1043. //不在选择范围内
  1044. if (location.x < 0 || location.x > JX_SCREEN_WIDTH/2 || location.y < 7) {
  1045. [self viewDisMissAction];
  1046. return;
  1047. }
  1048. int num = (location.y - TopHeight)/CellHeight;
  1049. if (num >= 0 && num < 4) {
  1050. addMsgVC* vc = [[addMsgVC alloc] init];
  1051. //在发布信息后调用,并使其刷新
  1052. vc.block = ^{
  1053. [self scrollToPageUp];
  1054. };
  1055. vc.dataType = num+1;
  1056. vc.delegate = self;
  1057. vc.didSelect = @selector(hideKeyShowAlert);
  1058. // [g_window addSubview:vc.view];
  1059. [g_navigation pushViewController:vc animated:YES];
  1060. vc.view.hidden = NO;
  1061. }
  1062. if (num == 4) {
  1063. JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
  1064. vc.remindArray = self.remindArray;
  1065. vc.isShowAll = YES;
  1066. // [g_window addSubview:vc.view];
  1067. [g_navigation pushViewController:vc animated:YES];
  1068. }
  1069. [self viewDisMissAction];
  1070. }
  1071. - (void)viewDisMissAction{
  1072. [UIView animateWithDuration:0.4 animations:^{
  1073. _bgBlackAlpha.alpha = 0.0;
  1074. } completion:^(BOOL finished) {
  1075. [_selectView removeFromSuperview];
  1076. _selectView = nil;
  1077. [_bgBlackAlpha removeFromSuperview];
  1078. }];
  1079. }
  1080. //单独加在weiboview上,弃用
  1081. - (void) hideKeyShowAlert
  1082. {
  1083. [self doHideKeyboard];
  1084. }
  1085. //- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  1086. //{
  1087. // if (actionSheet.tag==102){
  1088. // if(0==buttonIndex){
  1089. // NSString * string=[NSString stringWithFormat:@"tel:%@",phoneNumber];
  1090. // if(webView==nil)
  1091. // webView=[[UIWebView alloc]initWithFrame:self.view.bounds];
  1092. // [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
  1093. // webView.hidden=YES;
  1094. // [self.view addSubview:webView];
  1095. // }
  1096. // }else if (actionSheet.tag==103){
  1097. // if(0==buttonIndex){
  1098. // NSString * string=[NSString stringWithFormat:@"tel:%@",phoneNumber];
  1099. // if(webView==nil)
  1100. // webView=[[UIWebView alloc]initWithFrame:self.view.bounds];
  1101. // [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
  1102. // webView.hidden=YES;
  1103. // [self.view addSubview:webView];
  1104. // }else if(1==buttonIndex){
  1105. //
  1106. // }
  1107. // }
  1108. //}
  1109. - (void)tableView:(UITableView *)tableView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
  1110. [self doHideMenu];
  1111. [self doHideKeyboard];
  1112. }
  1113. - (void)tapHide:(UITapGestureRecognizer *)tap{
  1114. [self doHideMenu];
  1115. [self doHideKeyboard];
  1116. }
  1117. //创建回复keyBoard上的回复小黑条
  1118. -(void)buildInput{
  1119. self.clearBackGround = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT)];
  1120. UITapGestureRecognizer * tapG = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHide:)];
  1121. [self.clearBackGround addGestureRecognizer:tapG];
  1122. _inputParent = [[UIView alloc]initWithFrame:CGRectMake(0, 200, JX_SCREEN_WIDTH, 49)];
  1123. _inputParent.backgroundColor = [UIColor whiteColor];
  1124. [self.view addSubview:self.clearBackGround];
  1125. [self.clearBackGround addSubview:_inputParent];
  1126. // 配置自适应
  1127. _inputParent.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin);
  1128. self.clearBackGround.hidden = YES;
  1129. _inputParent.opaque = YES;
  1130. _inputParent.hidden = YES;
  1131. _input=[[UITextView alloc]initWithFrame:CGRectMake(15, 8, JX_SCREEN_WIDTH -30 , 33)];
  1132. // _input.target = self;
  1133. _input.delegate = self;
  1134. // _input.didTouch = @selector(onInputText:);
  1135. _input.backgroundColor = [UIColor whiteColor];
  1136. _input.layer.cornerRadius = 3.f;
  1137. _input.layer.masksToBounds = YES;
  1138. // _input.placeHolder = Localized(@"JXAlert_InputSomething");
  1139. _input.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  1140. _input.scrollIndicatorInsets = UIEdgeInsetsMake(10.0f, 0.0f, 10.0f, 8.0f);
  1141. _input.contentInset = UIEdgeInsetsZero;
  1142. _input.scrollEnabled = YES;
  1143. _input.scrollsToTop = NO;
  1144. _input.userInteractionEnabled = YES;
  1145. _input.font = [UIFont systemFontOfSize:16.0f];
  1146. _input.textColor = [UIColor blackColor];
  1147. _input.backgroundColor = [UIColor whiteColor];
  1148. _input.keyboardAppearance = UIKeyboardAppearanceDefault;
  1149. _input.keyboardType = UIKeyboardTypeDefault;
  1150. _input.textAlignment = NSTextAlignmentLeft;
  1151. //重要,扁平
  1152. _input.backgroundColor = [UIColor clearColor];
  1153. // self.layer.borderColor = [UIColor colorWithWhite:0.8f alpha:1.0f].CGColor;
  1154. _input.layer.borderColor = [UIColor colorWithWhite:0.8f alpha:1.0f].CGColor;
  1155. _input.layer.borderWidth = 0.65f;
  1156. _input.layer.cornerRadius = 6.0f;
  1157. _input.returnKeyType = UIReturnKeySend;
  1158. [_inputParent addSubview:_input];
  1159. }
  1160. - (void)textViewDidChange:(UITextView *)textView {
  1161. NSString* s = textView.text;
  1162. unichar c = [s characterAtIndex:s.length-1];
  1163. if (c == '\n'){
  1164. s = [s substringToIndex:s.length-1];
  1165. [self onInputText:s];
  1166. // textView.hidden = YES;
  1167. }
  1168. static CGFloat maxHeight =66.0f;
  1169. CGRect frame = textView.frame;
  1170. CGSize constraintSize = CGSizeMake(frame.size.width, MAXFLOAT);
  1171. CGSize size = [textView sizeThatFits:constraintSize];
  1172. if (size.height >= maxHeight)
  1173. {
  1174. size.height = maxHeight;
  1175. textView.scrollEnabled = YES; // 允许滚动
  1176. }
  1177. else
  1178. {
  1179. textView.scrollEnabled = NO; // 不允许滚动
  1180. }
  1181. if (textView.hidden) {
  1182. size.height = 32 + 5.5;
  1183. }
  1184. textView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, size.height);
  1185. _inputParent.frame = CGRectMake(_inputParent.frame.origin.x, JX_SCREEN_HEIGHT + self.deltaY - (size.height + 16), _inputParent.frame.size.width, size.height + 16);
  1186. }
  1187. -(void)changeKeyBoard:(NSNotification *)aNotifacation
  1188. {
  1189. // return;
  1190. //获取到键盘frame 变化之前的frame
  1191. NSValue *keyboardBeginBounds=[[aNotifacation userInfo]objectForKey:UIKeyboardFrameBeginUserInfoKey];
  1192. CGRect beginRect=[keyboardBeginBounds CGRectValue];
  1193. //获取到键盘frame变化之后的frame
  1194. NSValue *keyboardEndBounds=[[aNotifacation userInfo]objectForKey:UIKeyboardFrameEndUserInfoKey];
  1195. CGRect endRect=[keyboardEndBounds CGRectValue];
  1196. CGFloat deltaY=endRect.origin.y-beginRect.origin.y;
  1197. //拿frame变化之后的origin.y-变化之前的origin.y,其差值(带正负号)就是我们self.view的y方向上的增量
  1198. deltaY=-endRect.size.height;
  1199. self.deltaY = deltaY;
  1200. // NSLog(@"deltaY:%f",deltaY);
  1201. [_table setFrame:CGRectMake(0, JX_SCREEN_HEIGHT+deltaY-_table.frame.size.height, _table.frame.size.width, _table.frame.size.height)];
  1202. [_inputParent setFrame:CGRectMake(0, JX_SCREEN_HEIGHT+deltaY-_inputParent.frame.size.height, _inputParent.frame.size.width, _inputParent.frame.size.height)];
  1203. }
  1204. -(void)doHideKeyboard{
  1205. [_input resignFirstResponder];
  1206. _table.frame =CGRectMake(0,self.heightHeader,self_width,JX_SCREEN_HEIGHT-self.heightHeader-self.heightFooter);
  1207. _inputParent.frame = CGRectMake(0,JX_SCREEN_HEIGHT-_inputParent.frame.size.height,_inputParent.frame.size.width,_inputParent.frame.size.height);
  1208. _inputParent.hidden = YES;
  1209. self.clearBackGround.hidden = YES;
  1210. _input.frame = CGRectMake(_input.frame.origin.x, 8, _input.frame.size.width, _input.frame.size.height);
  1211. }
  1212. -(void)setupTableViewHeight:(CGFloat)height tag:(NSInteger)tag{
  1213. _table.contentSize = CGSizeMake(_table.contentSize.width, _table.contentSize.height+height);
  1214. [_table reloadRow:(int)tag section:0];
  1215. }
  1216. -(IBAction)deleteAction:(id)sender
  1217. {
  1218. UIAlertView * alert=[[UIAlertView alloc]initWithTitle:Localized(@"JX_DeleteShare")
  1219. message:nil
  1220. delegate:self
  1221. cancelButtonTitle:Localized(@"JX_Cencal")
  1222. otherButtonTitles:Localized(@"JX_Confirm"), nil];
  1223. alert.tag=222;
  1224. [alert show];
  1225. }
  1226. //发送回复
  1227. -(void)onInputText:(NSString*)s{
  1228. _input.text = nil;
  1229. [self doHideKeyboard];
  1230. replyDataTemp.messageId = selectWeiboData.messageId;
  1231. replyDataTemp.body = s;
  1232. replyDataTemp.userId = MY_USER_ID;
  1233. replyDataTemp.userNickName = g_server.myself.userNickname;
  1234. [g_App.jxServer addComment:replyDataTemp toView:self];
  1235. }
  1236. -(void)delBtnAction:(WeiboData *)cellData{
  1237. selectWeiboData = cellData;
  1238. NSUInteger index = [_datas indexOfObject:cellData];
  1239. if (index != NSNotFound) {
  1240. NSIndexPath * indexPath = [NSIndexPath indexPathForRow:index inSection:0];
  1241. selectWeiboCell = [_table cellForRowAtIndexPath:indexPath];
  1242. }
  1243. // if (self.isCollection) {
  1244. //
  1245. // [g_server userEmojiDeleteWithId:selectWeiboData.objectId toView:self];
  1246. // }else {
  1247. [self deleteAction];
  1248. // }
  1249. }
  1250. - (void)fileAction:(WeiboData *)cellData {
  1251. ObjUrlData * obj= [cellData.files firstObject];
  1252. webpageVC *webVC = [webpageVC alloc];
  1253. webVC.isGotoBack= YES;
  1254. webVC.isSend = YES;
  1255. if (obj.name.length > 0) {
  1256. webVC.titleString = obj.name;
  1257. }else {
  1258. webVC.titleString = [obj.url lastPathComponent];
  1259. }
  1260. webVC.url = obj.url;
  1261. webVC = [webVC init];
  1262. [g_navigation.navigationView addSubview:webVC.view];
  1263. // [g_navigation pushViewController:webVC animated:YES];
  1264. }
  1265. //#pragma mark - 点赞、评论控件 delegate
  1266. //- (void)didMenuView:(JXMenuView *)menuView WithButtonIndex:(NSInteger)index {
  1267. // self.menuView = nil;
  1268. // if (index == 0) {
  1269. // if (!selectWeiboData.isPraise) {
  1270. // [self praiseAddAction];
  1271. // } else {
  1272. // [self praiseDelAction];
  1273. // }
  1274. // }else if (index == 1) {
  1275. // [self commentAction];
  1276. // }else if (index == 2) {
  1277. // if ([selectWeiboData.userId isEqualToString:MY_USER_ID]) {
  1278. // [self deleteAction];
  1279. // }else {
  1280. // [self reportUserView];
  1281. // }
  1282. // }
  1283. //}
  1284. #pragma mark - 点赞、评论控件创建
  1285. -(void)btnReplyAction:(UIButton *)sender WithCell:(WeiboCell *)cell {
  1286. // if (self.menuView) {
  1287. // [self.menuView dismissBaseView];
  1288. // if (cell == _lastCell) {
  1289. // self.lastCell = nil;
  1290. // return;
  1291. // }
  1292. // }
  1293. self.lastCell = cell;
  1294. NSIndexPath * indexPath = [NSIndexPath indexPathForRow:cell.tag inSection:0];
  1295. selectWeiboCell = [_table cellForRowAtIndexPath:indexPath];
  1296. selectWeiboData = [_datas objectAtIndex:cell.tag];
  1297. // BOOL isDelete = [selectWeiboData.userId isEqualToString:MY_USER_ID];
  1298. // NSArray *strArr = @[selectWeiboData.isPraise ? Localized(@"JX_Cencal") : Localized(@"JX_Good"),Localized(@"JX_Comment"),isDelete ? Localized(@"JX_Delete") : Localized(@"JXUserInfoVC_Report")];
  1299. // NSArray *imgArr = @[@"blog_giveLike",@"blog_comments",isDelete ? @"blog_delete" : @"blog_report"];
  1300. //
  1301. // CGPoint point = cell.replyContent.frame.origin;
  1302. // CGFloat y = point.y-5;
  1303. //
  1304. //
  1305. // self.menuView = [[JXMenuView alloc] initWithPoint:CGPointMake(0, y) Title:strArr Images:imgArr];
  1306. // self.menuView.delegate = self;
  1307. // [cell addSubview:self.menuView];
  1308. NSInteger btnTag = sender.tag % 1000;
  1309. if (btnTag == 1) { // 点赞
  1310. if (!selectWeiboData.isPraise) {
  1311. [self praiseAddAction];
  1312. } else {
  1313. [self praiseDelAction];
  1314. }
  1315. }else if(btnTag == 2) { // 评论
  1316. if (cell.weibo.isAllowComment == 0) {
  1317. [self commentAction];
  1318. }else {
  1319. [g_server showMsg:Localized(@"JX_NotComments") delay:.5];
  1320. }
  1321. }else if(btnTag == 3) { // 收藏
  1322. [self collectionWeibo];
  1323. }else{ // 举报
  1324. [self reportUserView];
  1325. }
  1326. }
  1327. - (void)collectionWeibo {
  1328. NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
  1329. WeiboData * weibo = [_datas objectAtIndex:self.lastCell.tag];
  1330. if (weibo.isCollect) { // 如果已被收藏,则取消收藏
  1331. [g_server userWeiboEmojiDeleteWithId:weibo.messageId toView:self];
  1332. }else {
  1333. ObjUrlData *data;
  1334. NSString *msg;
  1335. if (weibo.images.count > 0 || weibo.videos.count > 0) { // 图片或者视频都会进
  1336. if (weibo.videos.count > 0) { // 如果是视频
  1337. data = [weibo.videos firstObject];
  1338. msg = data.url;
  1339. weibo.type = 2;
  1340. }else { // 只是图片
  1341. NSMutableArray *imgArr = [NSMutableArray array];
  1342. for (NSDictionary *dict in weibo.images) {
  1343. NSString *imgUrl = [dict objectForKey:@"oUrl"];
  1344. [imgArr addObject:imgUrl];
  1345. }
  1346. if (imgArr.count > 1) {
  1347. msg = [imgArr componentsJoinedByString:@","];
  1348. }else {
  1349. msg = [imgArr firstObject];
  1350. }
  1351. weibo.type = 1;
  1352. }
  1353. }else if (weibo.audios.count > 0) {
  1354. data = [weibo.audios firstObject];
  1355. msg = data.url;
  1356. weibo.type = 4;
  1357. }else if (weibo.files.count > 0){
  1358. data = [weibo.files firstObject];
  1359. msg = data.url;
  1360. weibo.type = 3;
  1361. }else if (weibo.videos.count > 0){
  1362. // 视频放在图片中做处理
  1363. }else { // 纯文本
  1364. weibo.type = 5;
  1365. msg = weibo.content;
  1366. }
  1367. [dataDict setValue:msg forKey:@"msg"];
  1368. [dataDict setValue:@(weibo.type) forKey:@"type"];
  1369. [dataDict setValue:data.name forKey:@"fileName"];
  1370. [dataDict setValue:data.fileSize forKey:@"fileSize"];
  1371. [dataDict setValue:data.timeLen forKey:@"fileLength"];
  1372. [dataDict setValue:weibo.content forKey:@"collectContent"];
  1373. [dataDict setValue:weibo.messageId forKey:@"collectMsgId"];
  1374. [dataDict setValue:@1 forKey:@"collectType"];
  1375. NSMutableArray * emoji = [NSMutableArray array];
  1376. [emoji addObject:dataDict];
  1377. [g_server addFavoriteWithEmoji:emoji toView:self];
  1378. }
  1379. }
  1380. -(void)reportUserView{
  1381. JXReportUserVC * reportVC = [[JXReportUserVC alloc] init];
  1382. reportVC.user = self.user;
  1383. reportVC.delegate = self;
  1384. [g_navigation pushViewController:reportVC animated:YES];
  1385. }
  1386. - (void)report:(JXUserObject *)reportUser reasonId:(NSNumber *)reasonId {
  1387. [g_server reportUser:selectWeiboData.userId roomId:nil webUrl:nil reasonId:reasonId toView:self];
  1388. }
  1389. - (BOOL)canBecomeFirstResponder
  1390. {
  1391. return YES;
  1392. }
  1393. - (BOOL)canPerformAction:(SEL)action
  1394. withSender:(id)sender
  1395. {
  1396. if (action == @selector(allCommentAction) ||
  1397. action == @selector(commentAction) ||
  1398. action == @selector(giftAction) ||
  1399. action == @selector(forwardAction) ||
  1400. action == @selector(deleteAction) ||
  1401. (action == @selector(praiseAddAction) && !selectWeiboData.isPraise) ||
  1402. (action == @selector(praiseDelAction) && selectWeiboData.isPraise) || action == @selector(reportUserView))
  1403. return YES;
  1404. else
  1405. return NO;
  1406. }
  1407. -(void)delAndReplyAction
  1408. {
  1409. }
  1410. -(void)allCommentAction{
  1411. }
  1412. -(void)doShowAddComment:(NSString*)s{
  1413. // _input.placeHolder = s;
  1414. self.clearBackGround.hidden = NO;
  1415. _inputParent.hidden = NO;
  1416. [_input becomeFirstResponder];
  1417. }
  1418. -(void)commentAction{
  1419. replyDataTemp.toUserId = nil;
  1420. replyDataTemp.toNickName = nil;
  1421. [self doShowAddComment:nil];
  1422. }
  1423. -(void)praiseAddAction{
  1424. if(!selectWeiboData.isPraise)
  1425. [g_App.jxServer addPraise:selectWeiboData.messageId toView:self];
  1426. }
  1427. -(void)praiseDelAction{
  1428. if(selectWeiboData.isPraise)
  1429. [g_App.jxServer delPraise:selectWeiboData.messageId toView:self];
  1430. }
  1431. -(void)giftAction{
  1432. return;
  1433. // NSMutableArray* p = [[NSMutableArray alloc]init];
  1434. // for(int i=0;i<2;i++){
  1435. // NSMutableDictionary* dict = [[NSMutableDictionary alloc]init];
  1436. // [dict setValue:[NSNumber numberWithInt:i+1] forKey:@"goodsId"];
  1437. // [dict setValue:@"3" forKey:@"count"];
  1438. // [p addObject:dict];
  1439. // }
  1440. // SBJsonWriter * OderJsonwriter = [SBJsonWriter new];
  1441. // NSString * jsonString = [OderJsonwriter stringWithObject:p];
  1442. // // [OderJsonwriter release];
  1443. // // [p release];
  1444. // [g_App.jxServer addGift:selectWeiboData.messageId gifts:jsonString toView:self];
  1445. }
  1446. -(void)forwardAction{
  1447. }
  1448. //删除说说
  1449. -(void)deleteAction{
  1450. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:Localized(@"JX_IsDeletionConfirmed") message:nil delegate:self cancelButtonTitle:Localized(@"JX_Cencal") otherButtonTitles:Localized(@"JX_Confirm"), nil];
  1451. [alert show];
  1452. }
  1453. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  1454. if (buttonIndex == 1) {
  1455. if (alertView.tag == 2457) {
  1456. [self actionQuit];
  1457. [UIView animateWithDuration:0.3 animations:^{
  1458. [alertView dismissWithClickedButtonIndex:buttonIndex animated:NO];
  1459. } completion:^(BOOL finished) {
  1460. [self.delegate weiboVC:self didSelectWithData:_currentData];
  1461. }];
  1462. }else {
  1463. NSInteger i = [_datas indexOfObject:selectWeiboData];
  1464. WeiboCell *cell = [_table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
  1465. if (cell.audioPlayer != nil) {
  1466. [cell.audioPlayer stop];
  1467. cell.audioPlayer = nil;
  1468. }
  1469. if (cell.videoPlayer != nil) {
  1470. [cell.videoPlayer stop];
  1471. cell.videoPlayer = nil;
  1472. }
  1473. if (self.isCollection) {
  1474. [g_server userEmojiDeleteWithId:selectWeiboData.objectId toView:self];
  1475. }else {
  1476. [g_server delMessage:selectWeiboData.messageId toView:self];
  1477. }
  1478. }
  1479. }
  1480. }
  1481. //顶部大头照
  1482. -(void)createTableHeadShowRemind{
  1483. if (self.isDetail || self.isCollection) {
  1484. _table.tableHeaderView = nil;
  1485. return;
  1486. }
  1487. // [g_mainVC.tb setBadge:2 title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
  1488. int number = 0;
  1489. if (g_App.linkArray.count == 0) {
  1490. number = 2;
  1491. }else if(g_App.linkArray.count == 1){
  1492. number = 3;
  1493. }else if(g_App.linkArray.count == 2){
  1494. number = 100;
  1495. }
  1496. [g_mainVC.tb setBadge:number title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
  1497. UIView* head = [[UIView alloc]initWithFrame:CGRectMake(0,0, JX_SCREEN_WIDTH,250+JX_SCREEN_TOP+TopImageInset + (THE_DEVICE_HAVE_HEAD ? 44 : 20))];
  1498. head.backgroundColor = [UIColor whiteColor];
  1499. //上方大头照
  1500. JXImageView* iv = [[JXImageView alloc]initWithFrame:CGRectMake(0,0, JX_SCREEN_WIDTH,head.frame.size.height)];
  1501. iv.delegate = self;
  1502. iv.didTouch = @selector(actionPhotos);
  1503. iv.changeAlpha = NO;
  1504. iv.backgroundColor = [UIColor lightGrayColor];
  1505. iv.clipsToBounds = YES;
  1506. iv.contentMode = UIViewContentModeScaleAspectFill;
  1507. _topBackImageView = iv;
  1508. [self showTopImage];
  1509. // [g_server getHeadImageLarge:user.userId imageView:iv];
  1510. [head addSubview:iv];
  1511. UIButton* backBtn = [UIFactory createButtonWithImage:@"blog_back"
  1512. highlight:nil
  1513. target:self
  1514. selector:@selector(actionQuit)];
  1515. backBtn.frame = CGRectMake(15, JX_SCREEN_TOP-7-30+TopImageInset, 30, 30);
  1516. [head addSubview:backBtn];
  1517. if (!self.isDetail && [self.user.userId isEqualToString:MY_USER_ID]) {
  1518. UIButton* btn = [UIFactory createButtonWithImage:@"blog_add_msg"
  1519. highlight:nil
  1520. target:self
  1521. selector:@selector(onAddMsg:)];
  1522. btn.frame = CGRectMake(JX_SCREEN_WIDTH-15-30, JX_SCREEN_TOP-7-30+TopImageInset, 30, 30);
  1523. [head addSubview:btn];
  1524. }
  1525. UIView *radianView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(head.frame)-47, JX_SCREEN_WIDTH, 47)];
  1526. radianView.backgroundColor = [UIColor whiteColor];
  1527. [head addSubview:radianView];
  1528. [self setPartRoundWithView:radianView corners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadius:27];
  1529. CGFloat btnWH = 38;
  1530. // 语音
  1531. CGFloat btnX = (JX_SCREEN_WIDTH-38*5)/6;
  1532. CGFloat btnY = iv.frame.size.height-btnWH-15- radianView.frame.size.height;
  1533. if (!self.isDetail && [self.user.userId isEqualToString:MY_USER_ID] && !self.isCollection) {
  1534. UIButton *btn;
  1535. btn = [[UIButton alloc] initWithFrame:CGRectMake(btnX, btnY, btnWH, btnWH)];
  1536. [btn setTag:1];
  1537. [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_voice"] forState:UIControlStateNormal];
  1538. [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
  1539. [head addSubview:btn];
  1540. // 图文
  1541. btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
  1542. [btn setTag:0];
  1543. [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_image"] forState:UIControlStateNormal];
  1544. [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
  1545. [head addSubview:btn];
  1546. // 视频
  1547. btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
  1548. [btn setTag:2];
  1549. [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_video"] forState:UIControlStateNormal];
  1550. [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
  1551. [head addSubview:btn];
  1552. // 文件
  1553. btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
  1554. [btn setTag:3];
  1555. [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_file"] forState:UIControlStateNormal];
  1556. [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
  1557. [head addSubview:btn];
  1558. // 点赞/回复
  1559. btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
  1560. [btn setTag:4];
  1561. [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_like"] forState:UIControlStateNormal];
  1562. [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
  1563. [head addSubview:btn];
  1564. }
  1565. UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(0, btnY-20-20, JX_SCREEN_WIDTH, 20)];
  1566. name.textColor = [UIColor whiteColor];
  1567. name.font = SYSFONT(20);
  1568. name.text = self.user.userNickname;
  1569. name.textAlignment = NSTextAlignmentCenter;
  1570. [head addSubview:name];
  1571. name.layer.shadowColor = [UIColor blackColor].CGColor;
  1572. name.layer.shadowOpacity = 0.6;
  1573. name.layer.shadowRadius = 1.0;
  1574. name.clipsToBounds = NO;
  1575. iv = [[JXImageView alloc]initWithFrame:CGRectMake((JX_SCREEN_WIDTH-79)/2,CGRectGetMinY(name.frame)-10-79, 79,79)];
  1576. iv.layer.masksToBounds = YES;
  1577. iv.layer.cornerRadius = iv.frame.size.width/2;
  1578. iv.layer.borderWidth = 3.f;
  1579. iv.layer.borderColor = [UIColor whiteColor].CGColor;
  1580. iv.delegate = self;
  1581. iv.didTouch = @selector(actionUser);
  1582. [g_server getHeadImageSmall:user.userId userName:nil imageView:iv];
  1583. [head addSubview:iv];
  1584. if (self.remindArray.count) {
  1585. head.frame = CGRectMake(head.frame.origin.x, head.frame.origin.y, head.frame.size.width, head.frame.size.height + 40-17+15);
  1586. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(radianView.frame)-17, 180, 40)];
  1587. btn.backgroundColor = [UIColor colorWithWhite:.2 alpha:1];
  1588. btn.center = CGPointMake(head.frame.size.width / 2, btn.center.y);
  1589. btn.layer.cornerRadius = btn.frame.size.height/2;
  1590. btn.layer.masksToBounds = YES;
  1591. [btn addTarget:self action:@selector(remindBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  1592. [head addSubview:btn];
  1593. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 30, 30)];
  1594. JXBlogRemind *br = _remindArray.firstObject;
  1595. [g_server getHeadImageLarge:br.fromUserId userName:br.fromUserName imageView:imageView];
  1596. imageView.layer.cornerRadius = imageView.frame.size.height/2;
  1597. imageView.layer.masksToBounds = YES;
  1598. [btn addSubview:imageView];
  1599. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, btn.frame.size.width, btn.frame.size.height)];
  1600. label.font = SYSFONT(14.0);
  1601. label.backgroundColor = [UIColor clearColor];
  1602. label.textColor = [UIColor whiteColor];
  1603. label.textAlignment = NSTextAlignmentCenter;
  1604. label.text = [NSString stringWithFormat:@"%ld%@",self.remindArray.count, Localized(@"JX_PieceNewMessage")];
  1605. [btn addSubview:label];
  1606. UIImageView *arrowImage = [[UIImageView alloc] initWithFrame:CGRectMake(btn.frame.size.width - 15-7, (40-13)/2, 7, 13)];
  1607. arrowImage.image = [[UIImage imageNamed:@"new_icon_>"] imageWithTintColor:[UIColor blackColor]];
  1608. [btn addSubview:arrowImage];
  1609. }
  1610. _table.tableHeaderView = head;
  1611. }
  1612. // 画圆角
  1613. - (void)setPartRoundWithView:(UIView *)view corners:(UIRectCorner)corners cornerRadius:(float)cornerRadius {
  1614. CAShapeLayer *shapeLayer = [CAShapeLayer layer];
  1615. shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)].CGPath;
  1616. view.layer.mask = shapeLayer;
  1617. }
  1618. - (void)didMenuBtn:(UIButton *)button {
  1619. NSInteger index = button.tag;
  1620. switch (index) {
  1621. case 0:
  1622. case 1:
  1623. case 2:
  1624. case 3:{
  1625. addMsgVC* vc = [[addMsgVC alloc] init];
  1626. //在发布信息后调用,并使其刷新
  1627. vc.block = ^{
  1628. [self scrollToPageUp];
  1629. };
  1630. vc.dataType = (int)index + 2;
  1631. vc.delegate = self;
  1632. vc.didSelect = @selector(hideKeyShowAlert);
  1633. [g_navigation pushViewController:vc animated:YES];
  1634. vc.view.hidden = NO;
  1635. }
  1636. break;
  1637. case 4:{
  1638. JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
  1639. vc.remindArray = self.remindArray;
  1640. vc.isShowAll = YES;
  1641. [g_navigation pushViewController:vc animated:YES];
  1642. }
  1643. break;
  1644. default:
  1645. break;
  1646. }
  1647. }
  1648. - (void)remindBtnAction:(UIButton *)btn {
  1649. JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
  1650. vc.remindArray = self.remindArray;
  1651. // [g_window addSubview:vc.view];
  1652. [g_navigation pushViewController:vc animated:YES];
  1653. [[JXBlogRemind sharedInstance] updateUnread];
  1654. _remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
  1655. [self createTableHeadShowRemind];
  1656. // [self showTopImage];
  1657. }
  1658. -(void)doRefresh:(NSNotification *)notifacation{
  1659. [self createTableHeadShowRemind];
  1660. [self getServerData];
  1661. }
  1662. -(void)actionUser{
  1663. // _userVc = nil;
  1664. // _userVc = [userInfoVC alloc];
  1665. // _userVc.userId = self.user.userId;
  1666. // [_userVc init];
  1667. // [g_window addSubview:_userVc.view];
  1668. // [g_server getUser:self.user.userId toView:self];
  1669. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  1670. vc.userId = self.user.userId;
  1671. vc.fromAddType = 6;
  1672. vc = [vc init];
  1673. [g_navigation pushViewController:vc animated:YES];
  1674. [_pool addObject:vc];
  1675. }
  1676. -(NSString*)getLastMessageId:(NSArray*)objects{
  1677. NSString* lastId = @"";
  1678. if(_page > 0){
  1679. NSInteger n = [objects count]-1;
  1680. if(n>=0){
  1681. WeiboData* p = [objects objectAtIndex:n];
  1682. lastId = p.messageId;
  1683. p = nil;
  1684. }
  1685. }
  1686. return lastId;
  1687. }
  1688. -(void)doAddPraiseOK{
  1689. BOOL b=YES;
  1690. for(int i=0;i<[selectWeiboData.praises count];i++){
  1691. WeiboReplyData* praise = [selectWeiboData.praises objectAtIndex:i];
  1692. if([praise.userId intValue] == [g_server.myself.userId intValue]){
  1693. b = NO;
  1694. break;
  1695. }
  1696. }
  1697. if(b){
  1698. WeiboReplyData* praise = [[WeiboReplyData alloc]init];
  1699. praise.userId = g_server.myself.userId;
  1700. praise.userNickName = g_server.myself.userNickname;
  1701. praise.type = reply_data_praise;
  1702. [self.selectWeiboData.praises insertObject:praise atIndex:0];
  1703. selectWeiboData.replyHeight=[selectWeiboData heightForReply];
  1704. }
  1705. selectWeiboData.praiseCount++;
  1706. selectWeiboData.isPraise = YES;
  1707. [self.selectWeiboCell refresh];
  1708. // JXMessageObject *msg = [[JXMessageObject alloc] init];
  1709. // msg.timeSend = [NSDate date];
  1710. // msg.fromUserId = MY_USER_ID;
  1711. // msg.fromUserName = g_server.myself.userNickname;
  1712. // NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  1713. // [dict setObject:selectWeiboData.messageId forKey:@"id"];
  1714. // NSString *url;
  1715. // int type;
  1716. // if (selectWeiboData.images.count > 0) {
  1717. // url = [selectWeiboData.images.firstObject objectForKey:@"oUrl"];
  1718. // type = 1;
  1719. // }
  1720. // if (selectWeiboData.audios.count > 0) {
  1721. // url = selectWeiboData.audios.firstObject;
  1722. // type = 2;
  1723. // }
  1724. // if (selectWeiboData.videos.count > 0) {
  1725. // url = selectWeiboData.videos.firstObject;
  1726. // type = 3;
  1727. // }
  1728. //
  1729. // [dict setObject:[NSNumber numberWithInt:type] forKey:@"type"];
  1730. // if (url.length > 0) {
  1731. //
  1732. // [dict setObject:url forKey:@"url"];
  1733. // }
  1734. //
  1735. // NSError *error;
  1736. // NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
  1737. // options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
  1738. // error:&error];
  1739. //
  1740. // NSString *jsonString;
  1741. // if (! jsonData)
  1742. // {
  1743. // NSLog(@"Got an error: %@", error);
  1744. // }else
  1745. // {
  1746. // jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1747. // }
  1748. //
  1749. // jsonString = [jsonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //去除掉首尾的空白字符和换行字符
  1750. //
  1751. // [jsonString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  1752. //
  1753. // msg.objectId = jsonString;
  1754. // [g_xmpp sendMessage:msg roomName:nil];
  1755. }
  1756. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  1757. if (self.isCollection || self.isDetail) {
  1758. return;
  1759. }
  1760. CGFloat offsetY = scrollView.contentOffset.y;
  1761. NSLog(@"------------------y = %f",offsetY);
  1762. // if (y > 250+JX_SCREEN_TOP+TopImageInset + (THE_DEVICE_HAVE_HEAD ? 44 : 20)) {
  1763. // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  1764. // self.tableHeader.alpha = 1;
  1765. // }else {
  1766. // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  1767. // self.tableHeader.alpha = 0;
  1768. // }
  1769. if (offsetY > 200) {
  1770. // if (offsetY < _lastOffsetY) {
  1771. [UIView animateWithDuration:.3f animations:^{
  1772. self.tableHeader.transform = CGAffineTransformIdentity; //复位
  1773. } completion:^(BOOL finished) {
  1774. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  1775. }];
  1776. // }else {
  1777. // [UIView animateWithDuration:.3f animations:^{
  1778. // self.tableHeader.transform = CGAffineTransformMakeTranslation(0, -JX_SCREEN_TOP);
  1779. // } completion:^(BOOL finished) {
  1780. // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  1781. // }];
  1782. // }
  1783. }else {
  1784. [UIView animateWithDuration:.3f animations:^{
  1785. self.tableHeader.transform = CGAffineTransformMakeTranslation(0, -JX_SCREEN_TOP);
  1786. } completion:^(BOOL finished) {
  1787. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  1788. }];
  1789. }
  1790. _lastOffsetY = offsetY;
  1791. }
  1792. -(void)doDelPraiseOK{
  1793. for(int i=0;i<[selectWeiboData.praises count];i++){
  1794. WeiboReplyData* praise = [selectWeiboData.praises objectAtIndex:i];
  1795. if([praise.userId intValue] == [g_server.myself.userId intValue]){
  1796. [selectWeiboData.praises removeObjectAtIndex:i];
  1797. break;
  1798. }
  1799. }
  1800. selectWeiboData.praiseCount--;
  1801. if(selectWeiboData.praiseCount<0)
  1802. selectWeiboData.praiseCount=0;
  1803. selectWeiboData.isPraise = NO;
  1804. selectWeiboData.replyHeight=[selectWeiboData heightForReply];
  1805. [self.selectWeiboCell refresh];
  1806. }
  1807. -(void)actionPhotos{
  1808. if (![user.userId isEqualToString:MY_USER_ID]) {
  1809. return;
  1810. }
  1811. JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JX_ChoosePhoto"),Localized(@"JX_TakePhoto")]];
  1812. actionVC.delegate = self;
  1813. actionVC.tag = 111;
  1814. [self presentViewController:actionVC animated:NO completion:nil];
  1815. }
  1816. -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  1817. {
  1818. [picker dismissViewControllerAnimated:YES completion:nil];
  1819. }
  1820. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  1821. {
  1822. UIImage *image = [ImageResize image:[info objectForKey:@"UIImagePickerControllerEditedImage"] fillSize:CGSizeMake(640, 640)];
  1823. NSString* filePath = [FileInfo getUUIDFileName:@"jpg"];
  1824. [g_server saveImageToFile:image file:filePath isOriginal:NO];
  1825. [g_server uploadFile:filePath validTime:@"-1" messageId:nil toView:self];
  1826. _topBackImageView.image = image;
  1827. [picker dismissViewControllerAnimated:YES completion:nil];
  1828. }
  1829. - (void)cameraVC:(JXCameraVC *)vc didFinishWithImage:(UIImage *)image {
  1830. UIImage *camImage = [ImageResize image:image fillSize:CGSizeMake(640, 640)];
  1831. NSString* filePath = [FileInfo getUUIDFileName:@"jpg"];
  1832. [g_server saveImageToFile:camImage file:filePath isOriginal:NO];
  1833. [g_server uploadFile:filePath validTime:@"-1" messageId:nil toView:self];
  1834. _topBackImageView.image = camImage;
  1835. }
  1836. // 滚动tableView 移除点赞、评论控件
  1837. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  1838. [self.menuView dismissBaseView];
  1839. self.lastCell = nil;
  1840. }
  1841. - (void)showTopImage {
  1842. if (IsStringNull(_topImageUrl)) {
  1843. [g_server getHeadImageLarge:user.userId userName:user.userNickname imageView:_topBackImageView];
  1844. }else {
  1845. [g_server getImage:_topImageUrl imageView:_topBackImageView];
  1846. }
  1847. }
  1848. @end