123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191 |
- //
- // NTESSessionViewController.m
- // NIM
- //
- // Created by amao on 8/11/15.
- // Copyright (c) 2015 Netease. All rights reserved.
- //
- #import "NTESSessionViewController.h"
- @import MobileCoreServices;
- @import AVFoundation;
- #import "Reachability.h"
- #import "UIActionSheet+NTESBlock.h"
- #import "NTESCustomSysNotificationSender.h"
- #import "NTESSessionConfig.h"
- #import "NIMMediaItem.h"
- #import "NTESSessionMsgConverter.h"
- #import "NTESFileLocationHelper.h"
- #import "NTESSessionMsgConverter.h"
- #import "UIView+Toast.h"
- #import "NTESSnapchatAttachment.h"
- #import "NTESJanKenPonAttachment.h"
- #import "NTESFileTransSelectViewController.h"
- #import "NTESAudioChatViewController.h"
- #import "NTESWhiteboardViewController.h"
- #import "NTESVideoChatViewController.h"
- #import "NTESChartletAttachment.h"
- #import "NTESGalleryViewController.h"
- #import "NTESVideoViewController.h"
- #import "NTESFilePreViewController.h"
- #import "NTESAudio2TextViewController.h"
- #import "NSDictionary+NTESJson.h"
- #import "NIMAdvancedTeamCardViewController.h"
- #import "NTESSessionRemoteHistoryViewController.h"
- #import "NIMNormalTeamCardViewController.h"
- #import "UIView+NTES.h"
- #import "NTESBundleSetting.h"
- #import "NTESPersonalCardViewController.h"
- #import "NTESSessionSnapchatContentView.h"
- #import "NTESSessionLocalHistoryViewController.h"
- #import "NIMContactSelectViewController.h"
- #import "SVProgressHUD.h"
- #import "NTESSessionCardViewController.h"
- #import "NTESFPSLabel.h"
- #import "UIAlertView+NTESBlock.h"
- #import "NIMKit.h"
- #import "NTESSessionUtil.h"
- #import "NIMKitMediaFetcher.h"
- #import "NIMKitLocationPoint.h"
- #import "NIMLocationViewController.h"
- #import "NIMKitInfoFetchOption.h"
- #import "NTESSubscribeManager.h"
- #import "User.h"
- #import "GiftInputContainer.h"
- #import "GiftTopBarItem.h"
- #import "UIImageView+WebCache.h"
- #import "AFHTTPSessionManager.h"
- #import "TradePublishManager.h"
- #import "TradeInputContainer.h"
- #import "NIMMessageMaker.h"
- #import "GroupInfoViewController.h"
- #import "NIMInputView.h"
- #import "CityManager.h"
- @interface NTESSessionViewController ()
- <UIImagePickerControllerDelegate,
- UINavigationControllerDelegate,
- NIMSystemNotificationManagerDelegate,
- NIMMediaManagerDelegate,
- NTESTimerHolderDelegate,
- NIMContactSelectDelegate,
- NIMEventSubscribeManagerDelegate,
- GiftDataSourceDelegate,
- TradeInputDelegate,
- NIMInputDelegate>
- @property (nonatomic,strong) NTESCustomSysNotificationSender *notificaionSender;
- @property (nonatomic,strong) NTESSessionConfig *sessionConfig;
- @property (nonatomic,strong) UIImagePickerController *imagePicker;
- @property (nonatomic,strong) NTESTimerHolder *titleTimer;
- @property (nonatomic,strong) UIView *currentSingleSnapView;
- @property (nonatomic,strong) NTESFPSLabel *fpsLabel;
- @property (nonatomic,strong) NIMKitMediaFetcher *mediaFetcher;
- @property (nonatomic,strong) GiftTopBarItem *giftItem1;
- @property (nonatomic,strong) GiftTopBarItem *giftItem2;
- @property (nonatomic,strong) UIView *giftMovieContainer;
- @property (nonatomic,strong) UIImageView *giftMovie;
- @property (nonatomic,strong) NSTimer *timer;
- @property (nonatomic,assign) BOOL displayed;
- @end
- @implementation NTESSessionViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- DDLogInfo(@"enter session, id = %@",self.session.sessionId);
- _notificaionSender = [[NTESCustomSysNotificationSender alloc] init];
- [self setUpNav];
- BOOL disableCommandTyping = self.disableCommandTyping || (self.session.sessionType == NIMSessionTypeP2P &&[[NIMSDK sharedSDK].userManager isUserInBlackList:self.session.sessionId]);
- if (!disableCommandTyping) {
- _titleTimer = [[NTESTimerHolder alloc] init];
- [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
- }
- if ([[NTESBundleSetting sharedConfig] showFps])
- {
- self.fpsLabel = [[NTESFPSLabel alloc] initWithFrame:CGRectZero];
- [self.view addSubview:self.fpsLabel];
- self.fpsLabel.right = self.view.width;
- self.fpsLabel.top = self.tableView.top + self.tableView.contentInset.top;
- }
-
- if (self.session.sessionType == NIMSessionTypeP2P && !self.disableOnlineState)
- {
- //临时订阅这个人的在线状态
- [[NTESSubscribeManager sharedInstance] subscribeTempUserOnlineState:self.session.sessionId];
- [[NIMSDK sharedSDK].subscribeManager addDelegate:self];
- }
-
- //删除最近会话列表中有人@你的标记
- [NTESSessionUtil removeRecentSessionAtMark:self.session];
-
-
- //record chat room id
- if(self.session.sessionType == NIMSessionTypeTeam)
- {
- [User sharedInfo].currentChatRoomId = self.session.sessionId;
- }
- else
- {
- [User sharedInfo].currentChatRoomId = nil;
- }
-
-
-
- self.sessionInputView.giftContainer.delegate = self;
-
- _giftItem1 = [[GiftTopBarItem alloc] initWithFrame:CGRectMake(0, 64, self.view.width, 40)];
- _giftItem1.hidden = YES;
- [self.view addSubview:_giftItem1];
- _giftItem2 = [[GiftTopBarItem alloc] initWithFrame:CGRectMake(0, _giftItem1.bottom-5, self.view.width, 40)];
- _giftItem2.hidden = YES;
- [self.view addSubview:_giftItem2];
-
-
- _giftMovieContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
- _giftMovieContainer.backgroundColor = [UIColor colorWithRed:(0) green:(0) blue:(0) alpha:0.7];
- _giftMovieContainer.hidden = YES;
- _giftMovieContainer.userInteractionEnabled = YES;
- UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideGiftMovie:)];
- [_giftMovieContainer addGestureRecognizer:singleTap];
- [self.view addSubview:_giftMovieContainer];
-
- _giftMovie = [[UIImageView alloc] initWithFrame:CGRectMake(0, _giftItem2.bottom + 5, self.view.width, 300)];
- [_giftMovieContainer addSubview:_giftMovie];
-
- [self.view bringSubviewToFront:self.sessionInputView];
- [self.view bringSubviewToFront:self.sessionInputView.tabContainer];
-
- _timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(updateGiftTopItem) userInfo:nil repeats:YES];
-
-
- self.sessionInputView.giftContainer.tradeContainer.delegate = self;
- }
- - (void)dealloc
- {
- [[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self];
- if (self.session.sessionType == NIMSessionTypeP2P && !self.disableOnlineState)
- {
- [[NIMSDK sharedSDK].subscribeManager removeDelegate:self];
- [[NTESSubscribeManager sharedInstance] unsubscribeTempUserOnlineState:self.session.sessionId];
- }
- [_fpsLabel invalidate];
- [_timer invalidate];
- }
- - (void)viewDidLayoutSubviews{
- [super viewDidLayoutSubviews];
- self.fpsLabel.right = self.view.width;
- self.fpsLabel.top = self.tableView.top + self.tableView.contentInset.top;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- User *user = [User sharedInfo];
- GiftInputContainer *giftInput = [self.sessionInputView giftContainer];
- [giftInput setBalance:user.coin];
-
- if(self.session.sessionType == NIMSessionTypeTeam)
- {
- [giftInput setTeamId:self.session.sessionId];
- BOOL isSystemTeam = [[User sharedInfo] isSystemTeam:self.session.sessionId];
- giftInput.supplyBtn.hidden = !isSystemTeam;
- giftInput.demandBtn.hidden = !isSystemTeam;
-
- if(isSystemTeam)
- {
- NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:self.session.sessionId];
- NSString *teamName = team.teamName;
- TradePriorityType priorityType = [[CityManager shared] tradePriorityTypeByTeamName:teamName];
- NSMutableArray *priorityItems = [[NSMutableArray alloc] init];
- for(int i=0; i<user.tradePriorityItemArr.count; i++)
- {
- TradePriorityItemData *priorityItem = [user.tradePriorityItemArr objectAtIndex:i];
- if(priorityItem.type <= (int)priorityType)
- {
- [priorityItems addObject:priorityItem];
- }
- }
-
- [giftInput.tradeContainer fillItemData:priorityItems];
- }
- }
- else if(self.session.sessionType == NIMSessionTypeP2P)
- {
- [giftInput setTeamId:nil];
- giftInput.supplyBtn.hidden = YES;
- giftInput.demandBtn.hidden = YES;
- }
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- self.displayed = YES;
-
- [_timer setFireDate:[NSDate distantPast]];
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- [[NIMSDK sharedSDK].mediaManager stopRecord];
- [[NIMSDK sharedSDK].mediaManager stopPlay];
-
- [_timer setFireDate:[NSDate distantFuture]];
- }
- - (void)viewDidDisappear:(BOOL)animated{
- [super viewDidDisappear:animated];
- self.displayed = NO;
- }
- - (id<NIMSessionConfig>)sessionConfig
- {
- if (_sessionConfig == nil) {
- _sessionConfig = [[NTESSessionConfig alloc] init];
- _sessionConfig.session = self.session;
- }
- return _sessionConfig;
- }
- #pragma mark - NIMEventSubscribeManagerDelegate
- - (void)onRecvSubscribeEvents:(NSArray *)events
- {
- for (NIMSubscribeEvent *event in events) {
- if ([event.from isEqualToString:self.session.sessionId]) {
- [self refreshSessionSubTitle:[NTESSessionUtil onlineState:self.session.sessionId detail:YES]];
- }
- }
- }
- #pragma mark - NIMSystemNotificationManagerDelegate
- - (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification
- {
- if (!notification.sendToOnlineUsersOnly) {
- return;
- }
- NSData *data = [[notification content] dataUsingEncoding:NSUTF8StringEncoding];
- if (data) {
- NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data
- options:0
- error:nil];
- if ([dict jsonInteger:NTESNotifyID] == NTESCommandTyping && self.session.sessionType == NIMSessionTypeP2P && [notification.sender isEqualToString:self.session.sessionId])
- {
- [self refreshSessionTitle:@"正在输入..."];
- [_titleTimer startTimer:5
- delegate:self
- repeats:NO];
- }
- }
-
-
- }
- - (void)onNTESTimerFired:(NTESTimerHolder *)holder
- {
- [self refreshSessionTitle:self.sessionTitle];
- }
- - (NSString *)sessionTitle
- {
- if ([self.session.sessionId isEqualToString:[NIMSDK sharedSDK].loginManager.currentAccount]) {
- return @"我的电脑";
- }
- return [super sessionTitle];
- }
- - (NSString *)sessionSubTitle
- {
- if (self.session.sessionType == NIMSessionTypeP2P && ![self.session.sessionId isEqualToString:[NIMSDK sharedSDK].loginManager.currentAccount]) {
- return [NTESSessionUtil onlineState:self.session.sessionId detail:YES];
- }
- return @"";
- }
- - (void)onTextChanged:(id)sender
- {
- [_notificaionSender sendTypingState:self.session];
- }
- - (void)onSelectChartlet:(NSString *)chartletId
- catalog:(NSString *)catalogId
- {
- NTESChartletAttachment *attachment = [[NTESChartletAttachment alloc] init];
- attachment.chartletId = chartletId;
- attachment.chartletCatalog = catalogId;
- [self sendMessage:[NTESSessionMsgConverter msgWithChartletAttachment:attachment]];
- }
- #pragma mark - 石头剪子布
- - (void)onTapMediaItemJanKenPon:(NIMMediaItem *)item
- {
- NTESJanKenPonAttachment *attachment = [[NTESJanKenPonAttachment alloc] init];
- attachment.value = arc4random() % 3 + 1;
- [self sendMessage:[NTESSessionMsgConverter msgWithJenKenPon:attachment]];
- }
- #pragma mark - 实时语音
- - (void)onTapMediaItemAudioChat:(NIMMediaItem *)item
- {
- if ([self checkCondition]) {
- //由于音视频聊天里头有音频和视频聊天界面的切换,直接用present的话页面过渡会不太自然,这里还是用push,然后做出present的效果
- NTESAudioChatViewController *vc = [[NTESAudioChatViewController alloc] initWithCallee:self.session.sessionId];
- CATransition *transition = [CATransition animation];
- transition.duration = 0.25;
- transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
- transition.type = kCATransitionPush;
- transition.subtype = kCATransitionFromTop;
- [self.navigationController.view.layer addAnimation:transition forKey:nil];
- self.navigationController.navigationBarHidden = YES;
- [self.navigationController pushViewController:vc animated:NO];
- }
- }
- #pragma mark - 视频聊天
- - (void)onTapMediaItemVideoChat:(NIMMediaItem *)item
- {
- if ([self checkCondition]) {
- //由于音视频聊天里头有音频和视频聊天界面的切换,直接用present的话页面过渡会不太自然,这里还是用push,然后做出present的效果
- NTESVideoChatViewController *vc = [[NTESVideoChatViewController alloc] initWithCallee:self.session.sessionId];
- CATransition *transition = [CATransition animation];
- transition.duration = 0.25;
- transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
- transition.type = kCATransitionPush;
- transition.subtype = kCATransitionFromTop;
- [self.navigationController.view.layer addAnimation:transition forKey:nil];
- self.navigationController.navigationBarHidden = YES;
- [self.navigationController pushViewController:vc animated:NO];
- }
- }
- #pragma mark - 文件传输
- - (void)onTapMediaItemFileTrans:(NIMMediaItem *)item
- {
- NTESFileTransSelectViewController *vc = [[NTESFileTransSelectViewController alloc]
- initWithNibName:nil bundle:nil];
- __weak typeof(self) wself = self;
- vc.completionBlock = ^void(id sender,NSString *ext){
- if ([sender isKindOfClass:[NSString class]]) {
- [wself sendMessage:[NTESSessionMsgConverter msgWithFilePath:sender]];
- }else if ([sender isKindOfClass:[NSData class]]){
- [wself sendMessage:[NTESSessionMsgConverter msgWithFileData:sender extension:ext]];
- }
- };
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - 阅后即焚
- - (void)onTapMediaItemSnapChat:(NIMMediaItem *)item
- {
- UIActionSheet *sheet;
- BOOL isCamraAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
- if (isCamraAvailable) {
- sheet = [[UIActionSheet alloc] initWithTitle:@"请选择" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"从相册中选取",@"拍照",nil];
- }else{
- sheet = [[UIActionSheet alloc] initWithTitle:@"请选择" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"从相册中选取",nil];
- }
- __weak typeof(self) wself = self;
- [sheet showInView:self.view completionHandler:^(NSInteger index) {
- switch (index) {
- case 0:{
- //相册
- [wself.mediaFetcher fetchPhotoFromLibrary:^(NSArray *images, NSString *path, PHAssetMediaType type){
- if (images.count) {
- [wself sendSnapchatMessage:images.firstObject];
- }
- if (path) {
- [wself sendSnapchatMessagePath:path];
- }
- }];
-
- }
- break;
- case 1:{
- //相机
- [wself.mediaFetcher fetchMediaFromCamera:^(NSString *path, UIImage *image) {
- if (image) {
- [wself sendSnapchatMessage:image];
- }
- }];
- }
- break;
- default:
- return;
- }
- }];
- }
- - (void)sendSnapchatMessagePath:(NSString *)path
- {
- NTESSnapchatAttachment *attachment = [[NTESSnapchatAttachment alloc] init];
- [attachment setImageFilePath:path];
- [self sendMessage:[NTESSessionMsgConverter msgWithSnapchatAttachment:attachment]];
- }
- - (void)sendSnapchatMessage:(UIImage *)image
- {
- NTESSnapchatAttachment *attachment = [[NTESSnapchatAttachment alloc] init];
- [attachment setImage:image];
- [self sendMessage:[NTESSessionMsgConverter msgWithSnapchatAttachment:attachment]];
- }
- #pragma mark - 白板
- - (void)onTapMediaItemWhiteBoard:(NIMMediaItem *)item
- {
- NTESWhiteboardViewController *vc = [[NTESWhiteboardViewController alloc] initWithSessionID:nil
- peerID:self.session.sessionId
- types:NIMRTSServiceReliableTransfer | NIMRTSServiceAudio
- info:@"白板演示"];
- [self presentViewController:vc animated:NO completion:nil];
- }
- #pragma mark - 提醒消息
- - (void)onTapMediaItemTip:(NIMMediaItem *)item
- {
- UIAlertView *alert =[[UIAlertView alloc] initWithTitle:nil message:@"输入提醒" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
- alert.alertViewStyle = UIAlertViewStylePlainTextInput;
- [alert showAlertWithCompletionHandler:^(NSInteger index) {
- switch (index) {
- case 1:{
- UITextField *textField = [alert textFieldAtIndex:0];
- NIMMessage *message = [NTESSessionMsgConverter msgWithTip:textField.text];
- [self sendMessage:message];
- }
- break;
- default:
- break;
- }
- }];
- }
- #pragma mark - 录音事件
- - (void)onRecordFailed:(NSError *)error
- {
- [self.view makeToast:@"录音失败" duration:2 position:CSToastPositionCenter];
- }
- - (BOOL)recordFileCanBeSend:(NSString *)filepath
- {
- NSURL *URL = [NSURL fileURLWithPath:filepath];
- AVURLAsset *urlAsset = [[AVURLAsset alloc]initWithURL:URL options:nil];
- CMTime time = urlAsset.duration;
- CGFloat mediaLength = CMTimeGetSeconds(time);
- return mediaLength > 2;
- }
- - (void)showRecordFileNotSendReason
- {
- [self.view makeToast:@"录音时间太短" duration:0.2f position:CSToastPositionCenter];
- }
- #pragma mark - Cell事件
- - (BOOL)onTapCell:(NIMKitEvent *)event
- {
- BOOL handled = [super onTapCell:event];
- NSString *eventName = event.eventName;
- if ([eventName isEqualToString:NIMKitEventNameTapContent])
- {
- NIMMessage *message = event.messageModel.message;
- NSDictionary *actions = [self cellActions];
- NSString *value = actions[@(message.messageType)];
- if (value) {
- SEL selector = NSSelectorFromString(value);
- if (selector && [self respondsToSelector:selector]) {
- SuppressPerformSelectorLeakWarning([self performSelector:selector withObject:message]);
- handled = YES;
- }
- }
- }
- else if([eventName isEqualToString:NIMKitEventNameTapLabelLink])
- {
- NSString *link = event.data;
- [self.view makeToast:[NSString stringWithFormat:@"tap link : %@",link]
- duration:2
- position:CSToastPositionCenter];
- handled = YES;
- }
- else if([eventName isEqualToString:NIMDemoEventNameOpenSnapPicture])
- {
- NIMCustomObject *object = event.messageModel.message.messageObject;
- NTESSnapchatAttachment *attachment = (NTESSnapchatAttachment *)object.attachment;
- if(attachment.isFired){
- return handled;
- }
- UIView *sender = event.data;
- self.currentSingleSnapView = [NTESGalleryViewController alertSingleSnapViewWithMessage:object.message baseView:sender];
- handled = YES;
- }
- else if([eventName isEqualToString:NIMDemoEventNameCloseSnapPicture])
- {
- //点击很快的时候可能会触发两次查看,所以这里不管有没有查看过 先强直销毁掉
- NIMCustomObject *object = event.messageModel.message.messageObject;
- UIView *senderView = event.data;
- [senderView dismissPresentedView:YES complete:nil];
-
- NTESSnapchatAttachment *attachment = (NTESSnapchatAttachment *)object.attachment;
- if(attachment.isFired){
- return handled;
- }
- attachment.isFired = YES;
- NIMMessage *message = object.message;
- if ([NTESBundleSetting sharedConfig].autoRemoveSnapMessage) {
- [[NIMSDK sharedSDK].conversationManager deleteMessage:message];
- [self uiDeleteMessage:message];
-
- }else{
- [[NIMSDK sharedSDK].conversationManager updateMessage:message forSession:message.session completion:nil];
- [self uiUpdateMessage:message];
- }
- [[NSFileManager defaultManager] removeItemAtPath:attachment.filepath error:nil];
- handled = YES;
- self.currentSingleSnapView = nil;
- }
- if (!handled) {
- NSAssert(0, @"invalid event");
- }
- return handled;
- }
- - (BOOL)onTapAvatar:(NSString *)userId{
- UIViewController *vc = [[NTESPersonalCardViewController alloc] initWithUserId:userId];
- [self.navigationController pushViewController:vc animated:YES];
- return YES;
- }
- - (BOOL)onLongPressAvatar:(NSString *)userId{
-
- NSLog(@"onLongPressAvatar : %@", userId);
-
- [self.sessionInputView addAtItem:userId];
-
- return YES;
- }
- #pragma mark - Cell Actions
- - (void)showImage:(NIMMessage *)message
- {
- NIMImageObject *object = message.messageObject;
- NTESGalleryItem *item = [[NTESGalleryItem alloc] init];
- item.thumbPath = [object thumbPath];
- item.imageURL = [object url];
- item.name = [object displayName];
- NTESGalleryViewController *vc = [[NTESGalleryViewController alloc] initWithItem:item];
- [self.navigationController pushViewController:vc animated:YES];
- if(![[NSFileManager defaultManager] fileExistsAtPath:object.thumbPath]){
- //如果缩略图下跪了,点进看大图的时候再去下一把缩略图
- __weak typeof(self) wself = self;
- [[NIMSDK sharedSDK].resourceManager download:object.thumbUrl filepath:object.thumbPath progress:nil completion:^(NSError *error) {
- if (!error) {
- [wself uiUpdateMessage:message];
- }
- }];
- }
- }
- - (void)showVideo:(NIMMessage *)message
- {
- NIMVideoObject *object = message.messageObject;
- NTESVideoViewController *playerViewController = [[NTESVideoViewController alloc] initWithVideoObject:object];
- [self.navigationController pushViewController:playerViewController animated:YES];
- if(![[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]){
- //如果封面图下跪了,点进视频的时候再去下一把封面图
- __weak typeof(self) wself = self;
- [[NIMSDK sharedSDK].resourceManager download:object.coverUrl filepath:object.coverPath progress:nil completion:^(NSError *error) {
- if (!error) {
- [wself uiUpdateMessage:message];
- }
- }];
- }
- }
- - (void)showLocation:(NIMMessage *)message
- {
- NIMLocationObject *object = message.messageObject;
- NIMKitLocationPoint *locationPoint = [[NIMKitLocationPoint alloc] initWithLocationObject:object];
- NIMLocationViewController *vc = [[NIMLocationViewController alloc] initWithLocationPoint:locationPoint];
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)showFile:(NIMMessage *)message
- {
- NIMFileObject *object = message.messageObject;
- NTESFilePreViewController *vc = [[NTESFilePreViewController alloc] initWithFileObject:object];
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)showCustom:(NIMMessage *)message
- {
- //普通的自定义消息点击事件可以在这里做哦~
- NSLog(@"show custom message");
- }
- #pragma mark - 导航按钮
- - (void)onTouchUpInfoBtn:(id)sender{
- NTESSessionCardViewController *vc = [[NTESSessionCardViewController alloc] initWithSession:self.session];
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)enterHistory:(id)sender{
- [self.view endEditing:YES];
- UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"选择操作" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"云消息记录",@"搜索本地消息记录",@"清空本地聊天记录", nil];
- [sheet showInView:self.view completionHandler:^(NSInteger index) {
- switch (index) {
- case 0:{ //查看云端消息
- NTESSessionRemoteHistoryViewController *vc = [[NTESSessionRemoteHistoryViewController alloc] initWithSession:self.session];
- [self.navigationController pushViewController:vc animated:YES];
- break;
- }
- case 1:{ //搜索本地消息
- NTESSessionLocalHistoryViewController *vc = [[NTESSessionLocalHistoryViewController alloc] initWithSession:self.session];
- [self.navigationController pushViewController:vc animated:YES];
- break;
- }
- case 2:{ //清空聊天记录
- UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"确定清空聊天记录?" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil, nil];
- __weak UIActionSheet *wSheet;
- [sheet showInView:self.view completionHandler:^(NSInteger index) {
- if (index == wSheet.destructiveButtonIndex) {
- BOOL removeRecentSession = [NTESBundleSetting sharedConfig].removeSessionWheDeleteMessages;
- [[NIMSDK sharedSDK].conversationManager deleteAllmessagesInSession:self.session removeRecentSession:removeRecentSession];
- }
- }];
- break;
- }
- default:
- break;
- }
- }];
- }
- - (void)enterTeamCard:(id)sender{
- NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:self.session.sessionId];
- UIViewController *vc;
- if (team.type == NIMTeamTypeNormal) {
- vc = [[NIMNormalTeamCardViewController alloc] initWithTeam:team];
- }else if(team.type == NIMTeamTypeAdvanced){
- //vc = [[NIMAdvancedTeamCardViewController alloc] initWithTeam:team];
- vc = [[GroupInfoViewController alloc] initWithTeam:team];
- }
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - 菜单
- - (NSArray *)menusItems:(NIMMessage *)message
- {
- NSMutableArray *items = [NSMutableArray array];
- NSArray *defaultItems = [super menusItems:message];
- if (defaultItems) {
- [items addObjectsFromArray:defaultItems];
- }
-
- if ([NTESSessionUtil canMessageBeForwarded:message]) {
- [items addObject:[[UIMenuItem alloc] initWithTitle:@"转发" action:@selector(forwardMessage:)]];
- }
-
- if ([NTESSessionUtil canMessageBeRevoked:message]) {
- [items addObject:[[UIMenuItem alloc] initWithTitle:@"撤回" action:@selector(revokeMessage:)]];
- }
-
- if (message.messageType == NIMMessageTypeAudio) {
- [items addObject:[[UIMenuItem alloc] initWithTitle:@"转文字" action:@selector(audio2Text:)]];
- }
-
- return items;
-
- }
- - (void)audio2Text:(id)sender
- {
- NIMMessage *message = [self messageForMenu];
- __weak typeof(self) wself = self;
- NTESAudio2TextViewController *vc = [[NTESAudio2TextViewController alloc] initWithMessage:message];
- vc.completeHandler = ^(void){
- [wself uiUpdateMessage:message];
- };
- [self presentViewController:vc
- animated:YES
- completion:nil];
- }
- - (void)forwardMessage:(id)sender
- {
- NIMMessage *message = [self messageForMenu];
- UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"选择会话类型" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"个人",@"群组", nil];
- __weak typeof(self) weakSelf = self;
- [sheet showInView:self.view completionHandler:^(NSInteger index) {
- switch (index) {
- case 0:{
- NIMContactFriendSelectConfig *config = [[NIMContactFriendSelectConfig alloc] init];
- config.needMutiSelected = NO;
- NIMContactSelectViewController *vc = [[NIMContactSelectViewController alloc] initWithConfig:config];
- vc.finshBlock = ^(NSArray *array){
- NSString *userId = array.firstObject;
- NIMSession *session = [NIMSession session:userId type:NIMSessionTypeP2P];
- [weakSelf forwardMessage:message toSession:session];
- };
- [vc show];
- }
- break;
- case 1:{
- NIMContactTeamSelectConfig *config = [[NIMContactTeamSelectConfig alloc] init];
- NIMContactSelectViewController *vc = [[NIMContactSelectViewController alloc] initWithConfig:config];
- vc.finshBlock = ^(NSArray *array){
- NSString *teamId = array.firstObject;
- NIMSession *session = [NIMSession session:teamId type:NIMSessionTypeTeam];
- [weakSelf forwardMessage:message toSession:session];
- };
- [vc show];
- }
- break;
- case 2:
- break;
- default:
- break;
- }
- }];
- }
- - (void)revokeMessage:(id)sender
- {
- NIMMessage *message = [self messageForMenu];
- __weak typeof(self) weakSelf = self;
- [[NIMSDK sharedSDK].chatManager revokeMessage:message completion:^(NSError * _Nullable error) {
- if (error) {
- if (error.code == NIMRemoteErrorCodeDomainExpireOld) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"发送时间超过2分钟的消息,不能被撤回" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- }else{
- DDLogError(@"revoke message eror code %zd",error.code);
- [weakSelf.view makeToast:@"消息撤回失败,请重试" duration:2.0 position:CSToastPositionCenter];
- }
- }
- else
- {
- NIMMessageModel *model = [self uiDeleteMessage:message];
- NIMMessage *tip = [NTESSessionMsgConverter msgWithTip:[NTESSessionUtil tipOnMessageRevoked:message]];
- tip.timestamp = model.messageTime;
- [self uiInsertMessages:@[tip]];
-
- tip.timestamp = message.timestamp;
- // saveMessage 方法执行成功后会触发 onRecvMessages: 回调,但是这个回调上来的 NIMMessage 时间为服务器时间,和界面上的时间有一定出入,所以要提前先在界面上插入一个和被删消息的界面时间相符的 Tip, 当触发 onRecvMessages: 回调时,组件判断这条消息已经被插入过了,就会忽略掉。
- [[NIMSDK sharedSDK].conversationManager saveMessage:tip forSession:message.session completion:nil];
- }
- }];
- }
- - (void)forwardMessage:(NIMMessage *)message toSession:(NIMSession *)session
- {
- NSString *name;
- if (session.sessionType == NIMSessionTypeP2P)
- {
- NIMKitInfoFetchOption *option = [[NIMKitInfoFetchOption alloc] init];
- option.session = session;
- name = [[NIMKit sharedKit] infoByUser:session.sessionId option:option].showName;
- }
- else
- {
- name = [[NIMKit sharedKit] infoByTeam:session.sessionId option:nil].showName;
- }
- NSString *tip = [NSString stringWithFormat:@"确认转发给 %@ ?",name];
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"确认转发" message:tip delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
-
- __weak typeof(self) weakSelf = self;
- [alert showAlertWithCompletionHandler:^(NSInteger index) {
- if(index == 1){
- [[NIMSDK sharedSDK].chatManager forwardMessage:message toSession:session error:nil];
- [weakSelf.view makeToast:@"已发送" duration:2.0 position:CSToastPositionCenter];
- }
- }];
- }
- #pragma mark - 辅助方法
- - (void)sendImageMessagePath:(NSString *)path
- {
- [self sendSnapchatMessagePath:path];
- }
- - (BOOL)checkCondition
- {
- BOOL result = YES;
-
- if (![[Reachability reachabilityForInternetConnection] isReachable]) {
- [self.view makeToast:@"请检查网络" duration:2.0 position:CSToastPositionCenter];
- result = NO;
- }
- NSString *currentAccount = [[NIMSDK sharedSDK].loginManager currentAccount];
- if ([currentAccount isEqualToString:self.session.sessionId]) {
- [self.view makeToast:@"不能和自己通话哦" duration:2.0 position:CSToastPositionCenter];
- result = NO;
- }
- return result;
- }
- - (NSDictionary *)cellActions
- {
- static NSDictionary *actions = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- actions = @{@(NIMMessageTypeImage) : @"showImage:",
- @(NIMMessageTypeVideo) : @"showVideo:",
- @(NIMMessageTypeLocation) : @"showLocation:",
- @(NIMMessageTypeFile) : @"showFile:",
- @(NIMMessageTypeCustom): @"showCustom:"};
- });
- return actions;
- }
- - (NIMKitMediaFetcher *)mediaFetcher
- {
- if (!_mediaFetcher) {
- _mediaFetcher = [[NIMKitMediaFetcher alloc] init];
- _mediaFetcher.limit = 1;
- _mediaFetcher.mediaTypes = @[(NSString *)kUTTypeImage];;;
- }
- return _mediaFetcher;
- }
- - (void)setUpNav{
- // UIButton *enterTeamCard = [UIButton buttonWithType:UIButtonTypeCustom];
- // [enterTeamCard addTarget:self action:@selector(enterTeamCard:) forControlEvents:UIControlEventTouchUpInside];
- // [enterTeamCard setImage:[UIImage imageNamed:@"icon_session_info_normal"] forState:UIControlStateNormal];
- // [enterTeamCard setImage:[UIImage imageNamed:@"icon_session_info_pressed"] forState:UIControlStateHighlighted];
- // [enterTeamCard sizeToFit];
- // UIBarButtonItem *enterTeamCardItem = [[UIBarButtonItem alloc] initWithCustomView:enterTeamCard];
- //
- // UIButton *infoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // [infoBtn addTarget:self action:@selector(onTouchUpInfoBtn:) forControlEvents:UIControlEventTouchUpInside];
- // [infoBtn setImage:[UIImage imageNamed:@"icon_session_info_normal"] forState:UIControlStateNormal];
- // [infoBtn setImage:[UIImage imageNamed:@"icon_session_info_pressed"] forState:UIControlStateHighlighted];
- // [infoBtn sizeToFit];
- // UIBarButtonItem *enterUInfoItem = [[UIBarButtonItem alloc] initWithCustomView:infoBtn];
- //
- // UIButton *historyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // [historyBtn addTarget:self action:@selector(enterHistory:) forControlEvents:UIControlEventTouchUpInside];
- // [historyBtn setImage:[UIImage imageNamed:@"icon_history_normal"] forState:UIControlStateNormal];
- // [historyBtn setImage:[UIImage imageNamed:@"icon_history_pressed"] forState:UIControlStateHighlighted];
- // [historyBtn sizeToFit];
- // UIBarButtonItem *historyButtonItem = [[UIBarButtonItem alloc] initWithCustomView:historyBtn];
- //
- //
- //
- // if (self.session.sessionType == NIMSessionTypeTeam) {
- // self.navigationItem.rightBarButtonItems = @[enterTeamCardItem,historyButtonItem];
- // }else if(self.session.sessionType == NIMSessionTypeP2P){
- // if ([self.session.sessionId isEqualToString:[[NIMSDK sharedSDK].loginManager currentAccount]]) {
- // self.navigationItem.rightBarButtonItems = @[historyButtonItem];
- // }else{
- // self.navigationItem.rightBarButtonItems = @[enterUInfoItem,historyButtonItem];
- // }
- // }
-
- UIButton *enterTeamCard = [UIButton buttonWithType:UIButtonTypeCustom];
- [enterTeamCard addTarget:self action:@selector(enterTeamCard:) forControlEvents:UIControlEventTouchUpInside];
- [enterTeamCard setImage:[UIImage imageNamed:@"设置图标"] forState:UIControlStateNormal];
- [enterTeamCard setFrame:CGRectMake(0, 0, 30, 30)];
- UIBarButtonItem *enterTeamCardItem = [[UIBarButtonItem alloc] initWithCustomView:enterTeamCard];
-
-
- UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [searchBtn addTarget:self action:@selector(searchChatContent:) forControlEvents:UIControlEventTouchUpInside];
- [searchBtn setImage:[UIImage imageNamed:@"查找聊天内容_03"] forState:UIControlStateNormal];
- [searchBtn sizeToFit];
-
- UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(searchChatContent:)];
- UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteChatCache:)];
- UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [deleteBtn addTarget:self action:@selector(onTouchUpInfoBtn:) forControlEvents:UIControlEventTouchUpInside];
- [deleteBtn setImage:[UIImage imageNamed:@"icon_session_info_normal"] forState:UIControlStateNormal];
- [deleteBtn sizeToFit];
-
- //UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:searchBtn];
- //UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithCustomView:deleteBtn];
-
-
-
-
- if(self.session.sessionType == NIMSessionTypeTeam)
- {
- NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:self.session.sessionId];
- if(team && team.owner && [team.owner isEqualToString:@"10000"])
- {
- [self.navigationItem.titleView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(enterTeamCard:)]];
- self.navigationItem.rightBarButtonItems = @[deleteItem, searchItem];
- }
- else
- {
- self.navigationItem.rightBarButtonItems = @[enterTeamCardItem];
- }
- }
- else
- {
- self.navigationItem.rightBarButtonItems = @[deleteItem, searchItem];
- }
-
- }
- - (BOOL)shouldAutorotate{
- return !self.currentSingleSnapView;
- }
- - (void)requestGiftDataList
- {
- User *user = [User sharedInfo];
- [user requestGiftList:^(NSMutableArray * _Nullable list) {
- [self.sessionInputView.giftContainer initGiftList:list];
- } failure:^(NSError * _Nullable error) {
- NSLog(@"获取礼物列表失败");
- }];
- }
- - (void)sendGift:(GiftData *)giftData count:(int)count msg:(NSString *)msg userId:(NSString *)userId
- {
- NSString *teamId = @"";
- NSString *menberId = userId != nil ? userId : @"";
- if(self.session.sessionType == NIMSessionTypeTeam)
- {
- teamId = self.session.sessionId;
- }
- else if(self.session.sessionType == NIMSessionTypeP2P)
- {
- menberId = self.session.sessionId;
- }
-
- __weak typeof(self) wself = self;
-
- User *user = [User sharedInfo];
- [user sendGif:giftData count:count teamId:teamId targetId:menberId msg:msg success:^(NSString * _Nullable giftId, NSString * _Nullable info){
-
- [wself.sessionInputView.giftContainer setBalance:user.coin];
-
- NSArray *atUsers = nil;
- if(wself.session.sessionType == NIMSessionTypeTeam && userId != nil && userId.length > 0)
- {
- atUsers = @[userId];
- }
- else if(wself.session.sessionType == NIMSessionTypeP2P)
- {
- atUsers = @[];
- }
-
- if(atUsers.count)
- {
- [[NIMSDK sharedSDK].userManager fetchUserInfos:atUsers completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
- if(users.count)
- {
- NIMUser *u = [users objectAtIndex:0];
- NSString *content = [NSString stringWithFormat:@"@%@ %@", u.userInfo.nickName ? u.userInfo.nickName : u.userId, msg];
- [wself onSendGiftText:content atUsers:atUsers giftData:giftData giftId:giftId count:count teamId:teamId targetId:menberId];
- }
- }];
- }
- else
- {
- NSString *content = [NSString stringWithFormat:@"%@%@", @"", msg];
- [wself onSendGiftText:content atUsers:atUsers giftData:giftData giftId:giftId count:count teamId:teamId targetId:menberId];
- }
-
- //[wself requestGift];
-
- } failure:^(NSError * _Nullable error) {
- //
- }];
-
- [self.sessionInputView endEditing:YES];
- [self.sessionInputView unselectedTabBarItem];
- }
- - (void)onSendGiftText:(NSString *)text atUsers:(NSArray *)atUsers giftData:(GiftData *)giftData giftId:(NSString *)giftId count:(int)count teamId:(NSString *)teamId targetId:(NSString *)targetId
- {
- NTESGiftAttachment *attachment = [[NTESGiftAttachment alloc] init];
- attachment.giftId = giftId;
- attachment.senderId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
- attachment.teamId = teamId;
- attachment.targetId = targetId;
- attachment.count = [NSString stringWithFormat:@"%d", count];
- attachment.msg = text;
- attachment.movieURL = giftData.movieURL;
- attachment.iconURL = giftData.iconURL;
-
- NIMMessage *message = [NTESSessionMsgConverter msgWithGift:attachment];
- if (atUsers.count) {
- NIMMessageApnsMemberOption *apnsOption = [[NIMMessageApnsMemberOption alloc] init];
- apnsOption.userIds = atUsers;
- apnsOption.forcePush = YES;
-
- NIMKitInfoFetchOption *option = [[NIMKitInfoFetchOption alloc] init];
- option.session = self.session;
-
- NSString *me = [[NIMKit sharedKit].provider infoByUser:[NIMSDK sharedSDK].loginManager.currentAccount option:option].showName;
- apnsOption.apnsContent = [NSString stringWithFormat:@"%@在群里@了你",me];
- message.apnsMemberOption = apnsOption;
- }
- [self sendMessage:message];
-
- [self handleGiftMessage:attachment];
- }
- - (void)handleGiftMessage:(NTESGiftAttachment *)giftAttachment{
-
-
- NSString *giftId = giftAttachment.giftId;
- NSString *senderId = giftAttachment.senderId;
- NSString *teamId = giftAttachment.teamId;
- NSString *targetId = giftAttachment.targetId;
-
- NSString *key = teamId ? teamId : targetId;
-
- if(!self.displayed)
- {
- [[User sharedInfo] initGiftGot:key dataId:giftId];
- return;
- }
-
- if([[User sharedInfo] isNewGiftGot:key dataId:giftId])
- {
- NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
- [dict setValue:senderId forKey:@"sender"];
- [dict setValue:giftAttachment.iconURL forKey:@"gift"];
- [dict setValue:teamId forKey:@"team"];
- [dict setValue:targetId forKey:@"target"];
- [dict setValue:giftAttachment.count forKey:@"count"];
-
- if(!_giftItem1.isHidden && !_giftItem2.isHidden)
- {
- [_giftItem1 setInfo:_giftItem2.infoDict];
- _giftItem1.timeCount = _giftItem2.timeCount;
-
- [_giftItem2 setInfo:dict];
- _giftItem2.timeCount = 0;
- }
- else if(!_giftItem1.isHidden && _giftItem2.isHidden)
- {
- [_giftItem2 setInfo:dict];
- [_giftItem2 setHidden:NO];
- _giftItem2.timeCount = 0;
- }
- else
- {
- [_giftItem1 setInfo:dict];
- [_giftItem1 setHidden:NO];
- _giftItem1.timeCount = 0;
- }
-
- NSURL *url = [NSURL URLWithString:giftAttachment.movieURL];
- [_giftMovie sd_setImageWithURL:url placeholderImage:nil];
- [_giftMovieContainer setHidden:NO];
- }
-
- }
- - (void)updateGiftTopItem{
-
- NSLog(@"updateGiftTopItem");
-
- int hideTimeCount = 2;
- if(!_giftItem1.isHidden){
- _giftItem1.timeCount++;
- if(_giftItem1.timeCount > hideTimeCount)
- {
- [_giftItem1 setHidden:YES];
- }
- }
- if(!_giftItem2.isHidden){
- _giftItem2.timeCount++;
- if(_giftItem2.timeCount > hideTimeCount)
- {
- [_giftItem2 setHidden:YES];
- }
- }
-
-
- if(!_giftItem2.isHidden && _giftItem1.isHidden)
- {
- [_giftItem1 setInfo:_giftItem2.infoDict];
- _giftItem1.timeCount = _giftItem2.timeCount;
- [_giftItem1 setHidden:NO];
-
- [_giftItem2 setHidden:YES];
- }
- }
- - (void)hideGiftMovie:(id)sender
- {
- _giftMovieContainer.hidden = YES;
- }
- - (void)inputTabSelected{
- [self hideGiftMovie:nil];
- }
- - (void)deleteChatCache:(int)sender
- {
- UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"确定清空聊天记录?" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil, nil];
- __weak UIActionSheet *wSheet;
- [sheet showInView:self.view completionHandler:^(NSInteger index) {
- if (index == wSheet.destructiveButtonIndex) {
- BOOL removeRecentSession = [NTESBundleSetting sharedConfig].removeSessionWheDeleteMessages;
- [[NIMSDK sharedSDK].conversationManager deleteAllmessagesInSession:self.session removeRecentSession:removeRecentSession];
- }
- }];
- }
- - (void)searchChatContent:(int)sender
- {
- NTESSessionLocalHistoryViewController *vc = [[NTESSessionLocalHistoryViewController alloc] initWithSession:self.session];
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)sendTrade:(NSString *)msg picArr:(NSMutableArray *)picArr priority:(int)priority priorityType:(int)priorityType type:(int)type{
-
- if((!msg || msg.length == 0) && picArr.count == 0)
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"你还什么都没说呢" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- return;
- }
-
- TradePublishManager *tradePublishManager = [[TradePublishManager alloc] init];
- tradePublishManager.inputView = self.sessionInputView;
- [tradePublishManager tradePublish:msg picArr:picArr priority:priority priorityType:priorityType tradeType:type];
-
- }
- @end
|