| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818 |
- //
- // YHQAListController.m
- // github: https://github.com/samuelandkevin
- //
- // Created by samuelandkevin on 16/8/29.
- // Copyright © 2016年 HKP. All rights reserved.
- //
- #import "YHTimeLineListController.h"
- #import "CellForWorkGroup.h"
- #import "CellForWorkGroupRepost.h"
- #import "YHRefreshTableView.h"
- #import "YHWorkGroup.h"
- #import "YHUserInfoManager.h"
- //#import "YHUtils.h"
- #import "YHSharePresentView.h"
- #import "UITableViewCell+HYBMasonryAutoCellHeight.h"
- //#import "XWPublishController.h"
- #import "DetailsLineViewController.h"
- #import <CLPlayer/CLPlayerView.h>
- #import "YHPlayerViewController.h"
- #import "ReleaseDynamicVC.h"
- #import "BGTopicTimeLineListController.h"
- #import "MGNewDTNearByViewController.h"//附近的人
- @interface YHTimeLineListController ()<UITableViewDelegate,UITableViewDataSource,CellForWorkGroupDelegate,CellForWorkGroupRepostDelegate,BzoneLogicDelegate>{
- int _currentRequestPage; //当前请求页面
- BOOL _reCalculate;
- }
- //@property (nonatomic,strong) UITableView *tableView;
- @property (nonatomic, strong) UIButton *rightBtn;
- @property (nonatomic,strong) NSMutableArray *dataArray;
- @property (nonatomic,strong) NSMutableDictionary *heightDict;
- @property (nonatomic, strong) BzoneLogic *logic;
- @property (nonatomic, strong) CellForWorkGroup *c_cell;
- @property (nonatomic, strong) CLPlayerView *playerView;
- @property(nonatomic, assign) CGFloat scrollOffset;
- @property(nonatomic, strong) UIView *tableHeadView;
- @end
- @implementation YHTimeLineListController
- -(instancetype)initWithIndexAct:(MGDTHOMETYPE)act withUID:(NSString *)toUid{
- YHTimeLineListController *vc = [YHTimeLineListController new];
- vc.homeType = act;
- vc.toUid = toUid;
- return vc;
- }
- - (void)viewDidLoad{
- [super viewDidLoad];
- [self initUI];
- self.logic = [BzoneLogic new];
- self.logic.page = 1;
- _logic.delegagte = self;
- _logic.to_uid = self.toUid;
- _logic.isGZ = YES;
-
- // [self requestDataLoadNew:YES];
- //设置UserId
- [YHUserInfoManager sharedInstance].userInfo.uid = @"1";
- }
- - (void)initUI{
- self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH - kTabBarHeight - 64 - 49) style:UITableViewStylePlain];
- self.tableView.tag = 1107;
- if (isIPhoneX()) {
- self.tableView.height = kScreenH - 49 - 64 - 20;
- }
-
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
-
- NSLog(@"%f",kTabBarHeight);
- NSLog(@"%f",kNavigationBarHeight);
-
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- self.tableView.backgroundColor = RGBCOLOR(244, 244, 244);
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-
- [self.view addSubview:self.tableView];
-
- // [self.tableView setEnableLoadNew:YES];
- // [self.tableView setEnableLoadMore:YES];
-
- self.view.backgroundColor = UIColor.clearColor;
-
- [self.tableView registerClass:[CellForWorkGroup class] forCellReuseIdentifier:NSStringFromClass([CellForWorkGroup class])];
- [self.tableView registerClass:[CellForWorkGroupRepost class] forCellReuseIdentifier:NSStringFromClass([CellForWorkGroupRepost class])];
-
- self.rightBtn = [[UIButton alloc] init];
- self.rightBtn.frame = CGRectMake(kScreenW - 50 - 15, kScreenH - kNavigationBarHeight - kTabBarHeight - 50 - 25, 50, 50);
- // search.imageEdgeInsets = UIEdgeInsetsMake(6, 6, 6, 6);
- [self.rightBtn setImage:[UIImage imageNamed:@"mg_dy_publish"] forState:UIControlStateNormal];
- [self.rightBtn addTarget:self action:@selector(handleSearchEvent) forControlEvents:UIControlEventTouchUpInside];
-
- [BGMJRefreshManager refresh:self.tableView target:self headerRereshAction:@selector(refreshHeader) footerRereshAction:@selector(refreshFooter)];
-
- [self.view addSubview:self.rightBtn];
- }
- -(void)refreshHeader{
- [self resetHeadView];
- [self requestDataLoadNew:YES];
- }
- -(void)refreshFooter{
- [self requestDataLoadNew:NO];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- [self requestDataLoadNew:YES];
- // [self.logic loadListDataWithAct:self.homeType];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-
- [_playerView destroyPlayer];
- _c_cell =nil;
- }
- -(void)reloadDynamicData{
- BzoneLogic *logic = [BzoneLogic new];
- logic.delegagte = self;
- [logic loadListDataWithAct:self.homeType];
- }
- //发布动态
- - (void)handleSearchEvent
- {
- // XWPublishController *pushVC = [XWPublishController new];
- ReleaseDynamicVC *pushVC = [ReleaseDynamicVC new];
- __weak __typeof(self)weakSelf = self;
- pushVC.postFinishBlock = ^(BOOL isFinish) {
- if (isFinish) {
- if (weakSelf.timeLineDelegate && [weakSelf.timeLineDelegate respondsToSelector:@selector(reloadDynamicData)]) {
- [weakSelf.timeLineDelegate reloadDynamicData];
- }
- // [weakSelf.logic loadListDataWithAct:self.homeType];
- }
- };
- [[AppDelegate sharedAppDelegate]presentViewController:pushVC animated:YES completion:nil];
- // [self presentViewController:pushVC animated:YES completion:nil];
- }
- #pragma mark - Lazy Load
- - (NSMutableArray *)dataArray{
- if (!_dataArray) {
- _dataArray = [NSMutableArray array];
- }
- return _dataArray;
- }
- - (NSMutableDictionary *)heightDict{
- if (!_heightDict) {
- _heightDict = [NSMutableDictionary new];
- }
- return _heightDict;
- }
- #pragma mark - UITableViewDataSource
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataArray.count;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- return self.tableHeadView;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return _homeType == MGDTHOMETYPE_NEARBY ? kRealValue(80) :0;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if (self.dataArray.count < 1) {
- return [UITableViewCell new];
- }
-
- MGGroupUserInfo *model = self.dataArray[indexPath.row];
-
- //原创cell
- CellForWorkGroup *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([CellForWorkGroup class])];
- if (!cell) {
- cell = [[CellForWorkGroup alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([CellForWorkGroup class])];
- }
-
- cell.homeType = self.homeType;
- cell.indexPath = indexPath;
- cell.model = model;
- cell.delegate = self;
- return cell;
- }
- #pragma mark - UITableViewDelegate
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if (indexPath.row < self.dataArray.count) {
-
- CGFloat height = 0.0;
- //原创cell
- Class currentClass = [CellForWorkGroup class];
- MGGroupUserInfo *model = self.dataArray[indexPath.row];
-
- //取缓存高度
- NSDictionary *dict = self.heightDict[model.id];
- if (dict) {
- if (model.isOpening) {
- height = [dict[@"open"] floatValue];
- }else{
- height = [dict[@"normal"] floatValue];
- }
- if (height) {
- return height;
- }
- }
-
- height = [CellForWorkGroup hyb_heightForTableView:tableView config:^(UITableViewCell *sourceCell) {
- CellForWorkGroup *cell = (CellForWorkGroup *)sourceCell;
-
- cell.model = model;
-
- }];
-
- if (model.cover_url && ![model.cover_url isEqualToString:@""])
- {
- // height += 74;
- }
- // }
-
- //缓存高度
- if (model.id) {
- NSMutableDictionary *aDict = [NSMutableDictionary new];
- if (model.isOpening) {
- [aDict setObject:@(height) forKey:@"open"];
- }else{
- [aDict setObject:@(height) forKey:@"normal"];
- }
- [self.heightDict setObject:aDict forKey:model.id];
- }
- return height;
- }
- else{
- return 44.0f;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- self.hidesBottomBarWhenPushed = YES;
-
- if (self.dataArray.count > 0) {
- MGGroupUserInfo *model = self.dataArray[indexPath.row];
- DetailsLineViewController *datails = [DetailsLineViewController new];
- datails.title = ASLocalizedString(@"动态详情");
- datails.model = model;
-
- datails.refreshData = ^{
-
- [self refreshHeader];
-
- };
-
- [[AppDelegate sharedAppDelegate] pushViewController:datails animated:YES];
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- [AppDelegate sharedAppDelegate].topViewController.hidesBottomBarWhenPushed = YES;
- }
- }
- -(void)tableView:(UITableView *)tableView willDisplayCell:(CellForWorkGroup *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.dataArray.count < 1) {
- return;
- }
- MGGroupUserInfo *model = self.dataArray[indexPath.row];
- if (model.cover_url && ![model.cover_url isEqualToString:@""] && indexPath.row == 0){
- //原创cell
- [self onTouchActionVideo:cell withFullScreen:NO];
- }
- }
- - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
-
- if (self.dataArray.count > 0) {
- NSArray *cellArr = self.tableView.visibleCells;
-
- CellForWorkGroup *cell;
-
- if (self.scrollOffset - scrollView.contentOffset.y > 0) {
- cell = cellArr.firstObject;
- }else{
- cell = cellArr.lastObject;
- }
-
- if (cellArr.count == 3) {//当可见视图有三个cell时,展示中间那个。
- cell = [cellArr objectAtIndex:1];
- }
-
- self.scrollOffset = scrollView.contentOffset.y;
-
- if (self.scrollOffset == 0) cell = cellArr.firstObject;//下拉刷新时展示第一个
-
- if (_c_cell != cell) {
- _c_cell = cell;
- [self onTouchActionVideo:cell withFullScreen:NO];
- }
- }
-
- // MGGroupUserInfo *model = self.dataArray[indexPath.row];
-
- if (self.vDelegate && [self.vDelegate respondsToSelector:@selector(didDynamicCollectionViewScrollView:)]) {
- [self.vDelegate didDynamicCollectionViewScrollView:scrollView];
- return;
- }
-
- CGFloat sectionHeaderHeight = self.tableHeadView.height + kTopHeight;
- if(scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
- scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
- } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
- scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
- }
-
- if(self.timeLineDelegate && [self.timeLineDelegate respondsToSelector:@selector(protocolTimeLineDidScrollView:offset:)])
- {
- [self.timeLineDelegate protocolTimeLineDidScrollView:scrollView offset:scrollView.contentOffset.y];
- }
- }
- #pragma mark - 网络请求
- - (void)requestDataLoadNew:(BOOL)loadNew{
- YHRefreshType refreshType;
- if (loadNew) {
- _currentRequestPage = 1;
- refreshType = YHRefreshType_LoadNew;
- }
- else{
- _currentRequestPage ++;
- refreshType = YHRefreshType_LoadMore;
- }
-
- if (loadNew) {
- [self.dataArray removeAllObjects];
- [self.heightDict removeAllObjects];
- }
-
- _logic.page = _currentRequestPage;
-
- int totalCount = 10;
-
- NSUInteger lastDynamicID = 0;
- if (!loadNew && self.dataArray.count) {
- MGGroupUserInfo *model = self.dataArray.lastObject;
- lastDynamicID = [model.id integerValue];
- }
-
-
-
- [_logic loadListDataWithAct:self.homeType];
-
- // [BGMJRefreshManager endRefresh:self.tableView];
-
- // [self.tableView reloadData];
- }
- -(void)requestZoneListDataCompleted
- {
-
- [self.tableView.mj_footer endRefreshing];
- [self.tableView.mj_header endRefreshing];
-
-
- self.dataArray = _logic.dataArray;
- if(_logic.noHasMore == YES)
- {
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- }
-
- if (self.dataArray.count < 1)
- {
- [self showNoContentView];
- self.noContentView.top = kRealValue(120);
- }else
- {
- [self hideNoContentView];
- }
-
- if (kIsCheckingVersion())
- {
- [self.dataArray removeAllObjects];
- }
-
- [self.tableView reloadData];
-
- // [BGMJRefreshManager endRefresh:self.tableView];
- }
- #pragma mark - 模拟产生数据源
- - (void)randomModel:(MGGroupUserInfo *)model totalCount:(int)totalCount{
-
- model.type = arc4random()%totalCount %2? DynType_Forward:DynType_Original;//动态类型
- if (model.type == DynType_Forward) {
- model.forwardModel = [MGGroupUserInfo new];
- [self creatOriModel:model.forwardModel totalCount:totalCount];
- }
- [self creatOriModel:model totalCount:totalCount];
-
- }
- - (void)creatOriModel:(MGGroupUserInfo *)model totalCount:(int)totalCount{
- }
- #pragma mark - YHRefreshTableViewDelegate
- - (void)refreshTableViewLoadNew:(YHRefreshTableView*)view{
- // [self requestDataLoadNew:YES];
- }
- - (void)refreshTableViewLoadmore:(YHRefreshTableView*)view{
- // [self requestDataLoadNew:NO];
- }
- #pragma mark - CellForWorkGroupDelegate
- - (void)onAvatarInCell:(CellForWorkGroup *)cell{
- SHomePageVC *tmpController= [[SHomePageVC alloc]init];
- tmpController.user_id = cell.model.uid;
- tmpController.type = 0;
- [[AppDelegate sharedAppDelegate]pushViewController:tmpController animated:YES];
- }
- - (void)onMoreInCell:(CellForWorkGroup *)cell{
- if (cell.indexPath.row < [self.dataArray count]) {
- YHWorkGroup *model = self.dataArray[cell.indexPath.row];
- model.isOpening = !model.isOpening;
- [self.tableView reloadRowsAtIndexPaths:@[cell.indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- }
- - (void)onCommentInCell:(CellForWorkGroup *)cell{
- MGGroupUserInfo *model = self.dataArray[cell.indexPath.row];
-
- // self.hidesBottomBarWhenPushed = YES;
-
- DetailsLineViewController *datails = [DetailsLineViewController new];
- datails.hidesBottomBarWhenPushed = YES;
- datails.title = ASLocalizedString(@"动态详情");
- datails.model = model;
-
- datails.refreshData = ^{
- [self refreshHeader];
- };
- [self.navigationController pushViewController:datails animated:YES];
-
- self.hidesBottomBarWhenPushed = NO;
- }
- - (void)onLikeInCell:(CellForWorkGroup *)cell{
-
- __weak __typeof(self)weakSelf = self;
- MGGroupUserInfo *model = self.dataArray[cell.indexPath.row];
-
- BOOL isLike = ![model.is_like isEqualToString:@"1"];
-
- [self.logic addDolikeID:cell.model.id isLike:isLike Success:^(id _Nonnull selfPtr, BOOL isFinished) {
- if (cell.indexPath.row < [self.dataArray count]) {
- MGGroupUserInfo *model = weakSelf.dataArray[cell.indexPath.row];
-
- // BOOL isLike = [model.is_like isEqualToString:@"1"];
-
- NSInteger praise = [model.praise integerValue];
-
- if (isFinished) {//此处取反
- praise += 1;
- model.is_like = @"1";
- }else{
- praise -= 1;
- model.is_like = @"0";
- }
- //
- model.praise = [NSString stringWithFormat:@"%ld",praise];
- cell.model = model;
- [weakSelf.dataArray replaceObjectAtIndex:cell.indexPath.row withObject:model];
-
- // [cell.liksBtn setImage:[UIImage imageNamed:[model.is_like isEqualToString:@"1"] ? @"mg_dy_likes_select" : @"mg_dy_like"] forState:UIControlStateNormal];
- // [cell.liksBtn setTitleColor:[UIColor colorWithHexString:[model.is_like isEqualToString:@"1"] ? @"#FF268E" : @"#999999"] forState:UIControlStateNormal];
- // [weakSelf.tableView reloadRowsAtIndexPaths:@[cell.indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }
- }];
- }
- - (void)onShareInCell:(CellForWorkGroup *)cell{
- if (cell.indexPath.row < [self.dataArray count]){
- [self _shareWithCell:cell];
- }
- }
- - (void)onDeleteInCell:(CellForWorkGroup *)cell{
- if (cell.indexPath.row < [self.dataArray count]) {
- [self _deleteDynAtIndexPath:cell.indexPath dynamicId:cell.model.id cell:cell];
- }
- }
- - (void)onTopicInCell:(CellForWorkGroup *)cell{
- if (cell.indexPath.row < [self.dataArray count]) {
- BGTopicTimeLineListController *pushVC = [BGTopicTimeLineListController new];
- MGDynamicTopicModel *topic = [MGDynamicTopicModel new];
- topic.t_id = cell.model.theme_id;
- topic.name = cell.model.theme;
- pushVC.topic = topic;
- [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
- }
- }
- - (void)onFollowInCell:(CellForWorkGroup *)cell{
- if (cell.indexPath.row < [self.dataArray count]) {
- FWWeakify(self)
- [self.logic addFollowUID:cell.model.uid Success:^(NSDictionary * _Nonnull dic) {
-
- NSInteger _has_focus = [dic toInt:@"has_focus"];
- if (_has_focus == 1) {
- // [FanweMessage alertHUD:@""]
- // [FanweMessage alert:ASLocalizedString(@"关注成功")];
- }
-
- //刷新数据
- FWStrongify(self)
- _currentRequestPage = 1;
-
- self.logic.page = _currentRequestPage;
-
- [self.logic loadListDataWithAct:self.homeType];
-
- }];
-
- }
- }
- - (void)onTouchActionVideo:(CellForWorkGroup *)cell withFullScreen:(BOOL)fullScreen
- {
- if (fullScreen) {
-
- YHPlayerViewController *vc = [[YHPlayerViewController alloc]initWithPlayerURL:cell.model.video];
- [[AppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
- return;
- }
-
- _c_cell =cell;
- [_playerView destroyPlayer];
- _playerView =nil;
- _playerView = [[CLPlayerView alloc] initWithFrame:CGRectMake(0, 0, cell.ClVideoview.width, cell.ClVideoview.height)];
- _playerView.backgroundColor = kClearColor;
- _playerView.layer.cornerRadius = 4;
- _playerView.layer.masksToBounds = YES;
- _playerView.maskView.playButton.hidden = YES;
-
- // CLPlayerViewConfigure *config = [CLPlayerViewConfigure defaultConfigure];
- // config.mute = YES;
- _playerView.configure.mute = YES;
- _playerView.configure.repeatPlay = YES;
- _playerView.isFullScreen = fullScreen;
- _playerView.configure.mute = !fullScreen;
- _playerView.configure.isLandscape = YES;
- _playerView.configure.videoFillMode = VideoFillModeResizeAspectFill;
-
- [_playerView updateWithConfigure:^(CLPlayerViewConfigure *configure) {
- if (fullScreen) {
- _playerView.frame = CGRectMake(0, 0, kScreenW, kScreenH);
- [self.tabBarController.view addSubview:_playerView];
- UITapGestureRecognizer *tapPlayerView = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapPlayerView:)];
- [_playerView.maskView addGestureRecognizer:tapPlayerView];
- }else{
- [cell.ClVideoview addSubview:_playerView];
- UITapGestureRecognizer *tapPlayerView = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapBigScreen:)];
- [_playerView.maskView addGestureRecognizer:tapPlayerView];
- }
- _playerView.url =[NSURL URLWithString:cell.model.video];
- //播放
- [_playerView playVideo];
- }];
-
-
- //返回按钮点击事件回调
- [_playerView backButton:^(UIButton *button) {
- NSLog(ASLocalizedString(@"返回按钮被点击"));
- }];
-
- //播放完成回调
- [_playerView endPlay:^{
- // //销毁播放器
- // [_playerView destroyPlayer];
- // _playerView = nil;
- // NSLog(ASLocalizedString(@"播放完成"));
- }];
- }
- -(void)tapPlayerView:(UITapGestureRecognizer *)sender{
- [self onTouchActionVideo:_c_cell withFullScreen:NO];
- }
- -(void)tapBigScreen:(UITapGestureRecognizer *)sender{
- [self onTouchActionVideo:_c_cell withFullScreen:YES];
- }
- #pragma mark - CellForWorkGroupRepostDelegate
- - (void)onAvatarInRepostCell:(CellForWorkGroupRepost *)cell{
-
- }
- - (void)onTapRepostViewInCell:(CellForWorkGroupRepost *)cell{
-
- }
- - (void)onCommentInRepostCell:(CellForWorkGroupRepost *)cell{
-
- }
- //附近--点击去看看
- -(void)cliclSeeBtn:(UIButton *)sender{
-
-
- if (kIsCheckingVersion())
- {
- return;
- }
- MGNewDTNearByViewController *pushVC = [[MGNewDTNearByViewController alloc]initWithType:MGNEWDTTYPE_NEAR_PEOPLE];
- [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
- }
- - (void)onLikeInRepostCell:(CellForWorkGroupRepost *)cell{
-
- if (cell.indexPath.row < [self.dataArray count]) {
- YHWorkGroup *model = self.dataArray[cell.indexPath.row];
-
- BOOL isLike = !model.isLike;
- //更新本地数据源
- model.isLike = isLike;
- if (isLike) {
- model.likeCount += 1;
- }else{
- model.likeCount -= 1;
- }
- [self.tableView reloadRowsAtIndexPaths:@[cell.indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }
-
- }
- - (void)onShareInRepostCell:(CellForWorkGroupRepost *)cell{
-
- // if (cell.indexPath.row < [self.dataArray count]){
- // [self _shareWithCell:cell];
- // }
- }
- - (void)onDeleteInRepostCell:(CellForWorkGroup *)cell{
- if (cell.indexPath.row < [self.dataArray count]) {
- [self _deleteDynAtIndexPath:cell.indexPath dynamicId:cell.model.id cell:cell];
- }
- }
- - (void)onMoreInRespostCell:(CellForWorkGroupRepost *)cell{
- if (cell.indexPath.row < [self.dataArray count]) {
- YHWorkGroup *model = self.dataArray[cell.indexPath.row];
- model.isOpening = !model.isOpening;
- [self.tableView reloadRowsAtIndexPaths:@[cell.indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- }
- #pragma mark - private
- - (void)_deleteDynAtIndexPath:(NSIndexPath *)indexPath dynamicId:(NSString *)dynamicId cell:(CellForWorkGroup *)cell{
-
- __weak __typeof(self)weakSelf = self;
-
- // [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"确定删除该动态?")destructiveAction:^{
- [weakSelf.logic delZone:dynamicId Success:^{
- [weakSelf.logic loadListDataWithAct:self.homeType];
- [FanweMessage alertHUD:ASLocalizedString(@"删除成功")];
- }];
- // } cancelAction:^{
- //
- // }];
- }
- - (void)_shareWithCell:(CellForWorkGroup *)cell{
- __weak __typeof(self)weakSelf = self;
- [_logic dynamicForwardWithDynamic_id:cell.model.id Success:^{
- cell.model.bottomViewSelect = YES;
- cell.bottomView.hidden = YES;
- [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"转发成功")];
- [weakSelf.logic loadListDataWithAct:self.homeType];
- }];
- }
- #pragma mark - UIScrollViewDelegate
- -(UIView *)tableHeadView{
- if (!_tableHeadView) {
- _tableHeadView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(80))];
- _tableHeadView.backgroundColor = kWhiteColor;
- UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(kRealValue(10), 0, kScreenW - kRealValue(10 * 2), kRealValue(80))];
- imgView.image = [UIImage imageNamed:@"dy_newby_people_bgimg"];
- imgView.userInteractionEnabled = YES;
-
- UILabel *titleL = [[UILabel alloc]initWithFrame:CGRectMake(kRealValue(28), kRealValue(12), kRealValue(100), kRealValue(20))];
- titleL.text = ASLocalizedString(@"附近的人");
- titleL.font = [UIFont systemFontOfSize:15];
- titleL.textColor = kBlackColor;
-
- UIButton *toSeeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- toSeeBtn.frame = CGRectMake(kRealValue(25), titleL.bottom + kRealValue(5), kRealValue(64), kRealValue(29));
- [toSeeBtn setBackgroundImage:[UIImage imageNamed:@"dy_newby_people_tosee"] forState:UIControlStateNormal];
- [toSeeBtn setTitle:ASLocalizedString(@"去看看")forState:UIControlStateNormal];
- [toSeeBtn addTarget:self action:@selector(cliclSeeBtn:) forControlEvents:UIControlEventTouchUpInside];
- toSeeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
-
-
-
- [imgView addSubview:titleL];
- [imgView addSubview:toSeeBtn];
- [_tableHeadView addSubview:imgView];
- for (int i = 0; i < 3; i ++ ) {
- UIImageView *headImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kRealValue(240) + kRealValue(30) * i, 0, kRealValue(40), kRealValue(40))];
- headImgView.tag = 100 + i;
- headImgView.centerY = imgView.height / 2;
- headImgView.layer.masksToBounds = YES;
- headImgView.layer.cornerRadius = kRealValue(40 / 2);
- headImgView.backgroundColor = kClearColor;
- [_tableHeadView addSubview:headImgView];
- }
-
-
-
- }
- return _tableHeadView;
- }
- -(void)resetHeadView{
- //附近的人
- if (self.homeType == MGDTHOMETYPE_NEARBY) {
-
- if (kIsCheckingVersion())
- {
- return;
- }
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"dynamic" forKey:@"ctl"];
- [parmDict setObject:@"fujin_user" forKey:@"act"];
-
- [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
- if ([[responseJson valueForKey:@"status"] integerValue] == 1) {
- NSArray *arr = responseJson[@"data"];
- [self resetTableHeadViewWithArr:arr];
- }else{
-
- }
- } FailureBlock:^(NSError *error) {
- }];
- }
- }
- -(void)resetTableHeadViewWithArr:(NSArray *)arr{
- if (arr.count > 0)
- {
- for ( int i = 0; i < arr.count; i++) {
- NSDictionary *dic = arr[i];
- MGNewDTNearlistModel *model = [MGNewDTNearlistModel modelWithDictionary:dic];
- UIImageView *imgView = [_tableHeadView viewWithTag:100 + i];
- [imgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:nil];
-
- }
- }
-
- }
- @end
|