Commit ed7a62724dab39dc31114b41c1c316321fb7662f
1 parent
64362e47
0.0.3修改外部数据传输失败
Showing
6 changed files
with
60 additions
and
34 deletions
CNLiveWitnessVideoModule.podspec
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | Pod::Spec.new do |s| | 9 | Pod::Spec.new do |s| |
| 10 | s.name = 'CNLiveWitnessVideoModule' | 10 | s.name = 'CNLiveWitnessVideoModule' |
| 11 | - s.version = '0.0.2' | 11 | + s.version = '0.0.3' |
| 12 | s.summary = '目击者视频播放功能' | 12 | s.summary = '目击者视频播放功能' |
| 13 | 13 | ||
| 14 | # This description is used to generate tags and improve search results. | 14 | # This description is used to generate tags and improve search results. |
CNLiveWitnessVideoModule/Classes/Controller/CNBWitnessListController.m
| @@ -56,23 +56,42 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; | @@ -56,23 +56,42 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; | ||
| 56 | if (self = [super init]) { | 56 | if (self = [super init]) { |
| 57 | _dataSource = [NSMutableArray array]; | 57 | _dataSource = [NSMutableArray array]; |
| 58 | _type = type; | 58 | _type = type; |
| 59 | - _isHaveNext = @"1"; | ||
| 60 | - _pageIndex = pageNum + 1; | ||
| 61 | - NSArray *list = data[@"witnessBeans"]; | ||
| 62 | - if ([type isEqualToString:@"0"]) { | ||
| 63 | - _pageSize = 10; | ||
| 64 | - _currentPlayIndex = currentIndex; | ||
| 65 | - for (NSDictionary *dic in list) { | ||
| 66 | - CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic]; | ||
| 67 | - [_dataSource addObject:witnessModel]; | 59 | + _pageSize = 10; |
| 60 | + if (data && [data isKindOfClass:[NSDictionary class]] && data.count > 0) { //如果上一个页面传的有数据,且数据上传证据 | ||
| 61 | + if ([[data allKeys] containsObject:@"witnessBeans"] && data[@"witnessBeans"] && [data[@"witnessBeans"] isKindOfClass:[NSArray class]]) { | ||
| 62 | + NSArray *list = data[@"witnessBeans"]; | ||
| 63 | + if (list.count > 0) { | ||
| 64 | + | ||
| 65 | + if ([type isEqualToString:@"0"]) { | ||
| 66 | + if (currentIndex > list.count) { | ||
| 67 | + _currentPlayIndex = 0; | ||
| 68 | + }else { | ||
| 69 | + _currentPlayIndex = currentIndex; | ||
| 70 | + } | ||
| 71 | + for (NSDictionary *dic in list) { | ||
| 72 | + CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic]; | ||
| 73 | + [_dataSource addObject:witnessModel]; | ||
| 74 | + } | ||
| 75 | + }else { | ||
| 76 | + NSDictionary *dic = list[currentIndex]; | ||
| 77 | + CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic]; | ||
| 78 | + [_dataSource addObject:witnessModel]; | ||
| 79 | + _currentPlayIndex = 0; | ||
| 80 | + } | ||
| 81 | + _pageIndex = pageNum + 1; | ||
| 82 | + _isHaveNext = @"1"; | ||
| 83 | + }else { | ||
| 84 | + _isRefreshHeader = YES; | ||
| 85 | + _pageIndex = pageNum; | ||
| 86 | + } | ||
| 87 | + }else { | ||
| 88 | + _isRefreshHeader = YES; | ||
| 89 | + _pageIndex = pageNum; | ||
| 68 | } | 90 | } |
| 69 | }else { | 91 | }else { |
| 70 | - NSDictionary *dic = list[currentIndex]; | ||
| 71 | - CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic]; | ||
| 72 | - [_dataSource addObject:witnessModel]; | ||
| 73 | - _currentPlayIndex = 0; | 92 | + _isRefreshHeader = YES; |
| 93 | + _pageIndex = pageNum; | ||
| 74 | } | 94 | } |
| 75 | - | ||
| 76 | } | 95 | } |
| 77 | return self; | 96 | return self; |
| 78 | } | 97 | } |
| @@ -95,28 +114,29 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; | @@ -95,28 +114,29 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; | ||
| 95 | } | 114 | } |
| 96 | - (void)viewDidLoad { | 115 | - (void)viewDidLoad { |
| 97 | [super viewDidLoad]; | 116 | [super viewDidLoad]; |
| 98 | - if (self.dataSource.count > 0) { | ||
| 99 | - if ([self.type isEqualToString:@"0"]) { | ||
| 100 | - self.toSid = ((CNBWitnessListModel *)[self.dataSource objectAtIndex:self.currentPlayIndex]).icon.sid; | ||
| 101 | - }else { | ||
| 102 | - self.toSid = ((CNBWitnessListModel *)self.dataSource[self.currentPlayIndex]).contentSid; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - } | ||
| 106 | [self setLeftButton]; | 117 | [self setLeftButton]; |
| 107 | [self setBackgroundImage]; | 118 | [self setBackgroundImage]; |
| 108 | [self.view addSubview:self.tableView]; | 119 | [self.view addSubview:self.tableView]; |
| 109 | _isLightContentStatusBar = YES; | 120 | _isLightContentStatusBar = YES; |
| 110 | if (self.dataSource.count> 0) { | 121 | if (self.dataSource.count> 0) { |
| 122 | + if ([self.type isEqualToString:@"0"]) { | ||
| 123 | + self.toSid = ((CNBWitnessListModel *)[self.dataSource objectAtIndex:self.currentPlayIndex]).icon.sid; | ||
| 124 | + self.tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshVideoList)]; | ||
| 125 | + self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(getMoreVideoList)]; | ||
| 126 | + }else { | ||
| 127 | + self.toSid = ((CNBWitnessListModel *)self.dataSource[self.currentPlayIndex]).contentSid; | ||
| 128 | + } | ||
| 111 | [_tableView reloadData]; | 129 | [_tableView reloadData]; |
| 112 | [_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.currentPlayIndex inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; | 130 | [_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.currentPlayIndex inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; |
| 113 | [self playIndex:self.currentPlayIndex isAutoPlay:YES]; | 131 | [self playIndex:self.currentPlayIndex isAutoPlay:YES]; |
| 132 | + }else { | ||
| 133 | + if ([self.type isEqualToString:@"0"]) { | ||
| 134 | + self.pageIndex = 1; | ||
| 135 | + self.currentPlayIndex = 0; | ||
| 136 | + [self loadWitnessData:self.pageIndex]; | ||
| 137 | + } | ||
| 138 | + | ||
| 114 | } | 139 | } |
| 115 | - if ([self.type isEqualToString:@"0"]) { | ||
| 116 | - self.tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshVideoList)]; | ||
| 117 | - self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(getMoreVideoList)]; | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | } | 140 | } |
| 121 | #pragma mark -添加关闭按钮 | 141 | #pragma mark -添加关闭按钮 |
| 122 | - (void)setLeftButton { | 142 | - (void)setLeftButton { |
| @@ -213,8 +233,8 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; | @@ -213,8 +233,8 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; | ||
| 213 | if (!strongSelf) { | 233 | if (!strongSelf) { |
| 214 | return ; | 234 | return ; |
| 215 | } | 235 | } |
| 216 | - [strongSelf.tableView.mj_footer isRefreshing]; | ||
| 217 | - [strongSelf.tableView.mj_header isRefreshing]; | 236 | + [strongSelf.tableView.mj_footer endRefreshing]; |
| 237 | + [strongSelf.tableView.mj_header endRefreshing]; | ||
| 218 | strongSelf.isHaveNext = isHaveNext; | 238 | strongSelf.isHaveNext = isHaveNext; |
| 219 | if ([isHaveNext isEqualToString:@"1"]) { | 239 | if ([isHaveNext isEqualToString:@"1"]) { |
| 220 | strongSelf.pageIndex ++; | 240 | strongSelf.pageIndex ++; |
CNLiveWitnessVideoModule/Classes/ViewModel/CNBWitnessListViewModel.m
| @@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
| 12 | #import "CNBWitnessListModel.h" | 12 | #import "CNBWitnessListModel.h" |
| 13 | #import "MJExtension.h" | 13 | #import "MJExtension.h" |
| 14 | #import <QMUIKit/QMUIKit.h> | 14 | #import <QMUIKit/QMUIKit.h> |
| 15 | +#import "CNUserInfoManager.h" | ||
| 15 | #define CNBWitnessAppKeyWindow ([UIApplication sharedApplication].delegate).window | 16 | #define CNBWitnessAppKeyWindow ([UIApplication sharedApplication].delegate).window |
| 16 | @implementation CNBWitnessListViewModel | 17 | @implementation CNBWitnessListViewModel |
| 17 | + (void)getWitnessListDataTosid:(NSString *)toSid page:(NSInteger)page pageSize:(NSInteger)pageSize successBlock:(void(^)(NSMutableArray *dataArray,NSString *isHaveNext))successBlock failureBlock:(void (^)(NSError *error))failureBlock { | 18 | + (void)getWitnessListDataTosid:(NSString *)toSid page:(NSInteger)page pageSize:(NSInteger)pageSize successBlock:(void(^)(NSMutableArray *dataArray,NSString *isHaveNext))successBlock failureBlock:(void (^)(NSError *error))failureBlock { |
| @@ -19,13 +20,13 @@ | @@ -19,13 +20,13 @@ | ||
| 19 | NSString *url = @""; | 20 | NSString *url = @""; |
| 20 | NSDictionary *param = [NSDictionary dictionary]; | 21 | NSDictionary *param = [NSDictionary dictionary]; |
| 21 | param = @{ | 22 | param = @{ |
| 22 | - @"toSid" :CNLiveStringIsEmpty(toSid)? @"":toSid, | 23 | + @"toSid" :CNLiveStringIsEmpty(toSid)?CNUserShareModelUid:toSid, |
| 23 | @"pageNo" :[NSString stringWithFormat:@"%ld",page], | 24 | @"pageNo" :[NSString stringWithFormat:@"%ld",page], |
| 24 | @"pageSize" :[NSString stringWithFormat:@"%ld",pageSize], | 25 | @"pageSize" :[NSString stringWithFormat:@"%ld",pageSize], |
| 25 | @"type":@"0", | 26 | @"type":@"0", |
| 26 | @"reviewStatus":@"1" | 27 | @"reviewStatus":@"1" |
| 27 | }; | 28 | }; |
| 28 | - https://apiwjjtest.cnlive.com/Daren/bWitness/getBWitnessList.action | 29 | + https://apiwjjtest.cnlive.com/Daren/bWitness/getBWitnessList.action |
| 29 | url = cn_API_Host(@"/Daren/bWitness/getBWitnessList.action"); | 30 | url = cn_API_Host(@"/Daren/bWitness/getBWitnessList.action"); |
| 30 | [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | 31 | [CNLiveNetworking setAllowRequestDefaultArgument:YES]; |
| 31 | [CNLiveNetworking setupShowDataResult:NO]; | 32 | [CNLiveNetworking setupShowDataResult:NO]; |
Example/CNLiveWitnessVideoModule/CNLIVEAppDelegate.m
| @@ -33,6 +33,7 @@ static NSString * uuid; | @@ -33,6 +33,7 @@ static NSString * uuid; | ||
| 33 | [mDict setValue:@"i" forKey:@"plat"]; | 33 | [mDict setValue:@"i" forKey:@"plat"]; |
| 34 | [mDict setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"ver"]; | 34 | [mDict setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"ver"]; |
| 35 | [mDict setObject:AppId forKey:@"appId"]; | 35 | [mDict setObject:AppId forKey:@"appId"]; |
| 36 | + [mDict setObject:@"10511059" forKey:@"sid"]; | ||
| 36 | [CNLiveNetworking setupDefaultParam:mDict]; | 37 | [CNLiveNetworking setupDefaultParam:mDict]; |
| 37 | [CNLiveNetworking setupShowResult:NO]; | 38 | [CNLiveNetworking setupShowResult:NO]; |
| 38 | [CNLiveNetworking setupSignKey:APPKey]; | 39 | [CNLiveNetworking setupSignKey:APPKey]; |
Example/CNLiveWitnessVideoModule/CNLIVEViewController.m
| @@ -74,7 +74,7 @@ | @@ -74,7 +74,7 @@ | ||
| 74 | // CNBWitnessListController *vc = [[CNBWitnessListController alloc]initControllerWithData:self.data currentIndex:indexPath.row pageNum:1 type:@"0"]; | 74 | // CNBWitnessListController *vc = [[CNBWitnessListController alloc]initControllerWithData:self.data currentIndex:indexPath.row pageNum:1 type:@"0"]; |
| 75 | // [self.navigationController pushViewController:vc animated:YES]; | 75 | // [self.navigationController pushViewController:vc animated:YES]; |
| 76 | id <CNBWitnessVideoPlayProtocol>service = [[BeeHive shareInstance]createService:@protocol(CNBWitnessVideoPlayProtocol)]; | 76 | id <CNBWitnessVideoPlayProtocol>service = [[BeeHive shareInstance]createService:@protocol(CNBWitnessVideoPlayProtocol)]; |
| 77 | - [service pushToWitnessVideoController:self.data currentIndex:indexPath.row pageNum:1 type:@"0"]; | 77 | + [service pushToWitnessVideoController:self.data currentIndex:12 pageNum:1 type:@"0"]; |
| 78 | } | 78 | } |
| 79 | - (void)getWitnessListDataTosid:(NSString *)toSid page:(NSInteger)page pageSize:(NSInteger)pageSize type:(NSString *)type { | 79 | - (void)getWitnessListDataTosid:(NSString *)toSid page:(NSInteger)page pageSize:(NSInteger)pageSize type:(NSString *)type { |
| 80 | NSString *url = @""; | 80 | NSString *url = @""; |
| @@ -83,7 +83,9 @@ | @@ -83,7 +83,9 @@ | ||
| 83 | param = @{ | 83 | param = @{ |
| 84 | @"toSid" :CNLiveStringIsEmpty(toSid)? @"":toSid, | 84 | @"toSid" :CNLiveStringIsEmpty(toSid)? @"":toSid, |
| 85 | @"pageNo" :[NSString stringWithFormat:@"%ld",page], | 85 | @"pageNo" :[NSString stringWithFormat:@"%ld",page], |
| 86 | - @"pageSize" :[NSString stringWithFormat:@"%ld",pageSize] | 86 | + @"pageSize" :[NSString stringWithFormat:@"%ld",pageSize], |
| 87 | + @"type":@"0", | ||
| 88 | + @"reviewStatus":@"1" | ||
| 87 | }; | 89 | }; |
| 88 | url = cn_API_Host(@"/Daren/bWitness/getBWitnessList.action"); | 90 | url = cn_API_Host(@"/Daren/bWitness/getBWitnessList.action"); |
| 89 | 91 |
Example/CNLiveWitnessVideoModule/main.m
| @@ -7,11 +7,13 @@ | @@ -7,11 +7,13 @@ | ||
| 7 | // | 7 | // |
| 8 | 8 | ||
| 9 | @import UIKit; | 9 | @import UIKit; |
| 10 | +#import <CNLiveEnvironment/CNLiveEnvironment.h> | ||
| 10 | #import "CNLIVEAppDelegate.h" | 11 | #import "CNLIVEAppDelegate.h" |
| 11 | 12 | ||
| 12 | int main(int argc, char * argv[]) | 13 | int main(int argc, char * argv[]) |
| 13 | { | 14 | { |
| 14 | @autoreleasepool { | 15 | @autoreleasepool { |
| 16 | + [CNLiveEnvironmentManager setAppType:CNLiveAppTypeBLive environmentType:CNLiveDebugAppStore]; | ||
| 15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([CNLIVEAppDelegate class])); | 17 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([CNLIVEAppDelegate class])); |
| 16 | } | 18 | } |
| 17 | } | 19 | } |