فهرست منبع

修改VIP和趣纠课课程详情评价老师流程,增加评分弹窗

Pq 6 ماه پیش
والد
کامیت
de342363af

+ 36 - 0
student/src/main/java/com/cooleshow/student/presenter/course/SparringCourseDetailPresenter.java

@@ -231,4 +231,40 @@ public class SparringCourseDetailPresenter extends BasePresenter<SparringCourseD
             }
         });
     }
+
+    /**
+     * 提交陪练课老师评价
+     *
+     * @param commentContent
+     * @param courseScheduleId
+     * @param courseGroupId
+     */
+    public void submitSparringCourseComment(String commentContent, String courseScheduleId, String courseGroupId,float score) {
+        if (getView() != null) {
+            getView().showLoading();
+        }
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.putOpt("courseScheduleId", courseScheduleId);
+            jsonObject.putOpt("studentReplied", commentContent);
+            jsonObject.putOpt("courseGroupId", courseGroupId);
+            jsonObject.putOpt("score", score);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+        addSubscribe(create(APIService.class).submitSparringCourseComment(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString())), new BaseObserver<Object>(getView()) {
+            @Override
+            protected void onSuccess(Object o) {
+                if (getView() != null) {
+                    getView().submitSparringCourseTeacherCommentSuccess();
+                }
+            }
+
+            @Override
+            public void onError(Throwable e) {
+                super.onError(e);
+            }
+        });
+    }
 }

+ 36 - 8
student/src/main/java/com/cooleshow/student/ui/course/SparringCourseDetailActivity.java

@@ -41,6 +41,7 @@ import com.cooleshow.student.presenter.course.SparringCourseDetailPresenter;
 import com.cooleshow.student.ui.work.HomeWorkDetailActivity;
 import com.cooleshow.student.widgets.CourseSetCommentDialog;
 import com.cooleshow.base.widgets.VideoThumbnailView;
+import com.cooleshow.student.widgets.dialog.AddCourseCommentDialog;
 import com.cooleshow.student.widgets.dialog.UploadHomeworkVideoDialog;
 import com.dayayuemeng.classroom.helper.OpenClassRoomHelper;
 import com.tbruyelle.rxpermissions3.RxPermissions;
@@ -65,6 +66,7 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
     private List<PracticeVideoWorkBean> homeworkVideoData = new ArrayList<>();
     private PracticeVideoWorkAdapter mVideoWorkAdapter;
     private UploadHomeworkVideoDialog mVideoDialog;
+    private AddCourseCommentDialog mCommentDialog;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -320,7 +322,7 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
         if (commentBean != null && !TextUtils.isEmpty(commentBean.studentReplied)) {
             //学生已评价 tv_stu_comment_content
             //评分星级
-            viewBinding.ratingBarForStudent.setVisibility(View.VISIBLE);
+            viewBinding.ratingBarForStudent.setVisibility(View.GONE);
             viewBinding.ratingBarForStudent.setRating(commentBean.score);
             viewBinding.tvEvaluate.setVisibility(View.GONE);
             viewBinding.tvStuCommentEmptyText.setVisibility(View.GONE);
@@ -338,6 +340,9 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
 
     @Override
     public void onClick(View v) {
+        if (UiUtils.isFastClick(500)) {
+            return;
+        }
         if (v.getId() == R.id.tv_set_homework) {
             //布置作业
 //            showSetCommentDialog(CourseSetCommentDialog.TYPE_SET_HOMEWORK);
@@ -391,12 +396,32 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
                 ToastUtil.getInstance().show(this, "课程结束之后才可以评价哦~");
                 return;
             }
-            //评价老师
-            ARouter.getInstance()
-                    .build(RouterPath.CourseCenter.SPARRING_EVALUATE_TEACHER)
-                    .withString("course_id", mCourseId)
-                    .withString("course_group_id", mCourseGroupId)
-                    .navigation();
+            showEvaluateTeacherDialog();
+//            //评价老师
+//            ARouter.getInstance()
+//                    .build(RouterPath.CourseCenter.SPARRING_EVALUATE_TEACHER)
+//                    .withString("course_id", mCourseId)
+//                    .withString("course_group_id", mCourseGroupId)
+//                    .navigation();
+        }
+    }
+
+    private void showEvaluateTeacherDialog() {
+        if(mCommentDialog == null){
+            mCommentDialog = new AddCourseCommentDialog(this);
+            mCommentDialog.setOnEventListener(new AddCourseCommentDialog.OnEventListener() {
+                @Override
+                public void onResult(String content, float ratingCount) {
+                    //提交评分
+                    mCommentDialog.dismiss();
+                    if (presenter != null) {
+                        presenter.submitSparringCourseComment(content, mCourseId, mCourseGroupId, ratingCount);
+                    }
+                }
+            });
+        }
+        if(!mCommentDialog.isShowing()){
+            mCommentDialog.show();
         }
     }
 
@@ -573,7 +598,7 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
 
     }
 
-    private void submit(){
+    private void submit() {
         if (UiUtils.isFastClick()) {
             return;
         }
@@ -603,6 +628,9 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
     @Override
     public void onDestroy() {
         super.onDestroy();
+        if (mCommentDialog != null) {
+            mCommentDialog.onDestroy();
+        }
         if (mSetCommentDialog != null) {
             mSetCommentDialog.unbind();
         }

+ 167 - 0
student/src/main/java/com/cooleshow/student/widgets/dialog/AddCourseCommentDialog.java

@@ -0,0 +1,167 @@
+package com.cooleshow.student.widgets.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.Gravity;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.cooleshow.base.utils.StringUtils;
+import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.base.widgets.RatingBar;
+import com.cooleshow.student.R;
+
+import java.util.Locale;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Author by pq, Date on 2023/10/17.
+ * 评价老师
+ */
+public class AddCourseCommentDialog extends Dialog implements View.OnClickListener {
+
+
+    private OnEventListener mEventListener;
+    private TextWatcher mTextWatcher = new TextWatcher() {
+        @Override
+        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+        }
+
+        @Override
+        public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+        }
+
+        @Override
+        public void afterTextChanged(Editable s) {
+            updateTextNum();
+        }
+    };
+    private EditText mEtContent;
+    private TextView mTvTextNum;
+    private TextView mTvConfirm;
+    private ImageView mIvClose;
+    private RatingBar mRatingBar;
+
+    public AddCourseCommentDialog(@NonNull Context context) {
+        super(context, R.style.MyBottomDialogStyle);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.dialog_add_course_comment_layout);
+        initParams();
+        initViews();
+        initData();
+        initListener();
+    }
+
+
+    private void initViews() {
+        mEtContent = findViewById(R.id.et_content);
+        mTvTextNum = findViewById(R.id.tv_text_num);
+        mTvConfirm = findViewById(R.id.tv_confirm);
+        mIvClose = findViewById(R.id.iv_close);
+        mRatingBar = findViewById(R.id.rating_bar);
+    }
+
+    private void initData() {
+
+    }
+
+    private void initListener() {
+        mEtContent.addTextChangedListener(mTextWatcher);
+        mIvClose.setOnClickListener(this);
+        mTvConfirm.setOnClickListener(this);
+    }
+
+    private void updateTextNum() {
+        String text = mEtContent.getText().toString().trim();
+        int cLength = text.length();
+        mTvTextNum.setText(String.format(Locale.getDefault(), "%d/200", cLength));
+    }
+
+    private void initParams() {
+        Window window = getWindow();
+        //设置dialog在屏幕底部
+        window.setGravity(Gravity.BOTTOM);
+        //设置dialog弹出时的动画效果,从屏幕底部向上弹出
+        window.setWindowAnimations(com.cooleshow.base.R.style.BottomAnimation);
+        window.getDecorView().setPadding(0, 0, 0, 0);
+        //获得window窗口的属性
+        WindowManager.LayoutParams lp = window.getAttributes();
+        //设置窗口宽度为充满全屏
+        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
+        //设置窗口高度为包裹内容
+        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
+        lp.horizontalMargin = 0;
+        lp.verticalMargin = 0;
+        //将设置好的属性set回去
+        window.setAttributes(lp);
+    }
+
+    @Override
+    public void onClick(View v) {
+        int id = v.getId();
+        if (id == R.id.iv_close) {
+            dismiss();
+            return;
+        }
+        if (id == R.id.tv_confirm) {
+            if (mEventListener != null) {
+                Editable text = mEtContent.getText();
+                if (text != null) {
+                    String inputContent = text.toString().trim();
+
+                    if (TextUtils.isEmpty(inputContent)) {
+                        ToastUtil.getInstance().showShort("请输入您对本次课程老师的评价");
+                        return;
+                    }
+                    String result = StringUtils.replaceSpace(inputContent);
+                    float ratingCount = mRatingBar.getStarStep();
+                    mEventListener.onResult(result,ratingCount);
+                }
+            }
+            return;
+        }
+
+    }
+
+
+    public void setOnEventListener(OnEventListener listener) {
+        this.mEventListener = listener;
+    }
+
+    public void setContentText(String content) {
+        if (mEtContent != null) {
+            mEtContent.setText(content);
+            updateTextNum();
+        }
+    }
+
+    public interface OnEventListener {
+        void onResult(String content, float ratingCount);
+    }
+
+    @Override
+    public void onDetachedFromWindow() {
+        super.onDetachedFromWindow();
+    }
+
+    public void onDestroy(){
+        if (mEtContent != null && mTextWatcher != null) {
+            mEtContent.removeTextChangedListener(mTextWatcher);
+        }
+    }
+}

+ 136 - 0
student/src/main/res/layout/dialog_add_course_comment_layout.xml

@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@drawable/shape_f8f9fc_top_12dp"
+    android:paddingBottom="30dp">
+
+    <TextView
+        android:id="@+id/tv_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="18dp"
+        android:includeFontPadding="false"
+        android:text="评价老师"
+        android:textColor="@color/color_333333"
+        android:textSize="@dimen/sp_18"
+        android:textStyle="bold"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <ImageView
+        android:id="@+id/iv_close"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:padding="12dp"
+        android:src="@drawable/icon_close_dialog_32_32"
+        app:layout_constraintBottom_toBottomOf="@+id/tv_title"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="@+id/tv_title" />
+
+
+    <LinearLayout
+        android:gravity="center"
+        android:layout_marginEnd="14dp"
+        android:layout_marginStart="14dp"
+        android:layout_marginTop="18dp"
+        android:paddingTop="12dp"
+        android:paddingBottom="12dp"
+        android:background="@drawable/shape_white_10dp"
+        android:id="@+id/ll_mark"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/tv_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <com.cooleshow.base.widgets.RatingBar
+            android:id="@+id/rating_bar"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/dp_28"
+            android:gravity="center"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            app:starCount="5"
+            app:starEmpty="@drawable/icon_star_default"
+            app:starFill="@drawable/icon_star_select"
+            app:starImageSize="@dimen/dp_28"
+            app:starPadding="@dimen/dp_7"
+            app:starStep="5"
+            app:stepSize="Full" />
+
+        <TextView
+            android:id="@+id/tv_title_hint"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/dp_17"
+            android:text="如果满意请给五星好评喔~"
+            android:textColor="@color/color_999999"
+            android:textSize="@dimen/sp_12"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/rating_bar" />
+    </LinearLayout>
+
+    <FrameLayout
+        android:id="@+id/fl_input"
+        android:layout_width="match_parent"
+        android:layout_height="164dp"
+        android:layout_marginStart="14dp"
+        android:layout_marginTop="12dp"
+        android:layout_marginEnd="14dp"
+        android:background="@drawable/shape_white_8dp"
+        android:minHeight="164dp"
+        android:paddingStart="10dp"
+        android:paddingTop="12dp"
+        android:paddingEnd="10dp"
+        android:paddingBottom="18dp"
+        app:layout_constraintTop_toBottomOf="@+id/ll_mark">
+
+        <EditText
+            android:id="@+id/et_content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginBottom="20dp"
+            android:background="@color/transparent"
+            android:gravity="left"
+            android:hint="请输入您对本次课程老师教学的评价"
+            android:maxLength="200"
+            android:textColor="@color/black_333"
+            android:textColorHint="@color/color_aaaaaa"
+            android:textCursorDrawable="@drawable/shape_2dc7aa_1dp"
+            android:textSize="@dimen/sp_15"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <TextView
+            android:id="@+id/tv_text_num"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="bottom|right"
+            android:includeFontPadding="false"
+            android:text="0/200"
+            android:textColor="@color/color_aaaaaa"
+            android:textSize="@dimen/sp_14" />
+    </FrameLayout>
+
+
+    <TextView
+        android:id="@+id/tv_confirm"
+        android:layout_width="0dp"
+        android:layout_height="44dp"
+        android:layout_marginStart="28dp"
+        android:layout_marginTop="30dp"
+        android:layout_marginEnd="28dp"
+        android:background="@drawable/shape_2dc7aa_39dp"
+        android:gravity="center"
+        android:text="提交"
+        android:textColor="@color/white"
+        android:textSize="@dimen/sp_18"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/fl_input" />
+</androidx.constraintlayout.widget.ConstraintLayout>