|
@@ -1,25 +1,50 @@
|
|
package com.cooleshow.teacher.ui.mine;
|
|
package com.cooleshow.teacher.ui.mine;
|
|
|
|
|
|
|
|
+import android.Manifest;
|
|
|
|
+import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
+import android.graphics.Bitmap;
|
|
|
|
+import android.net.Uri;
|
|
|
|
+import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.os.Environment;
|
|
|
|
+import android.provider.MediaStore;
|
|
|
|
+import android.text.TextUtils;
|
|
|
|
+import android.util.Log;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
+import android.widget.PopupWindow;
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
-import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
|
|
|
+import androidx.core.content.FileProvider;
|
|
|
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
import com.cooleshow.base.common.WebConstants;
|
|
import com.cooleshow.base.common.WebConstants;
|
|
import com.cooleshow.base.router.RouterPath;
|
|
import com.cooleshow.base.router.RouterPath;
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
|
|
+import com.cooleshow.base.utils.ActivityUtils;
|
|
|
|
+import com.cooleshow.base.utils.FileUtils;
|
|
import com.cooleshow.base.utils.GlideUtils;
|
|
import com.cooleshow.base.utils.GlideUtils;
|
|
|
|
+import com.cooleshow.base.utils.IntentUtils;
|
|
|
|
+import com.cooleshow.base.utils.PopupUtil;
|
|
|
|
+import com.cooleshow.base.utils.ToastUtil;
|
|
|
|
+import com.cooleshow.base.utils.UriUtils;
|
|
import com.cooleshow.teacher.R;
|
|
import com.cooleshow.teacher.R;
|
|
-import com.cooleshow.teacher.bean.TeacherSelfStyleInfoBean;
|
|
|
|
import com.cooleshow.teacher.contract.PersonalSettingContract;
|
|
import com.cooleshow.teacher.contract.PersonalSettingContract;
|
|
import com.cooleshow.teacher.databinding.ActivityPersonalSettingBinding;
|
|
import com.cooleshow.teacher.databinding.ActivityPersonalSettingBinding;
|
|
import com.cooleshow.teacher.presenter.mine.PersonalSettingPresenter;
|
|
import com.cooleshow.teacher.presenter.mine.PersonalSettingPresenter;
|
|
|
|
+import com.cooleshow.teacher.ui.minestyle.MineStylePageActivity;
|
|
|
|
+import com.cooleshow.usercenter.bean.SetDetailBean;
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
+import com.luck.picture.lib.tools.MediaUtils;
|
|
|
|
+import com.tbruyelle.rxpermissions3.RxPermissions;
|
|
|
|
|
|
-import java.io.Serializable;
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建日期:2022/5/16 16:07
|
|
* 创建日期:2022/5/16 16:07
|
|
@@ -29,38 +54,188 @@ import java.io.Serializable;
|
|
*/
|
|
*/
|
|
@Route(path = RouterPath.MineCenter.MINE_PERSONAL_SETTING)
|
|
@Route(path = RouterPath.MineCenter.MINE_PERSONAL_SETTING)
|
|
public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSettingBinding, PersonalSettingPresenter> implements PersonalSettingContract.PersonalSettingView, View.OnClickListener {
|
|
public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSettingBinding, PersonalSettingPresenter> implements PersonalSettingContract.PersonalSettingView, View.OnClickListener {
|
|
- private TeacherSelfStyleInfoBean teacherInfoBean;
|
|
|
|
|
|
+ private SetDetailBean mySetDetailBean;
|
|
private final int MODIFY_NICKNAME = 1001;
|
|
private final int MODIFY_NICKNAME = 1001;
|
|
|
|
+ private final int MODIFY_PHONE = 1002;
|
|
|
|
+ private final int PERSONAL_CERTIFICATION = 1003;
|
|
|
|
+ private final int REQUEST_CODE_CAMERA = 0x44;
|
|
|
|
+ public final int REQUEST_CODE_LOCAL = 0x19;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onClick(View view) {
|
|
public void onClick(View view) {
|
|
switch (view.getId()) {
|
|
switch (view.getId()) {
|
|
case R.id.cl_header:
|
|
case R.id.cl_header:
|
|
|
|
+ selectHeader();
|
|
break;
|
|
break;
|
|
case R.id.cl_name:
|
|
case R.id.cl_name:
|
|
- if (null != teacherInfoBean) {
|
|
|
|
|
|
+ if (null != mySetDetailBean) {
|
|
Bundle bundle = new Bundle();
|
|
Bundle bundle = new Bundle();
|
|
- bundle.putSerializable("teacherInfoBean",teacherInfoBean);
|
|
|
|
|
|
+ bundle.putSerializable("teacherInfoBean", mySetDetailBean);
|
|
ARouter.getInstance().build(RouterPath.MineCenter.MINE_MODIFY_NICKNAME)
|
|
ARouter.getInstance().build(RouterPath.MineCenter.MINE_MODIFY_NICKNAME)
|
|
.withBundle("bundle", bundle)
|
|
.withBundle("bundle", bundle)
|
|
- .navigation(this,MODIFY_NICKNAME);
|
|
|
|
|
|
+ .navigation(this, MODIFY_NICKNAME);
|
|
}
|
|
}
|
|
|
|
|
|
break;
|
|
break;
|
|
case R.id.cl_sex:
|
|
case R.id.cl_sex:
|
|
|
|
+ modifySex();
|
|
break;
|
|
break;
|
|
case R.id.cl_phone:
|
|
case R.id.cl_phone:
|
|
|
|
+ ARouter.getInstance().build(RouterPath.MineCenter.MINE_CHECK_MODIFY_PHONENUM)
|
|
|
|
+ .navigation(this, MODIFY_PHONE);
|
|
break;
|
|
break;
|
|
case R.id.cl_modify_psd:
|
|
case R.id.cl_modify_psd:
|
|
|
|
+ ARouter.getInstance().build(RouterPath.MineCenter.MINE_MODIFY_PASSWORD)
|
|
|
|
+ .withString("phoneNum", mySetDetailBean.phone)
|
|
|
|
+ .navigation();
|
|
break;
|
|
break;
|
|
case R.id.cl_certification:
|
|
case R.id.cl_certification:
|
|
- //老师认证
|
|
|
|
- ARouter.getInstance().build(RouterPath.WebCenter.ACTIVITY_HTML)
|
|
|
|
- .withString(WebConstants.WEB_URL, WebConstants.TEACHER_CERT)
|
|
|
|
- .navigation();
|
|
|
|
|
|
+ ARouter.getInstance().build(RouterPath.MineCenter.MINE_PERSONAL_CERTIFICATION)
|
|
|
|
+ .navigation(this, PERSONAL_CERTIFICATION);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void modifySex() {
|
|
|
|
+ PopupUtil.showInBottom(this, R.layout.pop_modify_sex, (view, popupWindow) -> {
|
|
|
|
+ TextView tv_boy = view.findViewById(R.id.tv_boy);
|
|
|
|
+ TextView tv_girl = view.findViewById(R.id.tv_girl);
|
|
|
|
+ TextView tv_cancel = view.findViewById(R.id.tv_cancel);
|
|
|
|
+ tv_boy.setOnClickListener(view13 -> {
|
|
|
|
+ SetDetailBean requestBean = new SetDetailBean();
|
|
|
|
+ requestBean.gender = 1;
|
|
|
|
+ requestBean.real = mySetDetailBean.real;
|
|
|
|
+ requestBean.phone = mySetDetailBean.phone;
|
|
|
|
+ requestBean.birthdate = mySetDetailBean.birthdate;
|
|
|
|
+ requestBean.avatar = mySetDetailBean.avatar;
|
|
|
|
+ requestBean.username = mySetDetailBean.username;
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ presenter.submitSetDetail(gson.toJson(requestBean));
|
|
|
|
+ });
|
|
|
|
+ tv_girl.setOnClickListener(view12 -> {
|
|
|
|
+ SetDetailBean requestBean = new SetDetailBean();
|
|
|
|
+ requestBean.gender = 0;
|
|
|
|
+ requestBean.real = mySetDetailBean.real;
|
|
|
|
+ requestBean.phone = mySetDetailBean.phone;
|
|
|
|
+ requestBean.birthdate = mySetDetailBean.birthdate;
|
|
|
|
+ requestBean.avatar = mySetDetailBean.avatar;
|
|
|
|
+ requestBean.username = mySetDetailBean.username;
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ presenter.submitSetDetail(gson.toJson(requestBean));
|
|
|
|
+ });
|
|
|
|
+ tv_cancel.setOnClickListener(view1 -> popupWindow.dismiss());
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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();
|
|
|
|
+ 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) {
|
|
|
|
+ /* Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
|
|
+ File file = new File(imagePath);
|
|
|
|
+ Uri imageUri = Uri.fromFile(file);
|
|
|
|
+ intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
|
|
|
+ Log.e("asdfasdfasdfadfs", "111111" );
|
|
|
|
+ ActivityUtils.startActivityForResult(this, intent, REQUEST_CODE_CAMERA);*/
|
|
|
|
+ imagePath = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera/" + System.currentTimeMillis()+".jpg";
|
|
|
|
+ requestCamera(imagePath);
|
|
|
|
+ } else {
|
|
|
|
+ ToastUtil.getInstance().show(this, "请选择存储和相机权限!");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void requestCamera(String filePath) {
|
|
|
|
+ File outputImage = new File(filePath);
|
|
|
|
+ /*
|
|
|
|
+ 创建一个File文件对象,用于存放摄像头拍下的图片,我们把这个图片命名为output_image.jpg
|
|
|
|
+ 并把它存放在应用关联缓存目录下,调用getExternalCacheDir()可以得到这个目录,为什么要
|
|
|
|
+ 用关联缓存目录呢?由于android6.0开始,读写sd卡列为了危险权限,使用的时候必须要有权限,
|
|
|
|
+ 应用关联目录则可以跳过这一步
|
|
|
|
+ */
|
|
|
|
+ try//判断图片是否存在,存在则删除在创建,不存在则直接创建
|
|
|
|
+ {
|
|
|
|
+ if (!outputImage.getParentFile().exists()) {
|
|
|
|
+ outputImage.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ if (outputImage.exists()) {
|
|
|
|
+ outputImage.delete();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ outputImage.createNewFile();
|
|
|
|
+ Uri imageUri;
|
|
|
|
+ if (Build.VERSION.SDK_INT >= 24) {
|
|
|
|
+ imageUri = FileProvider.getUriForFile(this,
|
|
|
|
+ "com.cooleshow.teacher.fileprovider", outputImage);
|
|
|
|
+ } else {
|
|
|
|
+ imageUri = Uri.fromFile(outputImage);
|
|
|
|
+ }
|
|
|
|
+ //使用隐示的Intent,系统会找到与它对应的活动,即调用摄像头,并把它存储
|
|
|
|
+ Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
|
|
|
|
+ intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
|
|
|
+ ActivityUtils.startActivityForResult(this, intent, REQUEST_CODE_CAMERA);
|
|
|
|
+ //调用会返回结果的开启方式,返回成功的话,则把它显示出来
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String imagePath = null;//当前图片的路径
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void toAlbum() {
|
|
|
|
+ new RxPermissions(this)
|
|
|
|
+ .request(Manifest.permission.CAMERA,
|
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
|
+ Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
|
+ .subscribe(granted -> {
|
|
|
|
+ if (granted) {
|
|
|
|
+ Intent intent;
|
|
|
|
+ if (Build.VERSION.SDK_INT < 19) {
|
|
|
|
+ intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
+ intent.setType("image/*");
|
|
|
|
+ } else {
|
|
|
|
+ intent = new Intent(Intent.ACTION_PICK,
|
|
|
|
+ android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
|
|
|
+ }
|
|
|
|
+ ActivityUtils.startActivityForResult(this, intent, REQUEST_CODE_LOCAL);
|
|
|
|
+ } else {
|
|
|
|
+ ToastUtil.getInstance().show(this, "请选择存储和相机权限!");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected void initView() {
|
|
protected void initView() {
|
|
initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "设置");
|
|
initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "设置");
|
|
@@ -75,7 +250,7 @@ public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSet
|
|
@Override
|
|
@Override
|
|
public void initData() {
|
|
public void initData() {
|
|
super.initData();
|
|
super.initData();
|
|
- presenter.getTeacherSelfStyle();
|
|
|
|
|
|
+ presenter.getSetDetail();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -89,35 +264,80 @@ public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSet
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getSelfStyleSuccess(TeacherSelfStyleInfoBean styleInfoBean) {
|
|
|
|
- teacherInfoBean = styleInfoBean;
|
|
|
|
- GlideUtils.INSTANCE.loadImage(this, styleInfoBean.avatar, viewBinding.imHeader, R.drawable.icon_teacher_default_head);
|
|
|
|
- viewBinding.tvNickname.setText(styleInfoBean.username);
|
|
|
|
- if (styleInfoBean.gender.equals("0")) {
|
|
|
|
|
|
+ public void getSetDetailSuccess(SetDetailBean setDetailBean) {
|
|
|
|
+ mySetDetailBean = setDetailBean;
|
|
|
|
+ GlideUtils.INSTANCE.loadImage(this, setDetailBean.avatar, viewBinding.imHeader, R.drawable.icon_teacher_default_head);
|
|
|
|
+ viewBinding.tvNickname.setText(setDetailBean.username);
|
|
|
|
+ if (setDetailBean.gender == 0) {
|
|
//女
|
|
//女
|
|
viewBinding.tvSex.setText("女");
|
|
viewBinding.tvSex.setText("女");
|
|
} else {
|
|
} else {
|
|
//男
|
|
//男
|
|
viewBinding.tvSex.setText("男");
|
|
viewBinding.tvSex.setText("男");
|
|
}
|
|
}
|
|
- viewBinding.tvPhone.setText(styleInfoBean.phone);
|
|
|
|
- if (styleInfoBean.isReal.equals("0")) {
|
|
|
|
|
|
+ viewBinding.tvPhone.setText(setDetailBean.phone);
|
|
|
|
+ if (setDetailBean.real) {
|
|
|
|
+ //是
|
|
|
|
+ viewBinding.tvCertificationStatus.setText("已认证");
|
|
|
|
+ } else {
|
|
//否
|
|
//否
|
|
viewBinding.tvCertificationStatus.setText("未认证");
|
|
viewBinding.tvCertificationStatus.setText("未认证");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void submitSetDetailSuccess(SetDetailBean setDetailBean) {
|
|
|
|
+ mySetDetailBean.gender = setDetailBean.gender;
|
|
|
|
+ if (setDetailBean.gender == 0) {
|
|
|
|
+ //女
|
|
|
|
+ viewBinding.tvSex.setText("女");
|
|
} else {
|
|
} else {
|
|
- //是
|
|
|
|
- viewBinding.tvCertificationStatus.setText("已认证");
|
|
|
|
|
|
+ //男
|
|
|
|
+ viewBinding.tvSex.setText("男");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public void upLoadImageSuccess(String url) {
|
|
|
|
+ hideLoading();
|
|
|
|
+ Log.e("aksjhkasndfs", "upLoadImageSuccess: " + url);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void upLoadImageFailure() {
|
|
|
|
+ hideLoading();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
if (resultCode == RESULT_OK) {
|
|
if (resultCode == RESULT_OK) {
|
|
if (requestCode == MODIFY_NICKNAME) {
|
|
if (requestCode == MODIFY_NICKNAME) {
|
|
String userName = data.getStringExtra("userName");
|
|
String userName = data.getStringExtra("userName");
|
|
- teacherInfoBean.username=userName;
|
|
|
|
|
|
+ mySetDetailBean.username = userName;
|
|
viewBinding.tvNickname.setText(userName);
|
|
viewBinding.tvNickname.setText(userName);
|
|
|
|
+ } else if (requestCode == MODIFY_PHONE) {
|
|
|
|
+ String newPhoneNum = data.getStringExtra("newPhoneNum");
|
|
|
|
+ mySetDetailBean.phone = newPhoneNum;
|
|
|
|
+ viewBinding.tvPhone.setText(newPhoneNum);
|
|
|
|
+ } else if (requestCode == PERSONAL_CERTIFICATION) {
|
|
|
|
+ viewBinding.tvCertificationStatus.setText("已认证");
|
|
|
|
+ } else if (requestCode == REQUEST_CODE_CAMERA) {
|
|
|
|
+ if (!TextUtils.isEmpty(imagePath)) {
|
|
|
|
+ showLoading();
|
|
|
|
+ presenter.upLoadImage(PersonalSettingActivity.this, imagePath);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if (requestCode == REQUEST_CODE_LOCAL) {
|
|
|
|
+ if (data != null) {
|
|
|
|
+ Uri selectedImage = data.getData();
|
|
|
|
+ if (selectedImage != null) {
|
|
|
|
+ String v_path = FileUtils.getFilePathForN(selectedImage, PersonalSettingActivity.this);
|
|
|
|
+ showLoading();
|
|
|
|
+ presenter.upLoadImage(PersonalSettingActivity.this, v_path);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|