|
@@ -23,6 +23,8 @@ 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.MyFileUtils;
|
|
|
+import com.cooleshow.base.utils.SizeUtils;
|
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
|
import com.cooleshow.base.utils.ToastUtils;
|
|
|
import com.cooleshow.teacher.R;
|
|
@@ -33,12 +35,18 @@ import com.cooleshow.teacher.bean.TeacherSelfStyleInfoBean;
|
|
|
import com.cooleshow.teacher.contract.MineStylePageContract;
|
|
|
import com.cooleshow.teacher.databinding.ActivityMineStylePageBinding;
|
|
|
import com.cooleshow.teacher.presenter.minestyle.MineStylePagePresenter;
|
|
|
+import com.cooleshow.teacher.ui.mine.PersonalSettingActivity;
|
|
|
+import com.daya.live_teaching.utils.GlideEngine;
|
|
|
import com.google.android.flexbox.AlignItems;
|
|
|
import com.google.android.flexbox.FlexDirection;
|
|
|
import com.google.android.flexbox.FlexWrap;
|
|
|
import com.google.android.flexbox.FlexboxLayoutManager;
|
|
|
import com.google.android.flexbox.JustifyContent;
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.luck.picture.lib.PictureSelector;
|
|
|
+import com.luck.picture.lib.config.PictureConfig;
|
|
|
+import com.luck.picture.lib.config.PictureMimeType;
|
|
|
+import com.luck.picture.lib.entity.LocalMedia;
|
|
|
import com.tbruyelle.rxpermissions3.RxPermissions;
|
|
|
|
|
|
import java.io.Serializable;
|
|
@@ -57,6 +65,7 @@ import io.rong.imkit.utils.StatusBarUtil;
|
|
|
public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePageBinding, MineStylePagePresenter> implements MineStylePageContract.MineStylePageView, View.OnClickListener {
|
|
|
private final int SELECT_RESULT = 1001;
|
|
|
private final int CHOOSE_VIDEO = 1002;
|
|
|
+ public final int REQUEST_CODE_LOCAL = 0x19;
|
|
|
private EditText etSelfIntroduction;
|
|
|
private RecyclerView videoList;
|
|
|
private MineStyleVideoAdapter mMineStyleVideoListAdapter;
|
|
@@ -64,40 +73,42 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
|
|
|
private TeachableSelectAdapter teachableSelectAdapter;
|
|
|
private TeacherSelfStyleInfoBean myStyleInfoBean = null;
|
|
|
private List<TeachableInstrumentBean> selectTeachableInstrument = new ArrayList<>();
|
|
|
+ private int currentUploadCoverPosition = -1;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
switch (view.getId()) {
|
|
|
case R.id.tv_select_fans:
|
|
|
- Bundle bundle=new Bundle();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
bundle.putSerializable("selectTeachableInstrument", (Serializable) selectTeachableInstrument);
|
|
|
ARouter.getInstance().build(RouterPath.MineCenter.MINE_TEACHABLE_INSTRUMENT)
|
|
|
- .withBundle("bundle",bundle)
|
|
|
+ .withBundle("bundle", bundle)
|
|
|
.navigation(this, SELECT_RESULT);
|
|
|
break;
|
|
|
case R.id.tv_save:
|
|
|
Gson gson = new Gson();
|
|
|
myStyleInfoBean.styleVideo.clear();
|
|
|
for (TeacherSelfStyleInfoBean.StyleVideoBean styleVideoBean : videoBeanList) {
|
|
|
- if (styleVideoBean.type!=1){
|
|
|
+ if (styleVideoBean.type != 1) {
|
|
|
myStyleInfoBean.styleVideo.add(styleVideoBean);
|
|
|
}
|
|
|
}
|
|
|
- myStyleInfoBean.introduction=etSelfIntroduction.getText().toString().trim();
|
|
|
- String subjectIdStr="";
|
|
|
- String subjectNameStr="";
|
|
|
+ myStyleInfoBean.introduction = etSelfIntroduction.getText().toString().trim();
|
|
|
+ String subjectIdStr = "";
|
|
|
+ String subjectNameStr = "";
|
|
|
for (TeachableInstrumentBean teachableInstrumentBean : selectTeachableInstrument) {
|
|
|
- subjectIdStr+=","+teachableInstrumentBean.id;
|
|
|
- subjectNameStr+=","+teachableInstrumentBean.name;
|
|
|
+ subjectIdStr += "," + teachableInstrumentBean.id;
|
|
|
+ subjectNameStr += "," + teachableInstrumentBean.name;
|
|
|
}
|
|
|
- if (subjectIdStr.startsWith(",")){
|
|
|
- subjectIdStr= subjectIdStr.replaceFirst(",","");
|
|
|
+ if (subjectIdStr.startsWith(",")) {
|
|
|
+ subjectIdStr = subjectIdStr.replaceFirst(",", "");
|
|
|
}
|
|
|
- if (subjectNameStr.startsWith(",")){
|
|
|
- subjectNameStr= subjectNameStr.replaceFirst(",","");
|
|
|
+ if (subjectNameStr.startsWith(",")) {
|
|
|
+ subjectNameStr = subjectNameStr.replaceFirst(",", "");
|
|
|
}
|
|
|
- myStyleInfoBean.subjectId=subjectIdStr;
|
|
|
- myStyleInfoBean.subjectName=subjectNameStr;
|
|
|
+ myStyleInfoBean.subjectId = subjectIdStr;
|
|
|
+ myStyleInfoBean.subjectName = subjectNameStr;
|
|
|
presenter.saveTeacherStyle(gson.toJson(myStyleInfoBean));
|
|
|
break;
|
|
|
}
|
|
@@ -154,6 +165,12 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
|
|
|
}
|
|
|
mMineStyleVideoListAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUploadCover(int position) {
|
|
|
+ currentUploadCoverPosition = position;
|
|
|
+ toAlbum();
|
|
|
+ }
|
|
|
});
|
|
|
rvTopSelect = viewBinding.rvTopSelect;
|
|
|
//设置LayoutManager
|
|
@@ -176,6 +193,35 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
|
|
|
addETListener();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void toAlbum() {
|
|
|
+ new RxPermissions(this)
|
|
|
+ .request(Manifest.permission.CAMERA,
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
+ Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
+ .subscribe(granted -> {
|
|
|
+ if (granted) {
|
|
|
+ goAlbum();
|
|
|
+ } else {
|
|
|
+ ToastUtil.getInstance().show(this, "请选择存储和相机权限!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void goAlbum() {
|
|
|
+ PictureSelector.create(this)
|
|
|
+ .openGallery(PictureMimeType.ofImage())//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
|
|
|
+ .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
|
|
|
+ .cropImageWideHigh(SizeUtils.dp2px(157),SizeUtils.dp2px(106))
|
|
|
+ .showCropGrid(false)// 是否显示裁剪矩形网格 圆形裁剪时建议设为false true or false
|
|
|
+ .compress(true)// 是否压缩 true or false
|
|
|
+ .circleDimmedLayer(false)// 是否圆形裁剪 true or false
|
|
|
+ .forResult(REQUEST_CODE_LOCAL);
|
|
|
+ }
|
|
|
+
|
|
|
private void addETListener() {
|
|
|
etSelfIntroduction.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
@@ -218,20 +264,20 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
|
|
|
addEmptyVideoBean();
|
|
|
mMineStyleVideoListAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
- if (!TextUtils.isEmpty(styleInfoBean.subjectId)){
|
|
|
- if (styleInfoBean.subjectId.contains(",")){
|
|
|
+ if (!TextUtils.isEmpty(styleInfoBean.subjectId)) {
|
|
|
+ if (styleInfoBean.subjectId.contains(",")) {
|
|
|
String[] splitId = styleInfoBean.subjectId.split(",");
|
|
|
String[] splitName = styleInfoBean.subjectName.split(",");
|
|
|
for (int i = 0; i < splitId.length; i++) {
|
|
|
- TeachableInstrumentBean instrumentBean=new TeachableInstrumentBean();
|
|
|
- instrumentBean.id=Integer.parseInt(splitId[i]);
|
|
|
- instrumentBean.name=splitName[i];
|
|
|
+ TeachableInstrumentBean instrumentBean = new TeachableInstrumentBean();
|
|
|
+ instrumentBean.id = Integer.parseInt(splitId[i]);
|
|
|
+ instrumentBean.name = splitName[i];
|
|
|
selectTeachableInstrument.add(instrumentBean);
|
|
|
}
|
|
|
- }else{
|
|
|
- TeachableInstrumentBean instrumentBean=new TeachableInstrumentBean();
|
|
|
- instrumentBean.id=Integer.parseInt(styleInfoBean.subjectId);
|
|
|
- instrumentBean.name=styleInfoBean.subjectName;
|
|
|
+ } else {
|
|
|
+ TeachableInstrumentBean instrumentBean = new TeachableInstrumentBean();
|
|
|
+ instrumentBean.id = Integer.parseInt(styleInfoBean.subjectId);
|
|
|
+ instrumentBean.name = styleInfoBean.subjectName;
|
|
|
selectTeachableInstrument.add(instrumentBean);
|
|
|
}
|
|
|
teachableSelectAdapter.notifyDataSetChanged();
|
|
@@ -257,6 +303,28 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
|
|
|
public void upLoadVideoFailure() {
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void upLoadVideoCoverSuccess(String coverUrl) {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mMineStyleVideoListAdapter == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (currentUploadCoverPosition != -1 && currentUploadCoverPosition < videoBeanList.size()) {
|
|
|
+ videoBeanList.get(currentUploadCoverPosition).cover = coverUrl;
|
|
|
+ mMineStyleVideoListAdapter.notifyItemChanged(currentUploadCoverPosition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void upLoadVideoCoverFail() {
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void addEmptyVideoBean() {
|
|
|
TeacherSelfStyleInfoBean.StyleVideoBean styleVideoBean = new TeacherSelfStyleInfoBean.StyleVideoBean();
|
|
|
styleVideoBean.type = 1;
|
|
@@ -276,7 +344,26 @@ public class MineStylePageActivity extends BaseMVPActivity<ActivityMineStylePage
|
|
|
} else if (requestCode == CHOOSE_VIDEO) {
|
|
|
Uri uri = data.getData();
|
|
|
String v_path = FileUtils.getFilePathForN(uri, MineStylePageActivity.this);
|
|
|
- presenter.getUploadVideoCover(MineStylePageActivity.this, v_path);
|
|
|
+ presenter.uploadVideo(MineStylePageActivity.this, v_path);
|
|
|
+ } else if (requestCode == REQUEST_CODE_LOCAL) {
|
|
|
+ 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) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.uploadCover(MineStylePageActivity.this, v_path);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ToastUtil.getInstance().showShort("请选择图片类型文件");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|