فهرست منبع

修改老师端个人风采页面,顶部个人信息修改以及显示

Pq 3 سال پیش
والد
کامیت
88c3e8dcd5

+ 10 - 0
teacher/src/main/java/com/cooleshow/teacher/contract/MineStylePageContract.java

@@ -2,6 +2,8 @@ package com.cooleshow.teacher.contract;
 
 import com.cooleshow.base.presenter.view.BaseView;
 import com.cooleshow.teacher.bean.TeacherSelfStyleInfoBean;
+import com.cooleshow.teacher.bean.TeacherUserInfo;
+import com.cooleshow.usercenter.bean.SetDetailBean;
 
 /**
  * 创建日期:2022/5/13 14:15
@@ -18,6 +20,14 @@ public interface MineStylePageContract {
 
         void upLoadVideoCoverSuccess(String coverUrl);
         void upLoadVideoCoverFail();
+
+        void upLoadImageSuccess(String avatarUrl);
+
+        void upLoadImageFailure();
+
+        void submitSetDetailSuccess(SetDetailBean setDetailBean);
+
+        void getUserInfoSuccess(TeacherUserInfo data);
     }
 
     interface Presenter {

+ 53 - 0
teacher/src/main/java/com/cooleshow/teacher/presenter/minestyle/MineStylePagePresenter.java

@@ -24,8 +24,10 @@ import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.api.APIService;
 import com.cooleshow.teacher.bean.HomePageSheetMusicListBean;
 import com.cooleshow.teacher.bean.TeacherSelfStyleInfoBean;
+import com.cooleshow.teacher.bean.TeacherUserInfo;
 import com.cooleshow.teacher.contract.MineStylePageContract;
 import com.cooleshow.teacher.ui.minestyle.MineStylePageActivity;
+import com.cooleshow.usercenter.bean.SetDetailBean;
 import com.daya.live_teaching.LiveTeachingApp;
 import com.daya.live_teaching.model.FileUploadBean;
 import com.daya.live_teaching.repository.ClassRepository;
@@ -181,6 +183,57 @@ public class MineStylePagePresenter extends BasePresenter<MineStylePageContract.
         });
     }
 
+    public void upLoadImage(Activity activity, String filePath) {
+        UploadHelper uploadHelper = new UploadHelper(activity, UploadConstants.UPLOAD_TYPE_OTHER);
+        uploadHelper.uploadFile(new File(filePath));
+        uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
+            @Override
+            public void onSuccess(String url) {
+                if (getView() != null) {
+                    getView().upLoadImageSuccess(url);
+                }
+            }
+
+            @Override
+            public void onFailure() {
+                if (getView() != null) {
+                    getView().upLoadImageFailure();
+                }
+            }
+        });
+    }
+
+    public void submitSetDetail(String jsonStr) {
+        if (getView() != null) {
+            getView().showLoading();
+        }
+        addSubscribe(create(APIService.class).submitSetDetail(RequestBodyUtil.convertToRequestBodyJson(jsonStr)), new BaseObserver<SetDetailBean>(getView()) {
+            @Override
+            protected void onSuccess(SetDetailBean data) {
+                if (getView() != null) {
+                    getView().submitSetDetailSuccess(data);
+                }
+            }
+        });
+    }
+
+    /**
+     * 获取userInfo
+     */
+    public void getUserInfoDetail() {
+        if (getView() != null) {
+            getView().showLoading();
+        }
+        addSubscribe(create(APIService.class).getTeacherUserInfo(), new BaseObserver<TeacherUserInfo>(getView()) {
+            @Override
+            protected void onSuccess(TeacherUserInfo data) {
+                if (getView() != null) {
+                    getView().getUserInfoSuccess(data);
+                }
+            }
+        });
+    }
+
 
     public void getUploadVideoCover(Activity activity, String videoFilePath) {
         Observable.create(new ObservableOnSubscribe<String>() {

+ 204 - 8
teacher/src/main/java/com/cooleshow/teacher/ui/minestyle/MineStylePageActivity.java

@@ -11,6 +11,8 @@ import android.text.TextWatcher;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.EditText;
+import android.widget.RadioGroup;
+import android.widget.TextView;
 
 import androidx.annotation.Nullable;
 import androidx.recyclerview.widget.GridLayoutManager;
@@ -23,20 +25,26 @@ import com.cooleshow.base.ui.activity.BaseMVPActivity;
 import com.cooleshow.base.ui.video.VideoPlayActivity;
 import com.cooleshow.base.utils.ActivityUtils;
 import com.cooleshow.base.utils.FileUtils;
+import com.cooleshow.base.utils.GlideUtils;
 import com.cooleshow.base.utils.GsonUtils;
 import com.cooleshow.base.utils.MyFileUtils;
+import com.cooleshow.base.utils.PopupUtil;
 import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.widgets.CommonItemDecoration;
 import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.adapter.MineStyleVideoAdapter;
 import com.cooleshow.teacher.adapter.TeachableSelectAdapter;
 import com.cooleshow.teacher.bean.TeachableInstrumentBean;
 import com.cooleshow.teacher.bean.TeacherSelfStyleInfoBean;
+import com.cooleshow.teacher.bean.TeacherUserInfo;
 import com.cooleshow.teacher.contract.MineStylePageContract;
 import com.cooleshow.teacher.databinding.ActivityMineStylePageBinding;
 import com.cooleshow.teacher.presenter.minestyle.MineStylePagePresenter;
 import com.cooleshow.teacher.widgets.MineStyleVideoItemDecoration;
+import com.cooleshow.usercenter.bean.SetDetailBean;
+import com.cooleshow.usercenter.helper.UserHelper;
 import com.daya.live_teaching.utils.GlideEngine;
 import com.google.android.flexbox.AlignItems;
 import com.google.android.flexbox.FlexDirection;
@@ -49,6 +57,9 @@ import com.luck.picture.lib.config.PictureMimeType;
 import com.luck.picture.lib.entity.LocalMedia;
 import com.tbruyelle.rxpermissions3.RxPermissions;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
@@ -66,6 +77,7 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
     private final int SELECT_RESULT = 1001;
     private final int CHOOSE_VIDEO = 1002;
     public final int REQUEST_CODE_LOCAL = 0x19;
+    public final int REQUEST_CODE_AVATAR = 0x20;
     private EditText etSelfIntroduction;
     private RecyclerView videoList;
     private MineStyleVideoAdapter mMineStyleVideoListAdapter;
@@ -75,6 +87,9 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
     private List<TeachableInstrumentBean> selectTeachableInstrument = new ArrayList<>();
     private int currentUploadCoverPosition = -1;
     private boolean isShowAuditTip = false;
+    private String currentAvatarUrl;
+    private String currentNickName;
+    private String isReal;
 
 
     @Override
@@ -118,6 +133,29 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
             case R.id.tv_add_style:
                 getVideoPermission();
                 break;
+            case R.id.iv_avatar:
+                selectHeader();
+                break;
+            case R.id.view_nick_click:
+                //昵称修改
+                if (!TextUtils.isEmpty(currentNickName)) {
+                    ARouter.getInstance().build(RouterPath.MineCenter.MINE_MODIFY_NICKNAME)
+                            .withString("userName", currentNickName)
+                            .navigation(this);
+                }
+                break;
+            case R.id.view_real_name_click:
+                //实名认证
+                if (!TextUtils.isEmpty(isReal) && TextUtils.equals(isReal, "0")) {
+                    ARouter.getInstance().build(RouterPath.MineCenter.MINE_PERSONAL_CERTIFICATION)
+                            .navigation(this);
+                }
+                break;
+            case R.id.view_phone_click:
+                //手机号
+                ARouter.getInstance().build(RouterPath.MineCenter.MINE_CHECK_MODIFY_PHONENUM)
+                        .navigation(this);
+                break;
         }
     }
 
@@ -133,7 +171,17 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
     @Override
     public void initData() {
         super.initData();
-        presenter.getTeacherSelfStyle();
+        if (presenter != null) {
+            presenter.getTeacherSelfStyle();
+        }
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        if (presenter != null) {
+            presenter.getUserInfoDetail();
+        }
     }
 
     private List<TeacherSelfStyleInfoBean.StyleVideoBean> videoBeanList = new ArrayList<>();
@@ -147,6 +195,10 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
         viewBinding.tvSelectFans.setOnClickListener(this);
         viewBinding.tvSave.setOnClickListener(this);
         viewBinding.tvAddStyle.setOnClickListener(this);
+        viewBinding.ivAvatar.setOnClickListener(this);
+        viewBinding.viewNickClick.setOnClickListener(this);
+        viewBinding.viewRealNameClick.setOnClickListener(this);
+        viewBinding.viewPhoneClick.setOnClickListener(this);
         GridLayoutManager manager = new GridLayoutManager(this, 2);
         videoList.setLayoutManager(manager);
 //        addEmptyVideoBean();
@@ -186,7 +238,7 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
             @Override
             public void onUploadCover(int position) {
                 currentUploadCoverPosition = position;
-                toAlbum();
+                toAlbum(false);
             }
         });
         rvTopSelect = viewBinding.rvTopSelect;
@@ -208,6 +260,16 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
             teachableSelectAdapter.notifyDataSetChanged();
         });
         addETListener();
+        viewBinding.rgSex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rb_male) {
+                    modifySex(true);
+                } else {
+                    modifySex(false);
+                }
+            }
+        });
     }
 
     /**
@@ -230,21 +292,21 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
     }
 
 
-    private void toAlbum() {
+    private void toAlbum(boolean isUploadAvatar) {
         new RxPermissions(this)
                 .request(Manifest.permission.CAMERA,
                         Manifest.permission.READ_EXTERNAL_STORAGE,
                         Manifest.permission.WRITE_EXTERNAL_STORAGE)
                 .subscribe(granted -> {
                     if (granted) {
-                        goAlbum();
+                        goAlbum(isUploadAvatar);
                     } else {
                         ToastUtil.getInstance().show(this, "请选择存储和相机权限!");
                     }
                 });
     }
 
-    private void goAlbum() {
+    private void goAlbum(boolean isUploadAvatar) {
         PictureSelector.create(this)
                 .openGallery(PictureMimeType.ofImage())//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
                 .loadImageEngine(GlideEngine.createGlideEngine())
@@ -255,7 +317,7 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
                 .showCropGrid(false)// 是否显示裁剪矩形网格 圆形裁剪时建议设为false    true or false
                 .compress(true)// 是否压缩 true or false
                 .circleDimmedLayer(false)// 是否圆形裁剪 true or false
-                .forResult(REQUEST_CODE_LOCAL);
+                .forResult(isUploadAvatar ? REQUEST_CODE_AVATAR : REQUEST_CODE_LOCAL);
     }
 
     private void addETListener() {
@@ -272,8 +334,8 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
 
             @Override
             public void afterTextChanged(Editable s) {
-                String trim = etSelfIntroduction.getText().toString();
-                viewBinding.tvNumHint.setText(trim.length() + "/200");
+//                String trim = etSelfIntroduction.getText().toString();
+//                viewBinding.tvNumHint.setText(trim.length() + "/200");
             }
         });
     }
@@ -368,9 +430,63 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
         if (isFinishing() || isDestroyed()) {
             return;
         }
+        ToastUtil.getInstance().showShort("封面上传失败");
+    }
+
+    @Override
+    public void upLoadImageSuccess(String avatarUrl) {
+        if (!checkActivityExist()) {
+            return;
+        }
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.put("avatar", avatarUrl);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        presenter.submitSetDetail(jsonObject.toString());
+    }
+
+    @Override
+    public void upLoadImageFailure() {
 
     }
 
+    @Override
+    public void submitSetDetailSuccess(SetDetailBean setDetailBean) {
+        if (!checkActivityExist()) {
+            return;
+        }
+        ToastUtil.getInstance().showShort("修改成功");
+        if (setDetailBean != null) {
+            GlideUtils.INSTANCE.loadImage(this, setDetailBean.avatar, viewBinding.ivAvatar, R.drawable.icon_teacher_default_head);
+        }
+    }
+
+    @Override
+    public void getUserInfoSuccess(TeacherUserInfo data) {
+        if (!checkActivityExist()) {
+            return;
+        }
+        if (data != null) {
+            //头像
+            this.currentAvatarUrl = data.heardUrl;
+            GlideUtils.INSTANCE.loadImage(MineStylePageActivity.this, data.heardUrl, viewBinding.ivAvatar, R.drawable.icon_teacher_default_head);
+            //名称
+            String teacherName = UserHelper.getTeacherName(data.username, data.userId);
+            this.currentNickName = teacherName;
+            viewBinding.tvNickname.setText(teacherName);
+            //实名状态
+            this.isReal = String.valueOf(data.isReal);
+            viewBinding.tvRealNameStatus.setText(data.isReal == 1 ? "已认证" : "未认证");
+            viewBinding.tvRealNameStatus.setTextColor(getResources().getColor(data.isReal == 1 ? com.cooleshow.base.R.color.color_cccccc : com.cooleshow.base.R.color.color_ff0000));
+            //性别
+            viewBinding.rgSex.check(TextUtils.equals(data.gender, "1") ? R.id.rb_male : R.id.rb_female);
+            //手机号
+            viewBinding.tvPhoneNum.setText(data.phone);
+        }
+    }
+
     private void addEmptyVideoBean() {
         TeacherSelfStyleInfoBean.StyleVideoBean styleVideoBean = new TeacherSelfStyleInfoBean.StyleVideoBean();
         styleVideoBean.type = 1;
@@ -391,6 +507,23 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
                 Uri uri = data.getData();
                 String v_path = FileUtils.getFilePathForN(uri, MineStylePageActivity.this);
                 presenter.uploadVideo(MineStylePageActivity.this, v_path);
+            } else if (requestCode == REQUEST_CODE_AVATAR) {
+                if (data != null) {
+                    // 图片、视频、音频选择结果回调
+                    List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
+                    String v_path = null;
+                    if (selectList != null && selectList.size() > 0) {
+                        v_path = selectList.get(0).getCompressPath();
+                    }
+                    if (!TextUtils.isEmpty(v_path)) {
+                        boolean isImg = MyFileUtils.isImg(v_path);
+                        if (isImg) {
+                            presenter.upLoadImage(MineStylePageActivity.this, v_path);
+                        } else {
+                            ToastUtil.getInstance().showShort("请选择图片类型文件");
+                        }
+                    }
+                }
             } else if (requestCode == REQUEST_CODE_LOCAL) {
                 if (data != null) {
                     // 图片、视频、音频选择结果回调
@@ -437,4 +570,67 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
         ActivityUtils.startActivityForResult(this, intent, CHOOSE_VIDEO);
 
     }
+
+    private void modifySex(boolean isMale) {
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.put("gender", isMale ? 1 : 0);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        presenter.submitSetDetail(jsonObject.toString());
+    }
+
+
+    private void selectHeader() {
+        PopupUtil.showInBottom(this, R.layout.pop_modify_header, (view, popupWindow) -> {
+            TextView tv_camera = view.findViewById(R.id.tv_camera);
+            TextView tv_album = view.findViewById(R.id.tv_album);
+            TextView tv_cancel = view.findViewById(R.id.tv_cancel);
+            tv_camera.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    toCamera();
+                    popupWindow.dismiss();
+                }
+            });
+            tv_album.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    toAlbum(true);
+                    popupWindow.dismiss();
+                }
+            });
+            tv_cancel.setOnClickListener(view1 -> popupWindow.dismiss());
+        });
+    }
+
+    private void toCamera() {
+        new RxPermissions(this)
+                .request(Manifest.permission.CAMERA,
+                        Manifest.permission.READ_EXTERNAL_STORAGE,
+                        Manifest.permission.WRITE_EXTERNAL_STORAGE)
+                .subscribe(granted -> {
+                    if (granted) {
+                        goCamera();
+                    } else {
+                        ToastUtil.getInstance().show(this, "请选择存储和相机权限!");
+                    }
+                });
+    }
+
+    private void goCamera() {
+        PictureSelector.create(this)
+                .openCamera(PictureMimeType.ofImage())
+                .loadImageEngine(GlideEngine.createGlideEngine())
+                .theme(com.cooleshow.base.R.style.picture_daya_style)// 主题样式设置 具体参考 values/styles   用法:R .style.picture.white.style
+                .selectionMode(PictureConfig.SINGLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
+                .enableCrop(true)// 是否裁剪 true or false
+                .cutOutQuality(100)
+                .showCropGrid(false)// 是否显示裁剪矩形网格 圆形裁剪时建议设为false    true or false
+                .compress(true)// 是否压缩 true or false
+                .circleDimmedLayer(true)// 是否圆形裁剪 true or false
+                .forResult(REQUEST_CODE_AVATAR);
+    }
+
 }

+ 22 - 3
teacher/src/main/res/layout/activity_mine_style_page.xml

@@ -87,7 +87,12 @@
                 app:layout_constraintLeft_toLeftOf="@+id/tv_avatar_title"
                 app:layout_constraintTop_toBottomOf="@+id/tv_avatar_title" />
 
-
+            <View
+                android:id="@+id/view_nick_click"
+                app:layout_constraintBottom_toBottomOf="@+id/tv_nickname_title"
+                app:layout_constraintTop_toTopOf="@+id/tv_nickname_title"
+                android:layout_width="match_parent"
+                android:layout_height="50dp"/>
             <ImageView
                 android:id="@+id/iv_nickname_edit"
                 android:layout_width="wrap_content"
@@ -122,6 +127,12 @@
                 app:layout_constraintLeft_toLeftOf="@+id/tv_nickname_title"
                 app:layout_constraintTop_toBottomOf="@+id/tv_nickname_title" />
 
+            <View
+                android:id="@+id/view_real_name_click"
+                app:layout_constraintBottom_toBottomOf="@+id/tv_real_name_title"
+                app:layout_constraintTop_toTopOf="@+id/tv_real_name_title"
+                android:layout_width="match_parent"
+                android:layout_height="50dp"/>
 
             <ImageView
                 android:id="@+id/iv_real_name_arrow"
@@ -160,6 +171,7 @@
                 app:layout_constraintTop_toBottomOf="@+id/tv_real_name_title" />
 
             <RadioGroup
+                android:id="@+id/rg_sex"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginEnd="14dp"
@@ -169,7 +181,7 @@
                 app:layout_constraintTop_toTopOf="@+id/tv_gender_title">
 
                 <RadioButton
-                    android:id="@+id/tv_male"
+                    android:id="@+id/rb_male"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:button="@drawable/selector_normal_style"
@@ -181,7 +193,7 @@
                     android:textSize="@dimen/sp_16" />
 
                 <RadioButton
-                    android:id="@+id/tv_female"
+                    android:id="@+id/rb_female"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_marginStart="30dp"
@@ -207,6 +219,13 @@
                 app:layout_constraintTop_toBottomOf="@+id/tv_gender_title" />
 
 
+            <View
+                android:id="@+id/view_phone_click"
+                app:layout_constraintBottom_toBottomOf="@+id/tv_phone_title"
+                app:layout_constraintTop_toTopOf="@+id/tv_phone_title"
+                android:layout_width="match_parent"
+                android:layout_height="50dp"/>
+
             <ImageView
                 android:id="@+id/iv_edit_phone"
                 android:layout_width="wrap_content"