@@ -66,6 +66,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
66
66
_contentLabel = [[UITTTAttributedLabel alloc ] initWithFrame: CGRectMake (kMessageCell_PadingWidth , kMessageCell_PadingHeight , 0 , 0 )];
67
67
_contentLabel.numberOfLines = 0 ;
68
68
_contentLabel.font =kMessageCell_FontContent ;
69
+ _contentLabel.textColor = [UIColor blackColor ];
69
70
_contentLabel.backgroundColor = [UIColor clearColor ];
70
71
_contentLabel.linkAttributes = kLinkAttributes ;
71
72
_contentLabel.activeLinkAttributes = kLinkAttributesActive ;
@@ -100,6 +101,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
100
101
101
102
- (void )setCurPriMsg : (PrivateMessage *)curPriMsg andPrePriMsg : (PrivateMessage *)prePriMsg {
102
103
CGFloat mediaViewHeight = [MessageCell mediaViewHeightWithObj: curPriMsg];
104
+ BOOL isMyMsg = [curPriMsg.sender.global_key isEqualToString: [Login curLoginUser ].global_key];
103
105
104
106
if (_curPriMsg == curPriMsg && _prePriMsg == prePriMsg && _preMediaViewHeight == mediaViewHeight) {
105
107
[self configSendStatus ];
@@ -111,13 +113,7 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
111
113
else {
112
114
[_voiceView setUrl: [NSURL fileURLWithPath: curPriMsg.voiceMedia.file]];
113
115
}
114
-
115
- if ([_curPriMsg.sender.global_key isEqualToString: [Login curLoginUser ].global_key]) {
116
- _voiceView.isUnread = NO ;
117
- }
118
- else {
119
- _voiceView.isUnread = curPriMsg.played .intValue == 0 ;
120
- }
116
+ _voiceView.isUnread = !isMyMsg && (curPriMsg.played .intValue == 0 );
121
117
}
122
118
return ;
123
119
}else {
@@ -194,13 +190,7 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
194
190
[_voiceView setUrl: [NSURL fileURLWithPath: curPriMsg.voiceMedia.file]];
195
191
_voiceView.duration = curPriMsg.voiceMedia .duration ;
196
192
}
197
-
198
- if ([_curPriMsg.sender.global_key isEqualToString: [Login curLoginUser ].global_key]) {
199
- _voiceView.isUnread = NO ;
200
- }
201
- else {
202
- _voiceView.isUnread = curPriMsg.played .intValue == 0 ;
203
- }
193
+ _voiceView.isUnread = !isMyMsg && (curPriMsg.played .intValue == 0 );
204
194
205
195
_voiceView.playStartedBlock = ^(AudioPlayView *view) {
206
196
BubblePlayView *bubbleView = (BubblePlayView *)view;
@@ -211,32 +201,26 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
211
201
}
212
202
};
213
203
bgImgViewSize = CGSizeMake (_voiceView.frame .size .width , 40 );
204
+ _voiceView.type = isMyMsg? BubbleTypeRight: BubbleTypeLeft;
214
205
}
215
206
216
207
CGRect bgImgViewFrame;
217
- if (![_curPriMsg.sender.global_key isEqualToString: [Login curLoginUser ].global_key] ) {
208
+ if (!isMyMsg ) {
218
209
// 这是好友发的
219
210
bgImgViewFrame = CGRectMake (kPaddingLeftWidth +kMessageCell_UserIconWith , curBottomY +kMessageCell_PadingHeight , bgImgViewSize.width , bgImgViewSize.height );
220
211
[_userIconView setCenter: CGPointMake (kPaddingLeftWidth +kMessageCell_UserIconWith /2 , CGRectGetMaxY (bgImgViewFrame)- kMessageCell_UserIconWith /2 )];
221
- bgImg = [UIImage imageNamed: @" messageLeft_bg_img" ];
222
-
223
- bgImg = [bgImg resizableImageWithCapInsets: UIEdgeInsetsMake (18 , 30 , bgImg.size.height - 19 , bgImg.size.width - 31 )];
224
- _contentLabel.textColor = [UIColor blackColor ];
225
212
_bgImgView.frame = bgImgViewFrame;
226
213
}else {
227
214
// 这是自己发的
228
215
bgImgViewFrame = CGRectMake ((kScreen_Width - kPaddingLeftWidth - kMessageCell_UserIconWith ) -bgImgViewSize.width , curBottomY +kMessageCell_PadingHeight , bgImgViewSize.width , bgImgViewSize.height );
229
216
[_userIconView setCenter: CGPointMake (kScreen_Width - kPaddingLeftWidth -kMessageCell_UserIconWith /2 , CGRectGetMaxY (bgImgViewFrame)- kMessageCell_UserIconWith /2 )];
230
- bgImg = [UIImage imageNamed: @" messageRight_bg_img" ];
231
- bgImg = [bgImg resizableImageWithCapInsets: UIEdgeInsetsMake (18 , 30 , bgImg.size.height - 19 , bgImg.size.width - 31 )];
232
- _contentLabel.textColor = [UIColor blackColor ];
233
217
_bgImgView.frame = bgImgViewFrame;
234
218
}
235
- if (_voiceView
236
- || [_curPriMsg isSingleBigMonkey ]
237
- ) {
238
- bgImg = nil ; // 使用bubbleView的背景
239
- _voiceView. type = BubbleTypeRight ;
219
+ if (_voiceView || [_curPriMsg isSingleBigMonkey ] ) {
220
+ bgImg = nil ;
221
+ } else {
222
+ bgImg = [UIImage imageNamed: isMyMsg? @" messageRight_bg_img " : @" messageLeft_bg_img " ];
223
+ bgImg = [bgImg resizableImageWithCapInsets: UIEdgeInsetsMake ( 18 , 30 , bgImg.size.height - 19 , bgImg.size.width - 31 )] ;
240
224
}
241
225
242
226
__weak typeof (self) weakSelf = self;
0 commit comments