|  | @@ -4,16 +4,26 @@ import android.graphics.Color;
 | 
	
		
			
				|  |  |  import android.os.Bundle;
 | 
	
		
			
				|  |  |  import android.text.TextUtils;
 | 
	
		
			
				|  |  |  import android.view.View;
 | 
	
		
			
				|  |  | +import android.widget.LinearLayout;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.android.arouter.facade.annotation.Route;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.router.RouterPath;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.ui.activity.BaseMVPActivity;
 | 
	
		
			
				|  |  | +import com.cooleshow.base.utils.GlideUtils;
 | 
	
		
			
				|  |  | +import com.cooleshow.base.utils.SizeUtils;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.R;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.bean.PianoRoomCourseHomeworkBean;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.bean.PianoRoomCourseInfoBean;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.bean.SparringCourseHomeworkBean;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.constants.CourseConstants;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.contract.PianoRoomCourseDetailContract;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.contract.PianoRoomCourseHomeworkContract;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.databinding.ActivityPianoCourseHomeworkLayoutBinding;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.presenter.homework.PianoRoomCourseHomeWorkPresenter;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.widgets.CourseSetCommentDialog;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.widgets.HomeworkVideoThumbnailView;
 | 
	
		
			
				|  |  | +import com.cooleshow.usercenter.helper.UserHelper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import androidx.annotation.Nullable;
 | 
	
		
			
				|  |  |  import androidx.recyclerview.widget.LinearLayoutManager;
 | 
	
	
		
			
				|  | @@ -22,13 +32,14 @@ import androidx.recyclerview.widget.LinearLayoutManager;
 | 
	
		
			
				|  |  |   * Author by pq, Date on 2022/6/24.
 | 
	
		
			
				|  |  |   * 琴房课作业详情页面
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | -@Route(path = RouterPath.CourseCenter.PIANO_ROOM_COURSE_DETAIL)
 | 
	
		
			
				|  |  | -public class PianoRoomCourseHomeWorkActivity extends BaseMVPActivity<ActivityPianoCourseHomeworkLayoutBinding, PianoRoomCourseHomeWorkPresenter> implements PianoRoomCourseDetailContract.PianoRoomCourseDetailView, View.OnClickListener {
 | 
	
		
			
				|  |  | +@Route(path = RouterPath.CourseCenter.PIANO_ROOM_COURSE_HOMEWORK)
 | 
	
		
			
				|  |  | +public class PianoRoomCourseHomeWorkActivity extends BaseMVPActivity<ActivityPianoCourseHomeworkLayoutBinding, PianoRoomCourseHomeWorkPresenter> implements PianoRoomCourseHomeworkContract.PianoRoomCourseHomeworkView, View.OnClickListener {
 | 
	
		
			
				|  |  |      public static final String COURSE_ID = "course_id";
 | 
	
		
			
				|  |  |      public static final String STUDENT_ID = "studentId";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private String mCourseId;
 | 
	
		
			
				|  |  |      private String studentId;
 | 
	
		
			
				|  |  | +    private CourseSetCommentDialog mSetCommentDialog;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      protected void onCreate(@Nullable Bundle savedInstanceState) {
 | 
	
	
		
			
				|  | @@ -83,15 +94,128 @@ public class PianoRoomCourseHomeWorkActivity extends BaseMVPActivity<ActivityPia
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public void getCourseHomeworkInfoSuccess(PianoRoomCourseInfoBean bean) {
 | 
	
		
			
				|  |  | +    public void getCourseHomeworkInfoSuccess(PianoRoomCourseHomeworkBean infoBean) {
 | 
	
		
			
				|  |  | +        if (!checkActivityExist()) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (infoBean == null) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //学生头像
 | 
	
		
			
				|  |  | +        GlideUtils.INSTANCE.loadImage(this, infoBean.studentAvatar, viewBinding.ivAvatar, R.drawable.icon_teacher_default_head);
 | 
	
		
			
				|  |  | +        //title
 | 
	
		
			
				|  |  | +        viewBinding.tvTitle.setText(UserHelper.getStudentName(infoBean.studentName, studentId));
 | 
	
		
			
				|  |  | +        //subjectName
 | 
	
		
			
				|  |  | +        viewBinding.tvCourseName.setText(infoBean.subjectName);
 | 
	
		
			
				|  |  | +        //课后作业
 | 
	
		
			
				|  |  | +        handleHomeworkData(infoBean);
 | 
	
		
			
				|  |  | +        //作业视频
 | 
	
		
			
				|  |  | +        handleHomeworkStudentSubmit(infoBean);
 | 
	
		
			
				|  |  | +        //作业点评
 | 
	
		
			
				|  |  | +        handleHomeworkComment(infoBean);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 课后作业
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void handleHomeworkData(PianoRoomCourseHomeworkBean bean) {
 | 
	
		
			
				|  |  | +        if (bean == null) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (bean.decorateHomework == CourseConstants.COURSE_HOMEWORK_SET) {
 | 
	
		
			
				|  |  | +            //已布置课后作业
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkEmptyText.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkContent.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkContent.setText(bean.content);
 | 
	
		
			
				|  |  | +            viewBinding.tvSetHomework.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            //未布置课后作业
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkEmptyText.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkContent.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +            viewBinding.tvSetHomework.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 学生提交的作业
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param bean
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void handleHomeworkStudentSubmit(PianoRoomCourseHomeworkBean bean) {
 | 
	
		
			
				|  |  | +        if (bean == null) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //tv_homework_video_empty_text
 | 
	
		
			
				|  |  | +        if (bean.submitHomework == CourseConstants.COURSE_HOMEWORK_STU_SUBMIT) {
 | 
	
		
			
				|  |  | +            //学员已提交课后作业
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkVideoEmptyText.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +            viewBinding.llHomeworkVideoContent.removeAllViews();
 | 
	
		
			
				|  |  | +            addVideoThumbnailView(bean.studentAttachments);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            //学员未提交课后作业
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkVideoEmptyText.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 添加视频缩略图
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param videoUrls
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void addVideoThumbnailView(String videoUrls) {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            if (!TextUtils.isEmpty(videoUrls)) {
 | 
	
		
			
				|  |  | +                String[] results = TextUtils.split(videoUrls, ",");
 | 
	
		
			
				|  |  | +                for (int i = 0; i < results.length; i++) {
 | 
	
		
			
				|  |  | +                    HomeworkVideoThumbnailView videoThumbnailView = new HomeworkVideoThumbnailView(PianoRoomCourseHomeWorkActivity.this);
 | 
	
		
			
				|  |  | +                    videoThumbnailView.setData(results[i]);
 | 
	
		
			
				|  |  | +                    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
 | 
	
		
			
				|  |  | +                    int left = i == 0 ? 0 : SizeUtils.dp2px(6);
 | 
	
		
			
				|  |  | +                    layoutParams.setMargins(left, 0, 0, 0);
 | 
	
		
			
				|  |  | +                    layoutParams.weight = 1;
 | 
	
		
			
				|  |  | +                    viewBinding.llHomeworkVideoContent.addView(videoThumbnailView, layoutParams);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +            viewBinding.llHomeworkVideoContent.removeAllViews();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 作业点评
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void handleHomeworkComment(PianoRoomCourseHomeworkBean bean) {
 | 
	
		
			
				|  |  | +        //tv_homework_comment_content
 | 
	
		
			
				|  |  | +        if (bean == null) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (!TextUtils.isEmpty(bean.teacherReplied)) {
 | 
	
		
			
				|  |  | +            //老师已点评作业
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkCommentEmptyText.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkSetComment.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkCommentContent.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkCommentContent.setText(bean.teacherReplied);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkCommentEmptyText.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkSetComment.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | +            viewBinding.tvHomeworkCommentContent.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 提交布置作业成功
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public void submitSparringCourseHomeworkSuccess() {
 | 
	
		
			
				|  |  | +    public void submitCourseHomeworkSuccess() {
 | 
	
		
			
				|  |  | +        if (!checkActivityExist()) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        refresh();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void submitCourseHomeworkCommentSuccess() {
 | 
	
		
			
				|  |  |          if (!checkActivityExist()) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -101,11 +225,39 @@ public class PianoRoomCourseHomeWorkActivity extends BaseMVPActivity<ActivityPia
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void onClick(View v) {
 | 
	
		
			
				|  |  | -        int id = v.getId();
 | 
	
		
			
				|  |  | -        if (id == R.id.tv_set_homework) {
 | 
	
		
			
				|  |  | +        if (v.getId() == R.id.tv_set_homework) {
 | 
	
		
			
				|  |  |              //布置作业
 | 
	
		
			
				|  |  | -//            showSetCommentDialog();
 | 
	
		
			
				|  |  | +            showSetCommentDialog(CourseSetCommentDialog.TYPE_SET_HOMEWORK);
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (v.getId() == R.id.tv_homework_set_comment) {
 | 
	
		
			
				|  |  | +            //点评作业
 | 
	
		
			
				|  |  | +            showSetCommentDialog(CourseSetCommentDialog.TYPE_SET_HOMEWORK_COMMENT);
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void showSetCommentDialog(int typeSetTeacherComment) {
 | 
	
		
			
				|  |  | +        if (mSetCommentDialog == null) {
 | 
	
		
			
				|  |  | +            mSetCommentDialog = new CourseSetCommentDialog(this);
 | 
	
		
			
				|  |  | +            mSetCommentDialog.setOnSubmitClickListener(new CourseSetCommentDialog.OnSubmitClickListener() {
 | 
	
		
			
				|  |  | +                @Override
 | 
	
		
			
				|  |  | +                public void onSubmit(String content, int type) {
 | 
	
		
			
				|  |  | +                    //提交
 | 
	
		
			
				|  |  | +                    if (type == CourseSetCommentDialog.TYPE_SET_HOMEWORK) {
 | 
	
		
			
				|  |  | +                        //提交布置作业
 | 
	
		
			
				|  |  | +                        presenter.submitCourseHomework(content, mCourseId);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (type == CourseSetCommentDialog.TYPE_SET_HOMEWORK_COMMENT) {
 | 
	
		
			
				|  |  | +                        //提交作业点评
 | 
	
		
			
				|  |  | +                        presenter.submitCourseHomeworkComment(content, mCourseId, studentId);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (!mSetCommentDialog.isShowing()) {
 | 
	
		
			
				|  |  | +            mSetCommentDialog.show();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        mSetCommentDialog.showMethod(typeSetTeacherComment);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |