WBStatusTimelineViewController.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. //
  2. // YYWeiboFeedListController.m
  3. // YYKitExample
  4. //
  5. // Created by ibireme on 15/9/4.
  6. // Copyright (c) 2015 ibireme. All rights reserved.
  7. //
  8. #import "WBStatusTimelineViewController.h"
  9. #import "YYKit.h"
  10. #import "WBModel.h"
  11. #import "WBStatusLayout.h"
  12. #import "WBStatusCell.h"
  13. #import "YYPhotoGroupView.h"
  14. //#import "YYFPSLabel.h"
  15. #import <AVKit/AVKit.h>
  16. //#import "BogoDynamicDetailViewController.h"
  17. //#import "WBStatusComposeViewController.h"
  18. //#import "UserPageViewController.h"
  19. #import "WBUserInfoModel.h"
  20. #import <ZFPlayer/ZFPlayer.h>
  21. #import <ZFPlayer/ZFAVPlayerManager.h>
  22. #import <ZFPlayer/ZFPlayerControlView.h>
  23. #import <AVFoundation/AVFoundation.h>
  24. #import "WBStatusVideoControlView.h"
  25. #import <AFSoundManager/AFSoundManager.h>
  26. typedef void(^scrollViewDidScrollBlock)(UIScrollView *scrollView);
  27. @interface WBStatusTimelineViewController () <UITableViewDelegate, UITableViewDataSource, WBStatusCellDelegate>
  28. @property (nonatomic, strong) YYTableView *tableView;
  29. @property (nonatomic, strong) NSMutableArray *layouts;
  30. //@property (nonatomic, strong) YYFPSLabel *fpsLabel;
  31. @property(nonatomic, assign) NSInteger page;
  32. @property(nonatomic, strong) UIButton *releaseBtn;
  33. @property(nonatomic, strong) QMUIPopupMenuView *popView;
  34. @property (nonatomic, strong) ZFPlayerController *player;
  35. @property (nonatomic, strong) WBStatusVideoControlView *controlView;
  36. @property (nonatomic, strong) NSMutableArray *urls;
  37. @property(nonatomic, copy) scrollViewDidScrollBlock scrollViewDidScrollBlock;
  38. @property(nonatomic, strong) NSMutableArray *items;
  39. @property (nonatomic, strong) AFSoundPlayback *playback;
  40. @property (nonatomic, strong) AFSoundQueue *queue;
  41. @end
  42. @implementation WBStatusTimelineViewController
  43. - (instancetype)init {
  44. self = [super init];
  45. _tableView = [YYTableView new];
  46. _tableView.delegate = self;
  47. _tableView.dataSource = self;
  48. _layouts = [NSMutableArray new];
  49. _urls = [NSMutableArray array];
  50. _page = 1;
  51. return self;
  52. }
  53. - (void)viewDidLoad {
  54. [super viewDidLoad];
  55. if ([self respondsToSelector:@selector( setAutomaticallyAdjustsScrollViewInsets:)]) {
  56. self.automaticallyAdjustsScrollViewInsets = NO;
  57. }
  58. _tableView.frame = _tableViewFrame;
  59. _tableView.backgroundColor = [UIColor clearColor];
  60. _tableView.backgroundView.backgroundColor = [UIColor clearColor];
  61. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
  62. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
  63. [_tableView registerClass:[WBStatusCell class] forCellReuseIdentifier:NSStringFromClass([WBStatusCell class])];
  64. __weak __typeof(self)weakSelf = self;
  65. _tableView.zf_scrollViewDidEndScrollingCallback = ^(NSIndexPath * _Nonnull indexPath) {
  66. __strong __typeof(weakSelf)strongSelf = weakSelf;
  67. if (!strongSelf.player.playingIndexPath) {
  68. // [strongSelf playTheVideoAtIndexPath:indexPath scrollToTop:NO];
  69. }
  70. };
  71. [self.view addSubview:_tableView];
  72. self.view.backgroundColor = kWhiteColor;
  73. // _fpsLabel = [YYFPSLabel new];
  74. // [_fpsLabel sizeToFit];
  75. // _fpsLabel.bottom = _tableView.height - kWBCellPadding;
  76. // _fpsLabel.left = kWBCellPadding;
  77. // _fpsLabel.alpha = 0;
  78. // [self.view addSubview:_fpsLabel];
  79. // if ([_to_user_id isEqualToString:[IMAPlatform sharedInstance].host.userId]) {
  80. // self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.releaseBtn];
  81. // }
  82. [self.tableView.mj_header beginRefreshing];
  83. ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init];
  84. // KSMediaPlayerManager *playerManager = [[KSMediaPlayerManager alloc] init];
  85. // ZFIJKPlayerManager *playerManager = [[ZFIJKPlayerManager alloc] init];
  86. /// player的tag值必须在cell里设置
  87. self.player = [ZFPlayerController playerWithScrollView:self.tableView playerManager:playerManager containerViewTag:100];
  88. self.player.controlView = self.controlView;
  89. /// 0.8是消失80%时候,默认0.5
  90. self.player.playerDisapperaPercent = 0.8;
  91. /// 移动网络依然自动播放
  92. self.player.WWANAutoPlay = YES;
  93. @weakify(self)
  94. self.player.playerDidToEnd = ^(id _Nonnull asset) {
  95. @strongify(self)
  96. [self.player playTheIndexPath:self.player.playingIndexPath];
  97. };
  98. /// 停止的时候找出最合适的播放
  99. self.player.zf_scrollViewDidEndScrollingCallback = ^(NSIndexPath * _Nonnull indexPath) {
  100. @strongify(self)
  101. if (self.player.playingIndexPath) return;
  102. if (indexPath.row == self.layouts.count-1) {
  103. /// 加载下一页数据
  104. [self footerRefresh];
  105. }
  106. [self playTheVideoAtIndexPath:indexPath];
  107. };
  108. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshParent:) name:@"refreshParentDynamic" object:nil];
  109. }
  110. - (void)refreshParent:(NSNotification *)noti{
  111. NSNumber *index = noti.object;
  112. if (index.integerValue == self.type) {
  113. [self headerRefresh];
  114. }
  115. }
  116. /// play the video
  117. - (void)playTheVideoAtIndexPath:(NSIndexPath *)indexPath {
  118. [self.player playTheIndexPath:indexPath];
  119. [self.controlView resetControlView];
  120. // WBStatusLayout *data = self.layouts[indexPath.row];
  121. // [self.controlView showCoverViewWithUrl:data.status.cover_url withImageMode:UIViewContentModeScaleAspectFit];
  122. }
  123. - (void)viewDidAppear:(BOOL)animated{
  124. [super viewDidAppear:animated];
  125. if (self.isFront) {
  126. [self.tableView zf_filterShouldPlayCellWhileScrolled:^(NSIndexPath *indexPath) {
  127. // [self playTheVideoAtIndexPath:indexPath scrollToTop:NO];
  128. }];
  129. }
  130. // self.player.viewControllerDisappear = NO;
  131. }
  132. - (void)viewDidDisappear:(BOOL)animated{
  133. [super viewDidDisappear:animated];
  134. [self.player stopCurrentPlayingCell];
  135. // self.player.viewControllerDisappear = YES;
  136. }
  137. - (void)releaseBtnAction{
  138. // WBStatusComposeViewController *vc = [WBStatusComposeViewController new];
  139. // vc.type = WBStatusComposeViewTypeStatus;
  140. // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
  141. // nav.modalPresentationStyle = UIModalPresentationFullScreen;
  142. // [self presentViewController:nav animated:YES completion:NULL];
  143. }
  144. - (void)viewWillAppear:(BOOL)animated{
  145. [super viewWillAppear:animated];
  146. _tableView.frame = _tableViewFrame;
  147. }
  148. - (void)viewWillDisappear:(BOOL)animated {
  149. [super viewWillDisappear:animated];
  150. if (_queue.status == AFSoundStatusPlaying) {
  151. [_queue pause];
  152. _queue.status = AFSoundStatusPaused;
  153. // [cell.audioBtn.imgView stopAnimating];
  154. }
  155. }
  156. - (void)refreshData{
  157. [self.player stopCurrentPlayingCell];
  158. [self.tableView.mj_header beginRefreshing];
  159. }
  160. - (void)refreshDataNew{
  161. [self.player stopCurrentPlayingCell];
  162. [self.layouts removeAllObjects];
  163. [self.tableView reloadData];
  164. [self headerRefresh];
  165. }
  166. - (void)headerRefresh{
  167. _page = 1;
  168. [self requestData];
  169. }
  170. -(void)headerRefreshToTop:(BOOL)toTop{
  171. _page = 1;
  172. if (toTop) {
  173. [self.tableView scrollToTop];
  174. }
  175. [self requestData];
  176. }
  177. - (void)footerRefresh{
  178. _page ++;
  179. [self requestData];
  180. }
  181. - (void)requestData{
  182. self.navigationController.view.userInteractionEnabled = NO;
  183. // http://videoline.2019.bogokj.com/mapi/public/index.php/api/bzone_api/get_list_3x
  184. NSString *action = @"";
  185. NSMutableDictionary *paramDic = [NSMutableDictionary dictionary];
  186. paramDic = [NSMutableDictionary dictionaryWithDictionary:@{@"page":@(_page),@"to_user_id":_type == WBStatusTimelineViewControllerTypeUser ? _to_user_id : @"",@"topic":_topic.length ? _topic : @""}];
  187. switch (_type) {
  188. case WBStatusTimelineViewControllerTypeFriend:
  189. action = @"friends";
  190. break;
  191. case WBStatusTimelineViewControllerTypeUser:
  192. action = @"ou";
  193. break;
  194. case WBStatusTimelineViewControllerTypeFocus:
  195. action = @"att";
  196. break;
  197. case WBStatusTimelineViewControllerTypeNear:
  198. action = @"near";
  199. // if(StrValid(kAppDelegate.currentCity))
  200. // {
  201. // [paramDic setObject:SafeStr(kAppDelegate.strlatitude) forKey:@"lat"];
  202. // [paramDic setObject:SafeStr(kAppDelegate.strlongitude) forKey:@"lng"];
  203. // }
  204. // else
  205. // {
  206. [paramDic setObject:@"" forKey:@"lat"];
  207. [paramDic setObject:@"" forKey:@"lng"];
  208. // }
  209. break;
  210. default:
  211. break;
  212. }
  213. [paramDic setObject:action forKey:@"action"];
  214. [self.player stopCurrentPlayingCell];
  215. // [CYNET POSTDynamic:@"bzone_api" a:@"get_list_3x" parameters:paramDic success:^(id responseObject) {
  216. // if (_page == 1) {
  217. // [_layouts removeAllObjects];
  218. // [self.urls removeAllObjects];
  219. // self.player.assetURLs = nil;
  220. // [self.items removeAllObjects];
  221. // _queue = nil;
  222. // }
  223. // for (NSDictionary *dict in responseObject) {
  224. // WBModel *model = [WBModel mj_objectWithKeyValues:dict];
  225. // WBStatusLayout *layout = [[WBStatusLayout alloc] initWithStatus:model style:WBLayoutStyleTimeline];
  226. // if (layout) {
  227. // [_layouts addObject:layout];
  228. // }
  229. // NSURL *url = [NSURL URLWithString:model.video_url.length ? model.video_url : @""];
  230. // [self.urls addObject:url];
  231. // self.player.assetURLs = self.urls;
  232. //
  233. // AFSoundItem *item = [[AFSoundItem alloc] initWithStreamingURL:[NSURL URLWithString:model.audio_file]];
  234. // [self.items addObject:item];
  235. // }
  236. //
  237. // _queue = [[AFSoundQueue alloc] initWithItems:_items];
  238. //
  239. // self.navigationController.view.userInteractionEnabled = YES;
  240. // [_tableView reloadData];
  241. // if ([(NSArray *)responseObject count]) {
  242. // [_tableView.mj_footer endRefreshing];
  243. // }else{
  244. // [_tableView.mj_footer endRefreshingWithNoMoreData];
  245. // }
  246. // [_tableView.mj_header endRefreshing];
  247. // [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParentEnd" object:nil];
  248. // } failure:^(NSString *error) {
  249. // [[HUDHelper sharedInstance] tipMessage:error];
  250. // [_tableView.mj_header endRefreshing];
  251. // [_tableView.mj_footer endRefreshing];
  252. // [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParentEnd" object:nil];
  253. // }];
  254. }
  255. //
  256. //#pragma mark - UIScrollViewDelegate 列表播放必须实现
  257. //
  258. //- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  259. // [scrollView zf_scrollViewDidEndDecelerating];
  260. //}
  261. //
  262. //- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
  263. // [scrollView zf_scrollViewDidEndDraggingWillDecelerate:decelerate];
  264. //}
  265. //
  266. //- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
  267. // [scrollView zf_scrollViewDidScrollToTop];
  268. //}
  269. //
  270. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  271. // [scrollView zf_scrollViewDidScroll];
  272. // if (self.scrollViewDidScrollBlock) {
  273. // self.scrollViewDidScrollBlock(scrollView);
  274. // }
  275. //}
  276. //
  277. //- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  278. // [scrollView zf_scrollViewWillBeginDragging];
  279. //}
  280. //
  281. //#pragma mark - UITableViewDelegate UITableViewDataSource
  282. //- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  283. // return _layouts.count;
  284. //}
  285. //
  286. //- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  287. // WBStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([WBStatusCell class])];
  288. // cell.delegate = self;
  289. // cell.isShowMore = [self.title isEqualToString:NSLocalizedString(@"我的动态",nil)];
  290. // [cell setLayout:_layouts[indexPath.row]];
  291. // if(self.type==WBStatusTimelineViewControllerTypeUser){
  292. // cell.isfollow=YES;
  293. // }
  294. // return cell;
  295. //}
  296. //
  297. //- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  298. // return ((WBStatusLayout *)_layouts[indexPath.row]).height;
  299. //}
  300. //
  301. //- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
  302. // return NO;
  303. //}
  304. //
  305. //- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  306. //// WBStatusCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  307. //// BogoDynamicDetailViewController *detailVC = [[BogoDynamicDetailViewController alloc]init];
  308. //// detailVC.status = cell.statusView.layout.status;
  309. //// [self.navigationController pushViewController:detailVC animated:YES];
  310. //}
  311. //
  312. //#pragma mark - WBStatusCellDelegate
  313. //// 此处应该用 Router 之类的东西。。。这里只是个Demo,直接全跳网页吧~
  314. //
  315. ///// 点击了 Cell
  316. //- (void)cellDidClick:(WBStatusCell *)cell {
  317. //// BogoDynamicDetailViewController *detailVC = [[BogoDynamicDetailViewController alloc]init];
  318. //// detailVC.status = cell.statusView.layout.status;
  319. //// [self.navigationController pushViewController:detailVC animated:YES];
  320. //}
  321. //
  322. ///// 点击了 Card
  323. //- (void)cellDidClickCard:(WBStatusCell *)cell {
  324. //// WBPageInfo *pageInfo = cell.statusView.layout.status.pageInfo;
  325. //// NSString *url = pageInfo.pageURL; // sinaweibo://... 会跳到 Weibo.app 的。。
  326. //// RootWebViewController *vc = [[RootWebViewController alloc] initWithUrl:url];
  327. //// vc.title = pageInfo.pageTitle;
  328. //// [self.navigationController pushViewController:vc animated:YES];
  329. //}
  330. //
  331. ///// 点击了转发内容
  332. //- (void)cellDidClickRetweet:(WBStatusCell *)cell {
  333. //
  334. //}
  335. //
  336. ///// 点击了 Cell 菜单
  337. //- (void)cellDidClickMenu:(WBStatusCell *)cell {
  338. //
  339. //}
  340. //
  341. ///// 点击了下方 Tag
  342. //- (void)cellDidClickTag:(WBStatusCell *)cell {
  343. //// WBTag *tag = cell.statusView.layout.status.tagStruct.firstObject;
  344. //// NSString *url = tag.tagScheme; // sinaweibo://... 会跳到 Weibo.app 的。。
  345. //// RootWebViewController *vc = [[RootWebViewController alloc] initWithUrl:url];
  346. //// vc.title = tag.tagName;
  347. //// [self.navigationController pushViewController:vc animated:YES];
  348. //}
  349. //
  350. ///// 点击了关注
  351. //- (void)cellDidClickFollow:(WBStatusCell *)cell {
  352. //
  353. //}
  354. //
  355. ///// 点击了转发
  356. //- (void)cellDidClickRepost:(WBStatusCell *)cell {
  357. //
  358. //}
  359. //
  360. //-(void)cell:(WBStatusCell *)cell didClickDeleteBtn:(UIButton *)sender{
  361. // __weak __typeof(self)weakSelf = self;
  362. //
  363. //
  364. // BogoLiveAlertView *alert = [[BogoLiveAlertView alloc]initWithTitle:@"提示" message:@"是否删除此条动态?"];
  365. // [alert addAction:[BogoLiveAlertAction actionWithTitle:@"取消" type:BogoLiveAlertActionTypeCancel CallBack:nil]];
  366. // [alert addAction:[BogoLiveAlertAction actionWithTitle:@"确定" type:BogoLiveAlertActionTypeDefault CallBack:^{
  367. // [CYNET POSTDynamic:@"bzone_api" a:@"del_dynamic" parameters:@{@"zone_id":cell.layout.status.id} success:^(id responseObject) {
  368. // __strong __typeof(weakSelf)strongSelf = weakSelf;
  369. //
  370. // if ([[responseObject valueForKey:@"code"] integerValue] == 1) {
  371. // [MBProgressHUD showInfoMessage:@"删除成功"];
  372. // NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
  373. // [self.layouts removeObject:cell.statusView.layout];
  374. // [self.tableView deleteRow:indexPath.row inSection:0 withRowAnimation:UITableViewRowAnimationAutomatic];
  375. // }
  376. //
  377. // [strongSelf.tableView reloadData];
  378. //
  379. // } failure:^(NSString *error) {
  380. // [[HUDHelper sharedInstance] tipMessage:error];
  381. // }];
  382. // }]];
  383. //
  384. // [alert show:[AppDelegate shareAppDelegate].window];
  385. //
  386. //}
  387. //
  388. //
  389. ///// 点击了评论
  390. //- (void)cellDidClickComment:(WBStatusCell *)cell {
  391. //// BogoDynamicDetailViewController *detailVC = [[BogoDynamicDetailViewController alloc]init];
  392. //// detailVC.status = cell.statusView.layout.status;
  393. //// [self.navigationController pushViewController:detailVC animated:YES];
  394. //}
  395. //
  396. ///// 点击了赞
  397. //- (void)cellDidClickLike:(WBStatusCell *)cell {
  398. // WBModel *status = cell.statusView.layout.status;
  399. //
  400. //// http://test0813.anbig.com/mapi/public/index.php/api/bzone_api/request_like
  401. // [CYNET POSTDynamic:@"bzone_api" a:@"request_like" parameters:@{@"zone_id":cell.statusView.layout.status.id} success:^(id responseObject) {
  402. //
  403. // [cell.statusView.toolbarView setLiked:!status.is_like.intValue withAnimation:YES];
  404. //
  405. // NSMutableArray *tempArray = [NSMutableArray arrayWithArray:cell.statusView.layout.status.like_list];
  406. //
  407. // if (status.is_like.intValue) {
  408. // //点赞加一
  409. // WBLikeListModel *model = [[WBLikeListModel alloc]init];
  410. // model.avatar = curUser.avatar;
  411. // model.id = [IMAPlatform sharedInstance].host.userId;
  412. // [tempArray addObject:model];
  413. // }else{
  414. // //取消点赞减一
  415. // NSInteger index = -1;
  416. // for (NSInteger i = 0; i < tempArray.count ; i++) {
  417. // WBLikeListModel *model = tempArray[i];
  418. // if ([model.id isEqualToString:[IMAPlatform sharedInstance].host.userId]) {
  419. // index = i;
  420. // continue;
  421. // }
  422. // }
  423. // if (index != -1) {
  424. // [tempArray removeObjectAtIndex:index];
  425. // }
  426. // }
  427. // cell.statusView.layout.status.like_list = tempArray;
  428. //// [self.tableView reloadRowAtIndexPath:[self.tableView indexPathForCell:cell] withRowAnimation:UITableViewRowAnimationNone];
  429. // [self.tableView reloadData];
  430. //
  431. //
  432. // } failure:^(NSString *error) {
  433. // [[HUDHelper sharedInstance] tipMessage:error];
  434. // }];
  435. //}
  436. //
  437. ///// 点击了用户
  438. - (void)cell:(WBStatusCell *)cell didClickUser:(WBModel *)user {
  439. // BogoVoiceUserPageViewController *pageVC = [[BogoVoiceUserPageViewController alloc]init];
  440. // pageVC.uid = user.id;
  441. // pageVC.type = BogoVoiceUserPageViewControllerTypeDynamicP;
  442. // pageVC.hidesBottomBarWhenPushed = YES;
  443. // [self.navigationController pushViewController:pageVC animated:YES];
  444. }
  445. //
  446. ///// 点击了图片
  447. //- (void)cell:(WBStatusCell *)cell didClickImageAtIndex:(NSUInteger)index {
  448. // UIView *fromView = nil;
  449. // NSMutableArray *items = [NSMutableArray new];
  450. // WBModel *status = cell.statusView.layout.status;
  451. // NSArray<NSString *> *pics = status.thumbnailPicUrls;
  452. // NSArray<NSString *> *originPics = status.thumbnailPicUrls;
  453. //
  454. // for (NSUInteger i = 0, max = pics.count; i < max; i++) {
  455. // UIView *imgView = cell.statusView.picViews[i];
  456. // YYPhotoGroupItem *item = [YYPhotoGroupItem new];
  457. // item.thumbView = imgView;
  458. // item.largeImageURL = [NSURL URLWithString:originPics[i]];
  459. // item.largeImageSize = CGSizeMake(kScreenW, KScreenHeight);
  460. // [items addObject:item];
  461. // if (i == index) {
  462. // fromView = imgView;
  463. // }
  464. // }
  465. //
  466. //// UIImageView *tempImageView = [[UIImageView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.bounds];
  467. //// [tempImageView sd_setImageWithURL:[NSURL URLWithString:pics[0]]];
  468. //// [[UIApplication sharedApplication].keyWindow addSubview:tempImageView];
  469. //
  470. // YYPhotoGroupView *v = [[YYPhotoGroupView alloc] initWithGroupItems:items];
  471. // [v presentFromImageView:fromView toContainer:[UIApplication sharedApplication].keyWindow animated:YES completion:nil];
  472. //}
  473. //
  474. ///// 点击了 Label 的链接
  475. //- (void)cell:(WBStatusCell *)cell didClickInLabel:(YYLabel *)label textRange:(NSRange)textRange {
  476. // NSAttributedString *text = label.textLayout.text;
  477. // if (textRange.location >= text.length) return;
  478. // YYTextHighlight *highlight = [text attribute:YYTextHighlightAttributeName atIndex:textRange.location];
  479. // NSDictionary *info = highlight.userInfo;
  480. // if (info.count == 0) return;
  481. //
  482. // if (info[kWBLinkTopicName]) {
  483. // NSString *topic = info[kWBLinkTopicName];
  484. // if (topic.length) {
  485. // //话题
  486. // WBStatusTimelineViewController *statusVC = [[WBStatusTimelineViewController alloc]init];
  487. // statusVC.hidesBottomBarWhenPushed = YES;
  488. // statusVC.title = topic;
  489. // statusVC.topic = topic;
  490. // statusVC.type = WBStatusTimelineViewControllerTypeTopic;
  491. // statusVC.tableViewFrame = CGRectMake(0, 0, kScreenW, KScreenHeight - kTopHeight - kTabBarHeight1);
  492. // [self.navigationController pushViewController:statusVC animated:YES];
  493. // }
  494. // return;
  495. // }
  496. //}
  497. //
  498. //- (void)cell:(WBStatusCell *)cell didClickTopic:(NSString *)topic{
  499. // //话题
  500. // WBStatusTimelineViewController *statusVC = [[WBStatusTimelineViewController alloc]init];
  501. // statusVC.hidesBottomBarWhenPushed = YES;
  502. // statusVC.title = topic;
  503. // statusVC.topic = topic;
  504. // statusVC.type = WBStatusTimelineViewControllerTypeTopic;
  505. // statusVC.tableViewFrame = CGRectMake(0, 0, kScreenW, KScreenHeight - kTopHeight - kTabBarHeight1);
  506. // [self.navigationController pushViewController:statusVC animated:YES];
  507. //}
  508. //
  509. //- (void)cell:(WBStatusCell *)cell didClickVideo:(NSString *)url{
  510. // /// 如果正在播放的index和当前点击的index不同,则停止当前播放的index
  511. // if (self.player.playingIndexPath != [self.tableView indexPathForCell:cell]) {
  512. // [self.player stopCurrentPlayingCell];
  513. // }
  514. // AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:url]];
  515. // AVPlayerViewController *playerVC = [[AVPlayerViewController alloc]init];
  516. // playerVC.player = player;
  517. // [playerVC.player play];
  518. // [self presentViewController:playerVC animated:YES completion:nil];
  519. //}
  520. //
  521. //- (void)cell:(WBStatusCell *)cell didClickMore:(UIButton *)sender{
  522. //
  523. // NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"personal_api" A:@"click_attention"];
  524. // NSMutableDictionary *param = [NSMutableDictionary dictionary];
  525. // [param setObject:cell.layout.status.userInfo.id forKey:@"id"];
  526. // [CYNET POST:url parameters:param responseCache:^(id responseObject) {
  527. //
  528. // } success:^(id responseObject) {
  529. // if ([[responseObject valueForKey:@"code"]integerValue] == 1) {
  530. //// sender.hidden = YES;
  531. //
  532. // for (int i = 0; i < _layouts.count; i ++) {
  533. // WBStatusLayout *layout = _layouts[i];
  534. // if ([layout.status.userInfo.id isEqualToString:cell.layout.status.userInfo.id]) {
  535. // layout.status.is_focus = @"1";
  536. // [_layouts replaceObjectAtIndex:i withObject:layout];
  537. // }
  538. // }
  539. // [self.tableView reloadData];
  540. // }
  541. // } failure:^(NSString *error) {
  542. //
  543. // } hasCache:NO];
  544. //
  545. //
  546. //}
  547. //
  548. //- (void)cell:(WBStatusView *)cell didClickAudio:(UIButton *)sender{
  549. // NSInteger index = [self.layouts indexOfObject:cell.layout];
  550. // AFSoundItem *item = [self.items objectAtIndex:index];
  551. // NSLog(@"_queue.status:%ld",_queue.status);
  552. // if (item == [_queue getCurrentItem]) {
  553. // //是原来的item
  554. // if (_queue.status == AFSoundStatusPlaying) {
  555. // [_queue pause];
  556. // _queue.status = AFSoundStatusPaused;
  557. // [cell.audioBtn.imgView stopAnimating];
  558. // }else if (_queue.status == AFSoundStatusPaused){
  559. // [cell.audioBtn.imgView startAnimating];
  560. // [_queue playCurrentItem];
  561. // _queue.status = AFSoundStatusPlaying;
  562. // }else{
  563. // [cell.audioBtn.imgView startAnimating];
  564. // [_queue playItem:item];
  565. // _queue.status = AFSoundStatusPlaying;
  566. // }
  567. // [_queue listenFeedbackUpdatesWithBlock:nil andFinishedBlock:^(AFSoundItem *nextItem) {
  568. // [cell.audioBtn.imgView stopAnimating];
  569. // _queue.status = AFSoundStatusFinished;
  570. // }];
  571. // }else{
  572. // NSInteger currentIndex = [self.items indexOfObject:[_queue getCurrentItem]];
  573. // WBStatusCell *currentCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:currentIndex inSection:0]];
  574. // [currentCell.statusView.audioBtn.imgView stopAnimating];
  575. // //播放的不是之前的那首
  576. // [_queue playItem:(AFSoundItem *)_items[index]];
  577. // _queue.status = AFSoundStatusPlaying;
  578. // [cell.audioBtn.imgView startAnimating];
  579. // [_queue listenFeedbackUpdatesWithBlock:nil andFinishedBlock:^(AFSoundItem *nextItem) {
  580. // [cell.audioBtn.imgView stopAnimating];
  581. // }];
  582. // }
  583. //}
  584. //
  585. //#pragma mark - private method
  586. //
  587. ///// play the video
  588. //- (void)playTheVideoAtIndexPath:(NSIndexPath *)indexPath scrollToTop:(BOOL)scrollToTop {
  589. // [self.player playTheIndexPath:indexPath scrollToTop:scrollToTop];
  590. // [self.controlView showTitle:@""
  591. // coverURLString:@""
  592. // fullScreenMode:ZFFullScreenModePortrait];
  593. //}
  594. //
  595. //#pragma mark - Lazy Load
  596. //- (UIButton *)releaseBtn{
  597. // if (!_releaseBtn) {
  598. // _releaseBtn = [[UIButton alloc]initWithFrame:CGRectMake(kScreenW - 44, kStatusBarHeight, 44, 44)];
  599. // [_releaseBtn setImage:[UIImage imageNamed:@"发布_icon"] forState:UIControlStateNormal];
  600. // [_releaseBtn addTarget:self action:@selector(releaseBtnAction) forControlEvents:UIControlEventTouchUpInside];
  601. // }
  602. // return _releaseBtn;
  603. //}
  604. //
  605. //- (UIImage *)xy_noDataViewImage {
  606. // if (self.tableView.height) {
  607. // return [UIImage imageNamed:@"暂无数据_New"];
  608. // }
  609. // return nil;
  610. //}
  611. //
  612. //- (NSString *)xy_noDataViewMessage {
  613. // if (self.tableView.height) {
  614. // return NSLocalizedString(@"亲,暂时没有任何内容哦~",nil);
  615. // }
  616. // return @"";
  617. //}
  618. //
  619. //- (QMUIPopupMenuView *)popViewWithCell:(WBStatusCell *)cell{
  620. // if (!_popView) {
  621. // // 使用方法 2,以 UIWindow 的形式显示到界面上,这种无需默认隐藏,也无需 add 到某个 UIView 上
  622. // _popView = [[QMUIPopupMenuView alloc] init];
  623. // _popView.automaticallyHidesWhenUserTap = YES;// 点击空白地方消失浮层
  624. // _popView.maskViewBackgroundColor = [kBlackColor colorWithAlphaComponent:0.3];// 使用方法 2 并且打开了 automaticallyHidesWhenUserTap 的情况下,可以修改背景遮罩的颜色
  625. // _popView.shouldShowItemSeparator = YES;
  626. // _popView.itemTitleColor = [UIColor colorWithHexString:@"333333"];
  627. // _popView.itemSeparatorColor = [UIColor colorWithHexString:@"F2F2F2"];
  628. // _popView.itemConfigurationHandler = ^(QMUIPopupMenuView *aMenuView, QMUIPopupMenuButtonItem *aItem, NSInteger section, NSInteger index) {
  629. // // 利用 itemConfigurationHandler 批量设置所有 item 的样式
  630. //
  631. // };
  632. // __weak __typeof(self)weakSelf = self;
  633. // _popView.items = @[[QMUIPopupMenuButtonItem itemWithImage:[UIImageMake(@"icon_tabbar_component") imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] title:NSLocalizedString(@"删除",nil) handler:^(QMUIPopupMenuButtonItem *aItem) {
  634. // __strong __typeof(weakSelf)strongSelf = weakSelf;
  635. // [aItem.menuView hideWithAnimated:YES];
  636. //// http://test0813.anbig.com/mapi/public/index.php/api/bzone_api/del_dynamic
  637. // [CYNET POSTDynamic:@"bzone_api" a:@"del_dynamic" parameters:@{@"zone_id":cell.statusView.layout.status.id} success:^(id responseObject) {
  638. // NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
  639. // [self.layouts removeObject:cell.statusView.layout];
  640. // [self.tableView deleteRow:indexPath.row inSection:0 withRowAnimation:UITableViewRowAnimationAutomatic];
  641. // } failure:^(NSString *error) {
  642. // [[HUDHelper sharedInstance] tipMessage:error];
  643. // }];
  644. // }]];
  645. // _popView.didHideBlock = ^(BOOL hidesByUserTap) {
  646. //
  647. // };
  648. // }
  649. // return _popView;
  650. //}
  651. //
  652. //- (WBStatusVideoControlView *)controlView {
  653. // if (!_controlView) {
  654. // _controlView = [WBStatusVideoControlView new];
  655. // _controlView.fastViewAnimated = YES;
  656. // _controlView.horizontalPanShowControlView = NO;
  657. // _controlView.prepareShowLoading = YES;
  658. // }
  659. // return _controlView;
  660. //}
  661. //
  662. //#pragma mark - JXPagingViewListViewDelegate
  663. //- (UIView *)listView{
  664. // return self.view;
  665. //}
  666. //
  667. //- (UIScrollView *)listScrollView{
  668. // return self.tableView;
  669. //}
  670. //
  671. //- (void)listViewDidScrollCallbackWithCallback:(void (^)(UIScrollView * _Nonnull))callback{
  672. // self.scrollViewDidScrollBlock = callback;
  673. //}
  674. //
  675. //- (NSMutableArray *)items{
  676. // if (!_items) {
  677. // _items = [NSMutableArray array];
  678. // }
  679. // return _items;
  680. //}
  681. @end