|
@@ -459,6 +459,9 @@
|
|
|
[self submitHomeworkAction];
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ [self tryJoinRoom];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)submitHomeworkAction {
|
|
@@ -555,6 +558,75 @@
|
|
|
[_HUD hideAnimated:YES];
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+- (void)tryJoinRoom {
|
|
|
+
|
|
|
+ NSDateFormatter *dateFormatter = [NSObject getDateformatter];
|
|
|
+ [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
|
|
+ NSDate *beginDate = [dateFormatter dateFromString:self.homeworkModel.startTime];
|
|
|
+ NSDate *endDate = [dateFormatter dateFromString:self.homeworkModel.endTime];
|
|
|
+ NSDate *currentDate = [NSDate date];
|
|
|
+ NSTimeInterval beginTimeInterval = [beginDate timeIntervalSinceDate:currentDate];
|
|
|
+ NSTimeInterval endTimeInterval = [currentDate timeIntervalSinceDate:endDate];
|
|
|
+ if (beginTimeInterval <= self.joinRoomBeforeTime * 60 && endTimeInterval < 0) {
|
|
|
+ [self joinClassRoom];
|
|
|
+ }
|
|
|
+ else if (endTimeInterval > 0) {
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:@"该课程已结束"];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ NSString *tipsString = [NSString stringWithFormat:@"课程还未开始,请在上课前%zd分钟进入", self.joinRoomBeforeTime];
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:tipsString];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 加入房间
|
|
|
+- (void)joinClassRoom {
|
|
|
+
|
|
|
+ // 加入房间前判断摄像头和麦克风逻辑
|
|
|
+ [RecordCheckManager checkCameraPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
|
|
|
+ [self afterCheckCameraCheckMic:type];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)afterCheckCameraCheckMic:(PREMISSIONTYPE)cameraType {
|
|
|
+ [RecordCheckManager checkMicPermissionAvaiableCallback:^(PREMISSIONTYPE type) {
|
|
|
+ if (type == PREMISSIONTYPE_YES && cameraType == PREMISSIONTYPE_YES) {
|
|
|
+ // 判断是否进行课前检测
|
|
|
+ [self.classManager joinRoomWithId:self.courseId subjectName:self.homeworkModel.subjectName classEndTime:self.homeworkModel.endTime inViewController:self];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ NSString *content = @"";
|
|
|
+ CHECKDEVICETYPE checkType = CHECKDEVICETYPE_BOTH;
|
|
|
+ if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_NO) {
|
|
|
+ content = @"请开启相机和麦克风访问权限";
|
|
|
+ checkType = CHECKDEVICETYPE_BOTH;
|
|
|
+ }
|
|
|
+ else if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_YES) {
|
|
|
+ content = @"请开启相机访问权限";
|
|
|
+ checkType = CHECKDEVICETYPE_CAMREA;
|
|
|
+ }
|
|
|
+ else if (cameraType == PREMISSIONTYPE_YES && type == PREMISSIONTYPE_NO) {
|
|
|
+ content = @"请开启麦克风访问权限";
|
|
|
+ checkType = CHECKDEVICETYPE_MIC;
|
|
|
+ }
|
|
|
+ [self showAlertWithMessage:content type:checkType];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
|
|
|
+ [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
|
|
|
+
|
|
|
+ } confirm:^{
|
|
|
+ [self openSettingView];
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)openSettingView {
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|