聊天的

This commit is contained in:
wu736139669
2015-06-26 11:20:30 +08:00
parent 0dd214aaed
commit 2dd8e79a88
29 changed files with 1167 additions and 275 deletions
+30
View File
@@ -229,6 +229,10 @@
A97C55061AC933AD0038818A /* UMSnsAccountViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A97C54FA1AC933AD0038818A /* UMSnsAccountViewController.xib */; };
A97C55071AC933AD0038818A /* UMSShareListController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A97C54FB1AC933AD0038818A /* UMSShareListController.xib */; };
A97C55081AC933AD0038818A /* UMSocialSDKResourcesNew.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A97C54FC1AC933AD0038818A /* UMSocialSDKResourcesNew.bundle */; };
A97CCE291B3BE6440046FE17 /* MessageListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A97CCE271B3BE6440046FE17 /* MessageListViewController.m */; };
A97CCE2A1B3BE6440046FE17 /* MessageListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A97CCE281B3BE6440046FE17 /* MessageListViewController.xib */; };
A97CCE2E1B3BEBDA0046FE17 /* MessageListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A97CCE2C1B3BEBDA0046FE17 /* MessageListTableViewCell.m */; };
A97CCE2F1B3BEBDA0046FE17 /* MessageListTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A97CCE2D1B3BEBDA0046FE17 /* MessageListTableViewCell.xib */; };
A97DBE331ACAE10800705682 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A97DBE311ACAE10800705682 /* LoginViewController.m */; };
A97DBE341ACAE10800705682 /* LoginViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A97DBE321ACAE10800705682 /* LoginViewController.xib */; };
A97DBE3F1ACAE29E00705682 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = A97DBE391ACAE29E00705682 /* Icon.png */; };
@@ -293,6 +297,8 @@
A9B6DFE41B202E950003C1BC /* night_user_comment_circle@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B6DFE31B202E950003C1BC /* night_user_comment_circle@2x.png */; };
A9B6DFE61B2033A80003C1BC /* toolbar_light_comment@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B6DFE51B2033A80003C1BC /* toolbar_light_comment@2x.png */; };
A9B6DFEC1B2068790003C1BC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9B6DFEE1B2068790003C1BC /* Localizable.strings */; };
A9B7BD791B3C083E00C0B1D7 /* MyMessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B7BD771B3C083E00C0B1D7 /* MyMessageTableViewCell.m */; };
A9B7BD7A1B3C083E00C0B1D7 /* MyMessageTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9B7BD781B3C083E00C0B1D7 /* MyMessageTableViewCell.xib */; };
A9B8FEC51B32A4CF00619C7D /* ChatMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B8FEC31B32A4CF00619C7D /* ChatMainViewController.m */; };
A9B8FEC61B32A4CF00619C7D /* ChatMainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9B8FEC41B32A4CF00619C7D /* ChatMainViewController.xib */; };
A9B8FEC91B32AC7000619C7D /* DXMessageToolBar.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B8FEC81B32AC7000619C7D /* DXMessageToolBar.m */; };
@@ -819,6 +825,12 @@
A97C54FB1AC933AD0038818A /* UMSShareListController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UMSShareListController.xib; sourceTree = "<group>"; };
A97C54FC1AC933AD0038818A /* UMSocialSDKResourcesNew.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = UMSocialSDKResourcesNew.bundle; sourceTree = "<group>"; };
A97C54FD1AC933AD0038818A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/UMSocialLocalizable.strings"; sourceTree = "<group>"; };
A97CCE261B3BE6440046FE17 /* MessageListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageListViewController.h; sourceTree = "<group>"; };
A97CCE271B3BE6440046FE17 /* MessageListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageListViewController.m; sourceTree = "<group>"; };
A97CCE281B3BE6440046FE17 /* MessageListViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageListViewController.xib; sourceTree = "<group>"; };
A97CCE2B1B3BEBDA0046FE17 /* MessageListTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageListTableViewCell.h; sourceTree = "<group>"; };
A97CCE2C1B3BEBDA0046FE17 /* MessageListTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageListTableViewCell.m; sourceTree = "<group>"; };
A97CCE2D1B3BEBDA0046FE17 /* MessageListTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageListTableViewCell.xib; sourceTree = "<group>"; };
A97DBE301ACAE10800705682 /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
A97DBE311ACAE10800705682 /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
A97DBE321ACAE10800705682 /* LoginViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LoginViewController.xib; sourceTree = "<group>"; };
@@ -905,6 +917,9 @@
A9B6DFE51B2033A80003C1BC /* toolbar_light_comment@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "toolbar_light_comment@2x.png"; sourceTree = "<group>"; };
A9B6DFED1B2068790003C1BC /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
A9B6DFEF1B20687B0003C1BC /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
A9B7BD761B3C083E00C0B1D7 /* MyMessageTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyMessageTableViewCell.h; sourceTree = "<group>"; };
A9B7BD771B3C083E00C0B1D7 /* MyMessageTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyMessageTableViewCell.m; sourceTree = "<group>"; };
A9B7BD781B3C083E00C0B1D7 /* MyMessageTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MyMessageTableViewCell.xib; sourceTree = "<group>"; };
A9B8FEBB1B32930100619C7D /* libEaseMobClientSDKLite.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libEaseMobClientSDKLite.a; sourceTree = "<group>"; };
A9B8FEC21B32A4CF00619C7D /* ChatMainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatMainViewController.h; sourceTree = "<group>"; };
A9B8FEC31B32A4CF00619C7D /* ChatMainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatMainViewController.m; sourceTree = "<group>"; };
@@ -1202,6 +1217,9 @@
A9B4A9511AEDC3620017C655 /* FeedbackViewController.h */,
A9B4A9521AEDC3620017C655 /* FeedbackViewController.m */,
A9B4A9531AEDC3620017C655 /* FeedbackViewController.xib */,
A97CCE261B3BE6440046FE17 /* MessageListViewController.h */,
A97CCE271B3BE6440046FE17 /* MessageListViewController.m */,
A97CCE281B3BE6440046FE17 /* MessageListViewController.xib */,
);
path = My;
sourceTree = "<group>";
@@ -1323,6 +1341,9 @@
A9A3A74C1B2805DA001AAB3A /* PersonalTopView.h */,
A9A3A74D1B2805DA001AAB3A /* PersonalTopView.m */,
A9A3A74F1B2805EA001AAB3A /* PersonalTopView.xib */,
A97CCE2B1B3BEBDA0046FE17 /* MessageListTableViewCell.h */,
A97CCE2C1B3BEBDA0046FE17 /* MessageListTableViewCell.m */,
A97CCE2D1B3BEBDA0046FE17 /* MessageListTableViewCell.xib */,
);
path = User;
sourceTree = "<group>";
@@ -2330,6 +2351,9 @@
A9B6DFCA1B1FFDB20003C1BC /* CommentTextView.h */,
A9B6DFCB1B1FFDB20003C1BC /* CommentTextView.m */,
A9B6DFD11B20054B0003C1BC /* CommentTextView.xib */,
A9B7BD761B3C083E00C0B1D7 /* MyMessageTableViewCell.h */,
A9B7BD771B3C083E00C0B1D7 /* MyMessageTableViewCell.m */,
A9B7BD781B3C083E00C0B1D7 /* MyMessageTableViewCell.xib */,
);
path = Common;
sourceTree = "<group>";
@@ -2571,6 +2595,7 @@
A971EDF31B32B7AF0023740E /* chatBar_more_locationSelected@2x.png in Resources */,
A971EDF41B32B7AF0023740E /* chatBar_more_photo@2x.png in Resources */,
A971EE0A1B32B7C40023740E /* chatBar_colorMore_video@2x.png in Resources */,
A9B7BD7A1B3C083E00C0B1D7 /* MyMessageTableViewCell.xib in Resources */,
A99AA12F1ADD028400574B12 /* Icon120.png in Resources */,
A98536821AEBC7BB000312BF /* SetUserInfoViewController.xib in Resources */,
A9C58DED1B3AA8EC0007FCDC /* VoiceSearchFeedback004.png in Resources */,
@@ -2675,6 +2700,7 @@
A971EDF21B32B7AF0023740E /* chatBar_more_location@2x.png in Resources */,
A9FD82BD1B1D544300AC4DC9 /* CommentTableViewCell.xib in Resources */,
A971EE091B32B7C40023740E /* chatBar_colorMore_photoSelected@2x.png in Resources */,
A97CCE2A1B3BE6440046FE17 /* MessageListViewController.xib in Resources */,
A9C58DE31B3AA8EC0007FCDC /* chatFire_audioPlaying2.png in Resources */,
A98536731AEB66F9000312BF /* ReportViewController.xib in Resources */,
A9C58DF61B3AA8EC0007FCDC /* VoiceSearchFeedback008@2x.png in Resources */,
@@ -2709,6 +2735,7 @@
A93441E51ACA8AC400A6B233 /* Profile_filter_contentIcon@2x.png in Resources */,
A971EDF11B32B7AF0023740E /* chatBar_more_cameraSelected@2x.png in Resources */,
A97559B31ACBC683004ADA42 /* NotePublishViewController.xib in Resources */,
A97CCE2F1B3BEBDA0046FE17 /* MessageListTableViewCell.xib in Resources */,
A966FB991AD62CAE00542068 /* checkmark@2x.png in Resources */,
A9C58E0C1B3AA8EC0007FCDC /* VoiceSearchFeedback019@2x.png in Resources */,
A978CB401B3A3D7100028C4A /* chat_location_detail_disclosure@2x.png in Resources */,
@@ -2841,6 +2868,7 @@
A9F917D31B3906150007A3AC /* MessageModelManager.m in Sources */,
A9754A1D1ADC080E0018BAAD /* AutoRecoveringHttpDataSource.m in Sources */,
A971EDB61B32B5740023740E /* EMCDDeviceManager+Remind.m in Sources */,
A97CCE2E1B3BEBDA0046FE17 /* MessageListTableViewCell.m in Sources */,
A97C54CD1AC8F10F0038818A /* BaseViewModel.m in Sources */,
A9754A261ADC199B0018BAAD /* MyMessageViewController.m in Sources */,
A9617A4F1ACC0D0F0024AE4A /* NoteViewModel.m in Sources */,
@@ -2872,6 +2900,7 @@
A97C54D01AC8F10F0038818A /* PropertyEntity.m in Sources */,
A96F27F91B21C5C800DA0A66 /* PraiseUserListViewController.m in Sources */,
A93441DE1ACA311700A6B233 /* Ash_UIUtil.m in Sources */,
A9B7BD791B3C083E00C0B1D7 /* MyMessageTableViewCell.m in Sources */,
A9B8FEC91B32AC7000619C7D /* DXMessageToolBar.m in Sources */,
A968624C1ACCF0B400DDAA6B /* README.md in Sources */,
A9754A1E1ADC080E0018BAAD /* CoreFoundationDataSource.m in Sources */,
@@ -2906,6 +2935,7 @@
A96862431ACCF0B400DDAA6B /* MWCaptionView.m in Sources */,
A9F7F45F1B33BC4E00317F3E /* CallViewController.m in Sources */,
A971EDCA1B32B6A40023740E /* EMVoiceConverter.mm in Sources */,
A97CCE291B3BE6440046FE17 /* MessageListViewController.m in Sources */,
A9FD82BC1B1D544300AC4DC9 /* CommentTableViewCell.m in Sources */,
A9B6DFCC1B1FFDB20003C1BC /* CommentTextView.m in Sources */,
A96F27EE1B2195BA00DA0A66 /* UIImageView+Reloading.m in Sources */,
+7 -1
View File
@@ -50,9 +50,15 @@
}
#endif
NSString* apnsCertName = EaseMobApnsCertName_Dev;
#if DEBUG
apnsCertName = EaseMobApnsCertName_Dev;
#else
apnsCertName = EaseMobApnsCertNameProduct;
#endif
//注册 APNS文件的名字, 需要与后台上传证书时的名字一一对应
[[EaseMob sharedInstance] registerSDKWithAppKey:EaseMobAppKey apnsCertName:EaseMobApnsCertName];
[[EaseMob sharedInstance] registerSDKWithAppKey:EaseMobAppKey apnsCertName:apnsCertName];
// 需要在注册sdk后写上该方法
[[EaseMob sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
+5 -1
View File
@@ -53,6 +53,8 @@
#define kLoginSuccessNotificationName @"kLoginSuccessNotificationName"
#define kLogoutSuccessNotificationName @"kLogoutSuccessNotificationName"
#define kReceiveMessage @"kReceiveMessage"
//文字标签
#define kNetworkErrorTips @"网络连接失败"
#define kSSoErrorTips @"授权失败,请重新授权"
@@ -64,13 +66,15 @@
#define Ash_AWord_API_URL @"http://121.43.150.13/QuestionServer/rs/yjn/post"
#define Ash_AWord_First_URL @"http://121.43.150.13"
#define Ash_AWord_Share_URL @"http://121.43.150.13/QuestionServer/web"
//#define Ash_AWord_API_URL @"http://192.168.1.3:8080/QuestionServer"
#define Sign_Key @"yjn@jjyy123"
/**
*环信信息
*/
#define EaseMobApnsCertName @"yujianni"
#define EaseMobApnsCertName_Dev @"yujianni"
#define EaseMobApnsCertNameProduct @"yujianni_product"
#define EaseMobAppKey @"ash#ashyujianni"
#define EasePassword @"123456"
/**
@@ -39,7 +39,7 @@
"message.startRecordFail" = "failure to start recording";
"message.noMessage" = "no messages";
"The other side is not online" = "The other side is not online";
//location
"location.messageType" = "location message";
"location.fail" = "locate failure";
@@ -38,6 +38,8 @@
"message.startRecordFail" = "开始录音失败";
"message.noMessage" = "消息已经清空";
"The other side is not online" = "对方不在线";
"search" = "搜索";
"error" = "错误";
"delete" = "删除";
@@ -144,8 +144,6 @@
[self saveCacheWithAPIKey:apiKey property:proper data:tweet];
}
failure:^(AFHTTPRequestOperation *__unused task, NSError *error) {
NSLog(@"%@", error.description);
if (failedBlock) {
failedBlock(error);
}
+5
View File
@@ -21,6 +21,8 @@
[self loginWithUserName:username];
}else if (error.errorCode == EMErrorServerDuplicatedAccount) {
[self loginWithUserName:username];
}else{
[self loginWithUserName:username];
}
} onQueue:nil];
@@ -32,9 +34,12 @@
// 设置自动登录
[[EaseMob sharedInstance].chatManager setIsAutoLoginEnabled:YES];
DLog(@"登陆成功");
[[NSNotificationCenter defaultCenter] postNotificationName:kLogoutSuccessNotificationName object:nil];
}
EMPushNotificationOptions *options = [[EaseMob sharedInstance].chatManager pushNotificationOptions];
options.nickname = [AWordUser sharedInstance].userName;
options.displayStyle = ePushNotificationDisplayStyle_messageSummary;
[[EaseMob sharedInstance].chatManager asyncUpdatePushOptions:options];
} onQueue:nil];
}
@@ -57,6 +57,6 @@ static CTCallCenter *g_callCenter;
- (instancetype)initWithSession:(EMCallSession *)session
isIncoming:(BOOL)isIncoming withName:(NSString*)name withAvatar:(NSString*)avatar;
+ (BOOL)canVideo;
+ (BOOL)canVideoWithAlertStr:(NSString*)str;
@end
@@ -28,7 +28,6 @@
self = [super initWithNibName:nil bundle:nil];
if (self) {
_callSession = session;
_isIncoming = isIncoming;
_timeLabel.text = @"";
_timeLength = 0;
@@ -36,7 +35,11 @@
_avatar = avatar;
[[EaseMob sharedInstance].callManager removeDelegate:self];
[[EaseMob sharedInstance].callManager addDelegate:self delegateQueue:nil];
if(!isIncoming && session.type==eCallSessionTypeAudio)
{
[self _beginRing];
}
g_callCenter = [[CTCallCenter alloc] init];
g_callCenter.callEventHandler=^(CTCall* call)
{
@@ -295,6 +298,9 @@
{
[_ringPlayer stop];
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryAmbient error:nil];
[audioSession setActive:YES error:nil];
NSString *musicPath = [[NSBundle mainBundle] pathForResource:@"callRing" ofType:@"mp3"];
NSURL *url = [[NSURL alloc] initFileURLWithPath:musicPath];
@@ -481,12 +487,13 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
// [self hideHud];
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
[self _stopRing];
if(error){
[self _stopRing];
_statusLabel.text = @"连接失败";
[self _insertMessageWithStr:@"通话失败"];
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"error", @"Error") message:error.description delegate:self cancelButtonTitle:NSLocalizedString(@"ok", @"OK") otherButtonTitles:nil, nil];
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"error", @"Error") message:NSLocalizedString(error.description, error.description) delegate:self cancelButtonTitle:NSLocalizedString(@"ok", @"OK") otherButtonTitles:nil, nil];
errorAlert.tag = kAlertViewTag_Close;
[errorAlert show];
@@ -494,6 +501,8 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
}
if (callSession.status == eCallSessionStatusDisconnected) {
[self _stopRing];
NSLog(@"callSession.status == eCallSessionStatusDisconnected");
_statusLabel.text = @"通话已挂断";
NSString *str = @"通话结束";
@@ -514,6 +523,8 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
}
else if (callSession.status == eCallSessionStatusAccepted)
{
[self _stopRing];
_statusLabel.text = @"可以通话了...";
_timeLength = 0;
_timeTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timeTimerAction:) userInfo:nil repeats:YES];
@@ -581,7 +592,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
if(![_audioCategory isEqualToString:AVAudioSessionCategoryPlayAndRecord]){
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[audioSession setActive:YES error:nil];
NSLog(@"xieyajie===========2");
}
[[EaseMob sharedInstance].callManager asyncAnswerCall:_callSession.sessionId];
@@ -601,11 +611,12 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
[[EaseMob sharedInstance].callManager asyncEndCall:_callSession.sessionId reason:eCallReason_Hangup];
}
+ (BOOL)canVideo
+ (BOOL)canVideoWithAlertStr:(NSString *)str
{
if([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending){
if(!([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo] == AVAuthorizationStatusAuthorized)){\
UIAlertView * alt = [[UIAlertView alloc] initWithTitle:@"未获得授权使用摄像头" message:@"请在iOS\"设置中\"-\"隐私\"-\"相机\"中打开" delegate:self cancelButtonTitle:nil otherButtonTitles:@"知道了", nil];
if(!([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo] == AVAuthorizationStatusAuthorized)){
NSString* alertMsg = [NSString stringWithFormat:@"%@请在iOS\"设置中\"-\"隐私\"-\"相机\"中打开",str];
UIAlertView * alt = [[UIAlertView alloc] initWithTitle:@"未获得授权使用摄像头" message:alertMsg delegate:self cancelButtonTitle:nil otherButtonTitles:@"知道了", nil];
[alt show];
return NO;
}
@@ -73,22 +73,7 @@
return _slimeView;
}
- (instancetype)initWithChatter:(NSString *)chatter conversationType:(EMConversationType)type
{
self = [super initWithNibName:nil bundle:nil];
if (self) {
_isPlayingAudio = NO;
// _chatter = chatter;
// _conversationType = type;
_messages = [NSMutableArray array];
//根据接收者的username获取当前会话的管理者
_conversation = [[EaseMob sharedInstance].chatManager conversationForChatter:chatter conversationType:type];
[_conversation markAllMessagesAsRead:YES];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
@@ -102,6 +87,12 @@
self.navigationItem.title = _otherUserName;
if (!_otherUserName) {
_otherUserName = @"";
}
if (!_otherUserAvatar) {
_otherUserAvatar = @"";
}
//根据接收者的username获取当前会话的管理者
_conversation = [[EaseMob sharedInstance].chatManager conversationForChatter:_otherUserId conversationType:eConversationTypeChat];
[_conversation markAllMessagesAsRead:YES];
@@ -365,18 +356,19 @@
{
// 隐藏键盘
[self keyBoardHidden];
EMCallSession *callSession = nil;
EMError *error = nil;
if (![CallViewController canVideo]) {
return;
}
callSession = [[EaseMob sharedInstance].callManager asyncMakeVideoCall:_conversation.chatter timeout:50 error:&error];
CallViewController *callController = [[CallViewController alloc] initWithSession:callSession isIncoming:NO withName:_otherUserName withAvatar:_otherUserAvatar];
callController.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:callController animated:NO completion:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"callOutWithChatter" object:@{@"chatter":_otherUserId, @"type":[NSNumber numberWithInt:eCallSessionTypeVideo],@"username":_otherUserName,@"useravatar":_otherUserAvatar}];
// EMCallSession *callSession = nil;
// EMError *error = nil;
//
// if (![CallViewController canVideo]) {
// return;
// }
// callSession = [[EaseMob sharedInstance].callManager asyncMakeVideoCall:_conversation.chatter timeout:50 error:&error];
//
//
// CallViewController *callController = [[CallViewController alloc] initWithSession:callSession isIncoming:NO withName:_otherUserName withAvatar:_otherUserAvatar];
// callController.modalPresentationStyle = UIModalPresentationOverFullScreen;
// [self presentViewController:callController animated:NO completion:nil];
}
#pragma mark - helper
@@ -10,4 +10,5 @@
@interface MainViewController : UITabBarController
-(NSInteger)setupUnreadMessageCount;
@end
@@ -92,6 +92,7 @@ static NSString *kMessageType = @"MessageType";
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callOutWithChatter:) name:@"callOutWithChatter" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callControllerClose:) name:@"callControllerClose" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupUnreadMessageCount) name:kLogoutSuccessNotificationName object:nil];
self.selectedIndex = 0;
}
@@ -142,7 +143,7 @@ static NSString *kMessageType = @"MessageType";
// 统计未读消息数
-(void)setupUnreadMessageCount
-(NSInteger)setupUnreadMessageCount
{
NSArray *conversations = [[[EaseMob sharedInstance] chatManager] conversations];
@@ -157,9 +158,10 @@ static NSString *kMessageType = @"MessageType";
_myNav.tabBarItem.badgeValue = nil;
}
}
UIApplication *application = [UIApplication sharedApplication];
[application setApplicationIconBadgeNumber:unreadCount];
return unreadCount;
}
@@ -232,6 +234,8 @@ static NSString *kMessageType = @"MessageType";
// 收到消息回调
-(void)didReceiveMessage:(EMMessage *)message
{
[[NSNotificationCenter defaultCenter] postNotificationName:kReceiveMessage object:nil];
BOOL needShowNotification = (message.messageType != eMessageTypeChat) ? [self needShowNotification:message.conversationChatter] : YES;
if (needShowNotification) {
#if !TARGET_IPHONE_SIMULATOR
@@ -396,21 +400,21 @@ static NSString *kMessageType = @"MessageType";
#pragma mark - 自动登录回调
- (void)willAutoReconnect{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
[MBProgressHUD checkHudWithView:self.view label:NSLocalizedString(@"reconnection.ongoing", @"reconnecting...") hidesAfter:1.0];
// [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
// [MBProgressHUD checkHudWithView:self.view label:NSLocalizedString(@"reconnection.ongoing", @"reconnecting...") hidesAfter:1.0];
// [self hideHud];
// [self showHint:NSLocalizedString(@"reconnection.ongoing", @"reconnecting...")];
}
- (void)didAutoReconnectFinishedWithError:(NSError *)error{
// [self hideHud];
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
if (error) {
[MBProgressHUD checkHudWithView:self.view label:NSLocalizedString(@"reconnection.fail", @"reconnection failure, later will continue to reconnection") hidesAfter:1.0];
}else{
[MBProgressHUD checkHudWithView:self.view label:NSLocalizedString(@"reconnection.success", @"reconnection successful") hidesAfter:1.0];
}
// [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
//
// if (error) {
// [MBProgressHUD checkHudWithView:self.view label:NSLocalizedString(@"reconnection.fail", @"reconnection failure, later will continue to reconnection") hidesAfter:1.0];
// }else{
// [MBProgressHUD checkHudWithView:self.view label:NSLocalizedString(@"reconnection.success", @"reconnection successful") hidesAfter:1.0];
// }
}
#pragma mark - ICallManagerDelegate
@@ -433,7 +437,7 @@ static NSString *kMessageType = @"MessageType";
}
#warning 在后台不能进行视频通话
if(callSession.type == eCallSessionTypeVideo && ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground || ![CallViewController canVideo])){
if(callSession.type == eCallSessionTypeVideo && ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground || ![CallViewController canVideoWithAlertStr:@"有人想与你视频,如果需要视频,"])){
error = [EMError errorWithCode:EMErrorInitFailure andDescription:@"不能进行视频通话"];
break;
}
@@ -470,7 +474,7 @@ static NSString *kMessageType = @"MessageType";
callSession = [[EaseMob sharedInstance].callManager asyncMakeVoiceCall:chatter timeout:50 error:&error];
}
else if (type == eCallSessionTypeVideo){
if (![CallViewController canVideo]) {
if (![CallViewController canVideoWithAlertStr:@""]) {
return;
}
callSession = [[EaseMob sharedInstance].callManager asyncMakeVideoCall:chatter timeout:50 error:&error];
@@ -14,9 +14,14 @@
#import "MyNoteViewController.h"
#import "MyMessageViewController.h"
#import "SetUserInfoViewController.h"
#import "MessageListViewController.h"
#import "MyMessageTableViewCell.h"
#import "MainViewController.h"
#import "AppDelegate.h"
@interface MyViewController ()
{
NSArray* cellTitleArr;
}
@end
@@ -49,8 +54,14 @@
//注册通知的观察者
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:kLoginSuccessNotificationName object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:kLogoutSuccessNotificationName object:nil];
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:kReceiveMessage object:nil];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.tableView reloadData];
}
-(void)goSetUp
{
SetUpViewController* setUpViewController = [[SetUpViewController alloc] init];
@@ -64,7 +75,7 @@
#pragma mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
@@ -76,9 +87,21 @@
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString* cellIdentifier = @"cell";
if (indexPath.section == 2) {
cellIdentifier = @"MyMessageTableViewCell";
}
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
if (indexPath.section == 2) {
UINib* nib = nil;
nib = [UINib nibWithNibName:cellIdentifier bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:cellIdentifier];
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}else{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
}
switch (indexPath.section) {
@@ -109,7 +132,9 @@
break;
case 2:
{
cell.textLabel.text = @"推荐给朋友";
cell.textLabel.text = @"消息";
NSInteger count = [((AppDelegate*)[UIApplication sharedApplication].delegate).mainViewController setupUnreadMessageCount];
[(MyMessageTableViewCell*)cell setUnReadCount:count];
}
break;
default:
@@ -156,6 +181,13 @@
}
}
}
break;
case 2:
{
MessageListViewController* messageListViewController = [[MessageListViewController alloc] init];
messageListViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:messageListViewController animated:YES];
}
break;
default:
@@ -163,7 +163,7 @@
{
[MobClick event:kUmen_note];
PropertyEntity* pro = [NoteViewModel requireWithOrder_by:Order_by_Time withPage:_page withPage_size:20];
PropertyEntity* pro = [NoteViewModel requireWithOrder_by:Order_by_Time withPage:_page withPage_size:DefaultPageSize];
[RequireEngine requireWithProperty:pro completionBlock:^(id viewModel) {
NoteViewModel* noteViewModel = (NoteViewModel*)viewModel;
@@ -0,0 +1,14 @@
//
// MessageListViewController.h
// Ash_AWord
//
// Created by xmfish on 15/6/25.
// Copyright (c) 2015年 ash. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "BaseRefreshViewController.h"
@interface MessageListViewController : BaseRefreshViewController
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end
@@ -0,0 +1,176 @@
//
// MessageListViewController.m
// Ash_AWord
//
// Created by xmfish on 15/6/25.
// Copyright (c) 2015年 ash. All rights reserved.
//
#import "MessageListViewController.h"
#import "MessageListTableViewCell.h"
#import "ChatMainViewController.h"
#import "UserViewModel.h"
@interface MessageListViewController ()
{
NSInteger _page;
NSMutableArray* _dataArr;
NSMutableArray* _userArr;
}
@end
@implementation MessageListViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self customViewDidLoad];
_userArr = [NSMutableArray array];
self.navigationItem.title = @"消息列表";
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView removeFooter];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self loadData];
}
-(void)headerRereshing
{
_page=1;
[self loadData];
}
-(void)footerRereshing
{
[self loadData];
}
-(void)loadData
{
NSArray *conversations = [[EaseMob sharedInstance].chatManager conversations];
NSArray* sorte = [conversations sortedArrayUsingComparator:
^(EMConversation *obj1, EMConversation* obj2){
EMMessage *message1 = [obj1 latestMessage];
EMMessage *message2 = [obj2 latestMessage];
if(message1.timestamp > message2.timestamp) {
return(NSComparisonResult)NSOrderedAscending;
}else {
return(NSComparisonResult)NSOrderedDescending;
}
}];
_dataArr = [[NSMutableArray alloc] initWithArray:sorte];
NSMutableArray* uidArr = [NSMutableArray array];
for (EMConversation* conversation in _dataArr) {
[uidArr addObject:conversation.chatter];
}
PropertyEntity* pro = [UserViewModel requireUserListWithUid:uidArr];
[RequireEngine requireWithProperty:pro completionBlock:^(id viewModel) {
if ([viewModel success]) {
[_userArr removeAllObjects];
_userArr = [NSMutableArray arrayWithArray:[(UserViewModel*)viewModel userBaseInfoArr]];
}
[self.tableView reloadData];
[self.tableView.header endRefreshing];
} failedBlock:^(NSError *error) {
[self.tableView reloadData];
[self.tableView.header endRefreshing];
}];
}
#pragma mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _dataArr.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50.0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 10.0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.01;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString* cellIdentifier = @"MessageListTableViewCell";
MessageListTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
UINib* nib = nil;
nib = [UINib nibWithNibName:cellIdentifier bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:cellIdentifier];
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}
EMConversation* conversation = [_dataArr objectAtIndex:indexPath.row];
[cell setEMConversation:conversation];
UserInfoViewModel* userinfo;
for (UserInfoViewModel* user in _userArr) {
if ([user.uid isEqualToString:conversation.chatter]) {
userinfo = user;
break;
}
}
[cell setUserInfo:userinfo];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
EMConversation* conversation = [_dataArr objectAtIndex:indexPath.row];
ChatMainViewController* chatMainViewController = [[ChatMainViewController alloc] init];
chatMainViewController.otherUserId = conversation.chatter;
chatMainViewController.otherUserName = conversation.chatter;
for (UserInfoViewModel* user in _userArr) {
if ([user.uid isEqualToString:conversation.chatter]) {
chatMainViewController.otherUserAvatar = user.figureurl;
chatMainViewController.otherUserName = user.name;
break;
}
}
[self.navigationController pushViewController:chatMainViewController animated:YES];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MessageListViewController">
<connections>
<outlet property="tableView" destination="H7S-Oj-mSu" id="Dgg-OX-ZqY"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="H7S-Oj-mSu">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="H7S-Oj-mSu" secondAttribute="bottom" id="49H-eS-W4J"/>
<constraint firstAttribute="trailing" secondItem="H7S-Oj-mSu" secondAttribute="trailing" id="Bdc-A4-N0k"/>
<constraint firstItem="H7S-Oj-mSu" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="j5Q-Za-BcT"/>
<constraint firstItem="H7S-Oj-mSu" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="ohU-sl-3tv"/>
</constraints>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</objects>
</document>
@@ -197,7 +197,7 @@
if (buttonIndex == 1 &&alertView.tag == 101) {
[MobClick event:kUmen_logout];
[[EaseMob sharedInstance].chatManager asyncLogoffWithUnbindDeviceToken:NO completion:^(NSDictionary *info, EMError *error) {
[[EaseMob sharedInstance].chatManager asyncLogoffWithUnbindDeviceToken:YES completion:^(NSDictionary *info, EMError *error) {
if (!error && info) {
}
@@ -262,10 +262,7 @@
}
if(content.length <= 0)
{
content = @"最真的表白,是我欲言又止的沉默";
}
if (url.length <= 0) {
NSString *str = [NSString stringWithFormat:@"http://itunes.apple.com/us/app/id%d", kAppleID];
@@ -27,6 +27,7 @@
@property (nonatomic, strong) NSArray *userInfoArr;
@property (nonatomic, strong) NSArray *friendUserArr;
@property (nonatomic, strong)UserInfoViewModel* userInfo;
@property (nonatomic, strong) NSArray *userBaseInfoArr;
@property (nonatomic, assign)NSInteger relation;//与当前用户关系。0:没有关系,1:已关注此人,2:已被此人关注,3:相互关注(如果是获取自己的个人信息,可以无视该项0.0)
+(PropertyEntity*)requireLoadPraiseUserWithRecordId:(NSInteger)recordId withPage:(NSInteger)page withPage_size:(NSInteger)page_size withType:(CommentType)type;
@@ -34,4 +35,6 @@
+(PropertyEntity*)requireLoadUserListWithTargetUid:(NSString*)targetUid withType:(NSInteger)isAttention withPage:(NSInteger)page withPage_size:(NSInteger)page_size; // 1是关注列表,2是粉丝列表
+(PropertyEntity*)requireAttentionWithTargetUid:(NSString*)targetUid withIsAttention:(BOOL)isAttention;
+(PropertyEntity*)requireUserListWithUid:(NSArray*)uidArr;
@end
@@ -21,6 +21,7 @@
[dic setObject:@"users" forKey:@"userInfoArr"];
[dic setObject:@"friends" forKey:@"friendUserArr"];
[dic setObject:@"userinfo" forKey:@"userInfo"];
[dic setObject:@"userBaseInfos" forKey:@"userBaseInfoArr"];
return dic;
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionaryValue error:(NSError **)error {
@@ -33,6 +34,9 @@
return self;
}
+ (NSValueTransformer *)userBaseInfoArrJSONTransformer{
return [NSValueTransformer mtl_JSONArrayTransformerWithModelClass:UserInfoViewModel.class];
}
+ (NSValueTransformer *)userInfoArrJSONTransformer{
return [NSValueTransformer mtl_JSONArrayTransformerWithModelClass:UserInfoViewModel.class];
}
@@ -115,4 +119,23 @@
};
return pro;
}
+(PropertyEntity*)requireUserListWithUid:(NSArray *)uidArr
{
PropertyEntity *pro = [[PropertyEntity alloc] init];
pro.requireType = HTTPRequestTypeWithPOSTDATA;
pro.responesOBJ = self.class;
if (uidArr.count == 0) {
uidArr = [NSArray array];
}
NSDictionary* dic = @{@"targetUids": uidArr,
};
NSString* command = @"10010";
pro.pro = @{@"root": dic,
@"command": command,
};
return pro;
}
@end
@@ -0,0 +1,15 @@
//
// MyMessageTableViewCell.h
// Ash_AWord
//
// Created by xmfish on 15/6/25.
// Copyright (c) 2015年 ash. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MyMessageTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *unReadCountLabel;
-(void)setUnReadCount:(NSInteger)unReadConut;
@end
@@ -0,0 +1,33 @@
//
// MyMessageTableViewCell.m
// Ash_AWord
//
// Created by xmfish on 15/6/25.
// Copyright (c) 2015 ash. All rights reserved.
//
#import "MyMessageTableViewCell.h"
@implementation MyMessageTableViewCell
- (void)awakeFromNib {
// Initialization code
_unReadCountLabel.layer.cornerRadius = 10.0;
_unReadCountLabel.layer.masksToBounds = YES;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)setUnReadCount:(NSInteger)unReadConut
{
if (unReadConut > 0) {
_unReadCountLabel.hidden = NO;
_unReadCountLabel.text = [NSString stringWithFormat:@"%ld",unReadConut];
}else{
_unReadCountLabel.hidden = YES;
}
}
@end
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="MyMessageTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="999" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UJW-wi-X9b">
<rect key="frame" x="292" y="12" width="20" height="20"/>
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="bgT-op-GYj"/>
<constraint firstAttribute="width" secondItem="UJW-wi-X9b" secondAttribute="height" multiplier="1:1" id="zEs-5v-J5z"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="UJW-wi-X9b" firstAttribute="width" secondItem="UJW-wi-X9b" secondAttribute="height" multiplier="1:1" id="JkU-S4-FxF"/>
<constraint firstAttribute="centerY" secondItem="UJW-wi-X9b" secondAttribute="centerY" id="Tqv-Nh-sxE"/>
<constraint firstItem="UJW-wi-X9b" firstAttribute="trailing" secondItem="H2p-sc-9uM" secondAttribute="trailingMargin" id="Tz5-NI-cGm"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="unReadCountLabel" destination="UJW-wi-X9b" id="IFt-Ua-U9N"/>
</connections>
</tableViewCell>
</objects>
</document>
@@ -176,7 +176,7 @@
}
- (IBAction)shareBtnClick:(id)sender {
[SetUpViewController shareAppWithViewController:nil andTitle:@"遇见你" andContent:_text_voice.content andImage:nil andUrl:[NSString stringWithFormat:@"%@/web/voice_share_info?record_id=%ld",Ash_AWord_API_URL,_text_voice.messageId]];
[SetUpViewController shareAppWithViewController:nil andTitle:@"遇见你" andContent:_text_voice.content andImage:nil andUrl:[NSString stringWithFormat:@"%@/voice_share_info?record_id=%ld",Ash_AWord_Share_URL,_text_voice.messageId]];
PropertyEntity* pro = [MessageViewModel requireShareWithRecordId:_text_voice.messageId];
[RequireEngine requireWithProperty:pro completionBlock:^(id viewModel) {
if ([viewModel success]) {
+1 -1
View File
@@ -130,7 +130,7 @@
- (IBAction)shareBtnClick:(id)sender
{
[SetUpViewController shareAppWithViewController:nil andTitle:@"遇见你" andContent:_text_image.content andImage:_contentImgView.image andUrl:[NSString stringWithFormat:@"%@/web/image_share_info?record_id=%ld",Ash_AWord_API_URL,(long)_text_image.messageId]];
[SetUpViewController shareAppWithViewController:nil andTitle:@"遇见你" andContent:_text_image.content andImage:_contentImgView.image andUrl:[NSString stringWithFormat:@"%@/image_share_info?record_id=%ld",Ash_AWord_Share_URL,(long)_text_image.messageId]];
PropertyEntity* pro = [NoteViewModel requireShareWithRecordId:_text_image.messageId];
[RequireEngine requireWithProperty:pro completionBlock:^(id viewModel) {
if ([viewModel success]) {
@@ -0,0 +1,21 @@
//
// MessageListTableViewCell.h
// Ash_AWord
//
// Created by xmfish on 15/6/25.
// Copyright (c) 2015年 ash. All rights reserved.
//
#import <UIKit/UIKit.h>
@class EMConversation;
@class UserInfoViewModel;
@interface MessageListTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *unReadLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *lastMsgLabel;
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
-(void)setEMConversation:(EMConversation*)conversation;
-(void)setUserInfo:(UserInfoViewModel*)userInfo;
@end
@@ -0,0 +1,100 @@
//
// MessageListTableViewCell.m
// Ash_AWord
//
// Created by xmfish on 15/6/25.
// Copyright (c) 2015 ash. All rights reserved.
//
#import "MessageListTableViewCell.h"
#import "EMConversation.h"
#import "ConvertToCommonEmoticonsHelper.h"
#import "UserViewModel.h"
@implementation MessageListTableViewCell
- (void)awakeFromNib {
// Initialization code
_unReadLabel.layer.cornerRadius = 10.0;
_unReadLabel.layer.masksToBounds = YES;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)setUnReadCount:(NSInteger)count
{
if (count == 0) {
_unReadLabel.hidden = YES;
}else{
_unReadLabel.hidden = NO;
_unReadLabel.text = [NSString stringWithFormat:@"%ld",count];
}
}
-(void)setEMConversation:(EMConversation *)conversation
{
EMMessage *lastMessage = [conversation latestMessage];;
if (lastMessage) {
_timeLabel.hidden = NO;
NSString* str = [NSString stringWithFormat:@"%lld",lastMessage.timestamp];
_timeLabel.text = [CommonUtil timeFromtimeSp:str];
}else{
_timeLabel.hidden = YES;
}
[self setUnReadCount:conversation.unreadMessagesCount];
_lastMsgLabel.text = [self subTitleMessageByConversation:conversation];
_nameLabel.text = conversation.chatter;
}
-(void)setUserInfo:(UserInfoViewModel *)userInfo
{
if (userInfo) {
_nameLabel.text = userInfo.name;
[_avatarImageView sd_setImageWithURL:[NSURL URLWithString:userInfo.figureurl] placeholderImage:DefaultUserIcon];
}else{
[_avatarImageView sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:DefaultUserIcon];
}
}
//
-(NSString *)subTitleMessageByConversation:(EMConversation *)conversation
{
NSString *ret = @"";
EMMessage *lastMessage = [conversation latestMessage];
if (lastMessage) {
id<IEMMessageBody> messageBody = lastMessage.messageBodies.lastObject;
switch (messageBody.messageBodyType) {
case eMessageBodyType_Image:{
ret = NSLocalizedString(@"message.image1", @"[image]");
} break;
case eMessageBodyType_Text:{
//
NSString *didReceiveText = [ConvertToCommonEmoticonsHelper
convertToSystemEmoticons:((EMTextMessageBody *)messageBody).text];
ret = didReceiveText;
} break;
case eMessageBodyType_Voice:{
ret = NSLocalizedString(@"message.voice1", @"[voice]");
} break;
case eMessageBodyType_Location: {
ret = NSLocalizedString(@"message.location1", @"[location]");
} break;
case eMessageBodyType_Video: {
ret = NSLocalizedString(@"message.vidio1", @"[vidio]");
} break;
default: {
} break;
}
}
return ret;
}
@end
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="MessageListTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lBL-iI-Mzy">
<rect key="frame" x="292" y="20" width="20" height="20"/>
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="XUz-p2-ApH"/>
<constraint firstAttribute="width" secondItem="lBL-iI-Mzy" secondAttribute="height" multiplier="1:1" id="eeU-0Q-UAz"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yTD-Q6-6Fb">
<rect key="frame" x="283" y="3" width="29" height="14"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="defaultUserIcon.png" translatesAutoresizingMaskIntoConstraints="NO" id="Z8r-gn-9mS">
<rect key="frame" x="8" y="4" width="36" height="36"/>
<constraints>
<constraint firstAttribute="width" constant="36" id="E3f-lp-kaa"/>
<constraint firstAttribute="height" constant="36" id="Slk-iB-nWe"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y1j-uK-OMs">
<rect key="frame" x="52" y="23" width="232" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yk3-Q1-oOg">
<rect key="frame" x="52" y="4" width="36" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="lBL-iI-Mzy" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="-5" id="19x-ku-5u4"/>
<constraint firstItem="Yk3-Q1-oOg" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="-4" id="33e-00-0u3"/>
<constraint firstItem="lBL-iI-Mzy" firstAttribute="leading" secondItem="Y1j-uK-OMs" secondAttribute="trailing" constant="8" id="572-Ms-IwE"/>
<constraint firstAttribute="bottomMargin" secondItem="Y1j-uK-OMs" secondAttribute="bottom" constant="-5" id="A6Y-c5-HKB"/>
<constraint firstItem="yTD-Q6-6Fb" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="-5" id="D5e-cm-IZX"/>
<constraint firstItem="yTD-Q6-6Fb" firstAttribute="trailing" secondItem="H2p-sc-9uM" secondAttribute="trailingMargin" id="J49-BO-iWq"/>
<constraint firstItem="yTD-Q6-6Fb" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Yk3-Q1-oOg" secondAttribute="trailing" constant="8" id="Mcp-hK-gyB"/>
<constraint firstAttribute="centerY" secondItem="lBL-iI-Mzy" secondAttribute="centerY" id="Vos-wa-zgZ"/>
<constraint firstAttribute="bottomMargin" secondItem="yTD-Q6-6Fb" secondAttribute="bottom" constant="-8" id="Wbj-Bj-1dq"/>
<constraint firstItem="Z8r-gn-9mS" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" id="Xa9-Zh-VdL"/>
<constraint firstItem="Yk3-Q1-oOg" firstAttribute="leading" secondItem="Z8r-gn-9mS" secondAttribute="trailing" constant="8" id="Yf0-Ah-wZX"/>
<constraint firstAttribute="centerY" secondItem="Z8r-gn-9mS" secondAttribute="centerY" id="m4h-MK-rQn"/>
<constraint firstAttribute="trailing" secondItem="lBL-iI-Mzy" secondAttribute="trailing" constant="8" id="s2N-1q-hKI"/>
<constraint firstItem="Y1j-uK-OMs" firstAttribute="leading" secondItem="Z8r-gn-9mS" secondAttribute="trailing" constant="8" id="thW-MX-lau"/>
<constraint firstAttribute="bottomMargin" secondItem="lBL-iI-Mzy" secondAttribute="bottom" constant="-5" id="yXM-kO-fHi"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="Wbj-Bj-1dq"/>
<exclude reference="19x-ku-5u4"/>
<exclude reference="Vos-wa-zgZ"/>
</mask>
</variation>
</tableViewCellContentView>
<connections>
<outlet property="avatarImageView" destination="Z8r-gn-9mS" id="rjH-bn-xoe"/>
<outlet property="lastMsgLabel" destination="Y1j-uK-OMs" id="yLn-g4-DQI"/>
<outlet property="nameLabel" destination="Yk3-Q1-oOg" id="J2m-OD-OQM"/>
<outlet property="timeLabel" destination="yTD-Q6-6Fb" id="HgE-fe-5Gn"/>
<outlet property="unReadLabel" destination="lBL-iI-Mzy" id="FpF-Ol-omO"/>
</connections>
</tableViewCell>
</objects>
<resources>
<image name="defaultUserIcon.png" width="50" height="50"/>
</resources>
</document>