|
@@ -17,6 +17,8 @@
|
|
|
@property (nonatomic, readwrite, strong) YYLabel *yyLabel;
|
|
|
@property (nonatomic, readwrite, strong) NSMutableAttributedString *skillString;
|
|
|
|
|
|
+@property (nonatomic, readwrite, strong) QMUIButton *readBtn;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation RQExerciseAnswerItemViewModel
|
|
@@ -46,7 +48,29 @@
|
|
|
space = 0.f;
|
|
|
} else {
|
|
|
NSArray *knameList = [self getKeyRangeList:self.ydtJSModel.qb_analyse readText:self.ydtJSModel.qb_read_analyse];//获取关键字
|
|
|
- NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",self.ydtJSModel.qb_read_analyse]];
|
|
|
+ NSMutableAttributedString *text = [[NSMutableAttributedString alloc] init];
|
|
|
+ //播放-答案
|
|
|
+ if (RQ_COMMON_MANAGER.JSJP_APP_VOICE) {//读题-是否开启
|
|
|
+ CGSize btnSize = CGSizeMake(30, 30);
|
|
|
+ //读题
|
|
|
+ QMUIButton *readBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ CGFloat ebtnH = 30.f;
|
|
|
+ CGFloat ebtnW = 30.f;
|
|
|
+ CGSize ebtnSize = CGSizeMake(ebtnW, ebtnH);
|
|
|
+ readBtn.size = btnSize;
|
|
|
+ [readBtn setImage:RQImageNamed(@"播放_pay") forState:UIControlStateNormal];
|
|
|
+ [readBtn setImage:RQImageNamed(@"播放_suspend") forState:UIControlStateSelected];
|
|
|
+ [readBtn addTarget:self action:@selector(buttonActionPayVoicedo:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ NSMutableAttributedString *readAttachment = [NSMutableAttributedString yy_attachmentStringWithContent:readBtn
|
|
|
+ contentMode:UIViewContentModeCenter
|
|
|
+ attachmentSize:ebtnSize
|
|
|
+ alignToFont:[UIFont systemFontOfSize:RQ_Exercise_Module.exerciseFontSize]
|
|
|
+ alignment:YYTextVerticalAlignmentCenter];
|
|
|
+ self.readBtn = readBtn;
|
|
|
+ [text appendAttributedString:readAttachment];
|
|
|
+ }
|
|
|
+ NSMutableAttributedString *analyseString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",self.ydtJSModel.qb_read_analyse]];
|
|
|
+ [text appendAttributedString:analyseString];
|
|
|
text.yy_font = [UIFont systemFontOfSize:RQ_Exercise_Module.exerciseFontSize];
|
|
|
text.yy_lineSpacing = 8;
|
|
|
text.yy_color = RQ_MAIN_TEXT_COLOR_1;
|
|
@@ -73,19 +97,30 @@
|
|
|
self.skillHeight = height;
|
|
|
space = 6.f;
|
|
|
}
|
|
|
- _exRowHeight = [_answerString heightForFont:[UIFont systemFontOfSize:19] width:RQ_SCREEN_WIDTH - (16 * 2) - (8 * 2)] + (8 * 2) + (16 * 2) + space + self.skillHeight;
|
|
|
+ _exRowHeight = [_answerString heightForFont:[UIFont systemFontOfSize:19] width:RQ_SCREEN_WIDTH - (16 * 2) - (8 * 2)] + (8 * 2) + (16 * 2) + space;
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
return self;
|
|
|
}
|
|
|
+//重写 skillHeight get 方法
|
|
|
+- (CGFloat)skillHeight{
|
|
|
+ CGFloat skillH = _skillHeight;
|
|
|
+ NSInteger line = RQ_COMMON_MANAGER.APP_SWITCH? 0 : ((RQ_VIP_Module.isSubject1Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne)? 0 : ((RQ_VIP_Module.isSubject4Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour)? 0 : 1));
|
|
|
+ if (RQ_USER_MANAGER.tryLookCount>0 && line==1){//试看
|
|
|
+ line = 0;
|
|
|
+ }
|
|
|
+ if(line==1) skillH = RQ_FIT_HORIZONTAL(34.f);
|
|
|
+ return skillH;
|
|
|
+}
|
|
|
+
|
|
|
//重写 rowHeight get 方法
|
|
|
- (CGFloat)rowHeight{
|
|
|
- CGFloat rowH = _exRowHeight;
|
|
|
+ CGFloat rowH = _exRowHeight + self.skillHeight;
|
|
|
NSInteger line = RQ_COMMON_MANAGER.APP_SWITCH? 0 : ((RQ_VIP_Module.isSubject1Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne)? 0 : ((RQ_VIP_Module.isSubject4Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour)? 0 : 1));
|
|
|
if (RQ_USER_MANAGER.tryLookCount>0 && line==1){//试看
|
|
|
- rowH = _exRowHeight + 40.f;
|
|
|
+ rowH = rowH + 40.f;
|
|
|
}
|
|
|
return rowH;
|
|
|
}
|
|
@@ -103,7 +138,7 @@
|
|
|
NSRange matchedRange = [match rangeAtIndex:1];
|
|
|
NSString *extractedText = [originalText substringWithRange:matchedRange];
|
|
|
NSRange range = [readText rangeOfString:extractedText];
|
|
|
- dict[extractedText] = @[@(range.location),@(range.length)];
|
|
|
+ dict[extractedText] = @[@(range.location+1),@(range.length)];
|
|
|
[array addObject:dict];
|
|
|
NSLog(@"Extracted Text: %@", extractedText);
|
|
|
NSLog(@"Matched Range: %@", NSStringFromRange(matchedRange));
|
|
@@ -126,6 +161,7 @@
|
|
|
- (YYLabel *)yyLabel {
|
|
|
if (!_yyLabel) {
|
|
|
_yyLabel = [[YYLabel alloc] init];
|
|
|
+ _yyLabel.userInteractionEnabled = YES;
|
|
|
}
|
|
|
return _yyLabel;
|
|
|
}
|
|
@@ -134,4 +170,59 @@
|
|
|
return @"RQExerciseAnswerCell";
|
|
|
}
|
|
|
|
|
|
+#pragma mark -事件
|
|
|
+- (void)buttonActionPayVoicedo:(UIButton *)btn
|
|
|
+{
|
|
|
+ if (RQ_COMMON_MANAGER.JSJP_APP_VOICE) {//读题-是否开启
|
|
|
+ //是vip
|
|
|
+ NSInteger line = RQ_COMMON_MANAGER.APP_SWITCH? 0 : ((RQ_VIP_Module.isSubject1Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne)? 0 : ((RQ_VIP_Module.isSubject4Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour)? 0 : 1));
|
|
|
+ if (RQ_USER_MANAGER.tryLookCount>0 && line==1){//试看
|
|
|
+ line = 0;
|
|
|
+ }
|
|
|
+ if (line==1) {
|
|
|
+ ShowMsg(@"请购买会员,才能读解题技巧。");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ btn.userInteractionEnabled = NO;
|
|
|
+ btn.selected = !btn.isSelected;
|
|
|
+ if(btn.selected){//播放
|
|
|
+ if (NY_VOICE_MANAGER.state == NYVoiceType_Pause){
|
|
|
+ [NY_VOICE_MANAGER resumePayVoiceActionUrl];//恢复
|
|
|
+ }else {
|
|
|
+ [NY_VOICE_MANAGER stopPayVoiceActionUrl];
|
|
|
+ NSString *url = self.ydtJSModel.qb_skill_audio_link;
|
|
|
+ WeakSelf(weakSelf)
|
|
|
+ [NY_VOICE_MANAGER startPayVoiceActionUrl:url completedBlock:^(NYVoiceType voiceType) {
|
|
|
+ switch (voiceType) {
|
|
|
+ case NYVoiceType_Start:{
|
|
|
+ weakSelf.readBtn.selected = YES;
|
|
|
+ }break;
|
|
|
+ case NYVoiceType_Wait:{//完成-等待
|
|
|
+ weakSelf.readBtn.selected = NO;
|
|
|
+ }break;
|
|
|
+ case NYVoiceType_Resume:{//恢复
|
|
|
+ weakSelf.readBtn.selected = YES;
|
|
|
+ }break;
|
|
|
+ case NYVoiceType_Pause:{//暂停
|
|
|
+ weakSelf.readBtn.selected = NO;
|
|
|
+ }break;
|
|
|
+ case NYVoiceType_Stop:{//停止
|
|
|
+ weakSelf.readBtn.selected = NO;
|
|
|
+ }break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ }else {//暂停
|
|
|
+ [NY_VOICE_MANAGER pausePayVoiceActionUrl];
|
|
|
+ }
|
|
|
+ //防止频繁点击 1 秒点一次
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ self.readBtn.userInteractionEnabled = YES;
|
|
|
+ });
|
|
|
+
|
|
|
+}
|
|
|
@end
|
|
|
+
|