|
@@ -5,6 +5,7 @@ import android.content.Intent;
|
|
|
import android.content.pm.ActivityInfo;
|
|
|
import android.graphics.Color;
|
|
|
import android.graphics.Rect;
|
|
|
+import android.graphics.SurfaceTexture;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.media.MediaPlayer;
|
|
|
import android.os.Bundle;
|
|
@@ -14,14 +15,15 @@ import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.KeyEvent;
|
|
|
-import android.view.SurfaceHolder;
|
|
|
-import android.view.SurfaceView;
|
|
|
+import android.view.Surface;
|
|
|
+import android.view.TextureView;
|
|
|
import android.view.View;
|
|
|
import android.view.animation.LinearInterpolator;
|
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.SeekBar;
|
|
|
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
+import com.cooleshow.base.constanst.Constants;
|
|
|
import com.cooleshow.base.constanst.UploadConstants;
|
|
|
import com.cooleshow.base.router.RouterPath;
|
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
@@ -33,7 +35,6 @@ import com.cooleshow.base.utils.NumberUtils;
|
|
|
import com.cooleshow.base.utils.SizeUtils;
|
|
|
import com.cooleshow.base.utils.TimeUtils;
|
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
|
-import com.cooleshow.base.utils.UiUtils;
|
|
|
import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
|
|
|
import com.cooleshow.base.utils.helper.upload.UploadHelper;
|
|
|
import com.cooleshow.base.widgets.dialog.CommonConfirmDialog;
|
|
@@ -48,12 +49,12 @@ import com.cooleshow.musicmerge.helper.MixHelper;
|
|
|
import com.cooleshow.musicmerge.player.CustomPlayer;
|
|
|
import com.cooleshow.musicmerge.presenter.MusicFileHandlePresenter;
|
|
|
import com.cooleshow.musicmerge.viewmodel.MusicMergeViewModel;
|
|
|
+import com.cooleshow.musicmerge.widget.MergeLoadingTipDialog;
|
|
|
import com.luck.picture.lib.PictureSelector;
|
|
|
import com.luck.picture.lib.entity.LocalMedia;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.List;
|
|
|
-import java.util.Locale;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
@@ -63,15 +64,18 @@ import androidx.lifecycle.ViewModelProvider;
|
|
|
* Author by pq, Date on 2023/8/28.
|
|
|
*/
|
|
|
@Route(path = RouterPath.MusicTuner.MUSIC_MERGE_PAGE)
|
|
|
-public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBinding, MusicFileHandlePresenter> implements View.OnClickListener, SurfaceHolder.Callback, MusicFileHandleContract {
|
|
|
+public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBinding, MusicFileHandlePresenter> implements View.OnClickListener, MusicFileHandleContract, TextureView.SurfaceTextureListener {
|
|
|
public static final int REQUEST_CODE_LOCAL = 0x19;
|
|
|
+ public static final int REQUEST_CODE_LOCAL_VIDEO_COVER = 0x20;
|
|
|
+ public static final int REQUEST_CODE_VIDEO_COVER = 0x29;
|
|
|
private CustomPlayer player1;
|
|
|
private CustomPlayer player2;
|
|
|
private String accompanyUrl;
|
|
|
private String recordFilePath;
|
|
|
private MusicHandleSettingFragment mSettingFragment;
|
|
|
private boolean isVideo;
|
|
|
- private SurfaceView mSurfaceView;
|
|
|
+ private TextureView mSurfaceView;
|
|
|
+ private SurfaceTexture mSurfaceTexture;
|
|
|
private int videoWidth;
|
|
|
private int videoHeight;
|
|
|
private Handler mHandler = new Handler(Looper.getMainLooper());
|
|
@@ -88,6 +92,11 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
private boolean isNeedFinishPage = false;
|
|
|
|
|
|
private boolean isNeedResetScreenOrientation = true;
|
|
|
+ private MergeLoadingTipDialog mLoadingTipDialog;
|
|
|
+
|
|
|
+ private static int MAX_STEP = 3;
|
|
|
+ private static final int MAX_PROGRESS = 100;
|
|
|
+ private int currentStep = 0;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -115,18 +124,17 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
private void initSurfaceView() {
|
|
|
initVideoUIStyle();
|
|
|
+ mViewModel.getVideoFilePath().setValue(recordFilePath);
|
|
|
viewBinding.groupAudioView.setVisibility(View.GONE);
|
|
|
viewBinding.flSurface.setVisibility(View.VISIBLE);
|
|
|
viewBinding.viewVideoTopBg.setVisibility(View.VISIBLE);
|
|
|
viewBinding.viewVideoBottomBg.setVisibility(View.VISIBLE);
|
|
|
viewBinding.viewVideoBg.setVisibility(View.VISIBLE);
|
|
|
- mSurfaceView = new SurfaceView(MusicHandleActivity.this);
|
|
|
- SurfaceHolder holder = mSurfaceView.getHolder();
|
|
|
+ mSurfaceView = new TextureView(MusicHandleActivity.this);
|
|
|
+ mSurfaceView.setSurfaceTextureListener(this);
|
|
|
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
layoutParams.gravity = Gravity.CENTER;
|
|
|
viewBinding.flSurface.addView(mSurfaceView, layoutParams);
|
|
|
- holder.addCallback(MusicHandleActivity.this);
|
|
|
- holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
|
|
}
|
|
|
|
|
|
private void initVideoUIStyle() {
|
|
@@ -165,7 +173,7 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
}
|
|
|
accompanyUrl = getIntent().getStringExtra("accompanyUrl");
|
|
|
recordFilePath = getIntent().getStringExtra("recordFilePath");
|
|
|
-
|
|
|
+ initLoadingDialog();
|
|
|
initViewModel();
|
|
|
initFragment();
|
|
|
initListener();
|
|
@@ -197,6 +205,7 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
private void preLoad() {
|
|
|
isVideo = MyFileUtils.isVideo(recordFilePath);
|
|
|
LOG.i("isVideo:" + isVideo);
|
|
|
+ mViewModel.getIsVideoFile().setValue(isVideo);
|
|
|
boolean b = checkAccompanimentMp3File();
|
|
|
if (b) {
|
|
|
preparePlay();
|
|
@@ -242,6 +251,8 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void toMix(int offsetValue, float volume1, float volume2, boolean isNeedNotify) {
|
|
|
+ MAX_STEP = 3;
|
|
|
+ checkCoverToUpload();
|
|
|
if (isVideo) {
|
|
|
startMixForMp4(getAccompanyPath(), recordFilePath, offsetValue, volume1, volume2, isNeedNotify);
|
|
|
} else {
|
|
@@ -280,28 +291,48 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void checkCoverToUpload() {
|
|
|
+ MusicInfoBean value = mViewModel.getMusicInfoLiveData().getValue();
|
|
|
+ if (value != null) {
|
|
|
+ String preCover = value.getPreCover();
|
|
|
+ String videoCover = value.getVideoCover();
|
|
|
+ LOG.i("preCover:" + preCover);
|
|
|
+ LOG.i("videoCover:" + videoCover);
|
|
|
+ if (!TextUtils.isEmpty(preCover)) {
|
|
|
+ presenter.upLoadImage(null, preCover, false);
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(videoCover)) {
|
|
|
+ presenter.upLoadImage(null, videoCover, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void toSaveDraft() {
|
|
|
if (!TextUtils.isEmpty(recordFilePath)) {
|
|
|
if (!TextUtils.isEmpty(originalFileUrl)) {
|
|
|
+ MAX_STEP = 1;
|
|
|
+ toShowLoading(0, getString(R.string.save_draft_tip));
|
|
|
toNotifyDraft(originalFileUrl);
|
|
|
} else {
|
|
|
+ MAX_STEP = 2;
|
|
|
uploadDraft(recordFilePath);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void uploadDraft(String filePath) {
|
|
|
+ currentStep = 0;
|
|
|
File file = new File(filePath);
|
|
|
if (!file.exists()) {
|
|
|
return;
|
|
|
}
|
|
|
- setLoadingCancelable(false);
|
|
|
- showLoading("正在上传草稿0%");
|
|
|
+ toSetLoadingCancelable(false);
|
|
|
+ toShowLoading(getCurrentProgress(0), getString(R.string.updload_draft_tip));
|
|
|
UploadHelper uploadHelper = new UploadHelper(null, UploadConstants.UPLOAD_TYPE_HOMEWORK);
|
|
|
uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
|
|
|
@Override
|
|
|
protected void onSuccess(String url) {
|
|
|
- updateLoadingText("正在上传草稿100%");
|
|
|
+ toUpdateLoadingText(getCurrentProgress(100), getString(R.string.updload_draft_tip));
|
|
|
toNotifyDraft(url);
|
|
|
}
|
|
|
|
|
@@ -318,26 +349,28 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onUploadProgress(double v) {
|
|
|
- Log.i("pq","onUploadProgress"+v);
|
|
|
- updateLoadingText("正在上传草稿"+UiUtils.convertDouble(v)+"%");
|
|
|
+ Log.i("pq", "onUploadProgress" + v);
|
|
|
+// UiUtils.convertDouble(v)
|
|
|
+ toUpdateLoadingText(getCurrentProgress((int) v), getString(R.string.updload_draft_tip));
|
|
|
}
|
|
|
});
|
|
|
- uploadHelper.setLoadingTip("正在上传草稿");
|
|
|
+ uploadHelper.setLoadingTip(getString(R.string.updload_draft_tip));
|
|
|
|
|
|
uploadHelper.uploadFile(file);
|
|
|
}
|
|
|
|
|
|
private void upload(String filePath) {
|
|
|
+ currentStep = 1;
|
|
|
File file = new File(filePath);
|
|
|
if (!file.exists()) {
|
|
|
return;
|
|
|
}
|
|
|
- updateLoadingText("正在上传作品0%");
|
|
|
+ toUpdateLoadingText(getCurrentProgress(0), getString(R.string.upload_works_tip));
|
|
|
UploadHelper uploadHelper = new UploadHelper(null, UploadConstants.UPLOAD_TYPE_HOMEWORK);
|
|
|
uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
|
|
|
@Override
|
|
|
protected void onSuccess(String url) {
|
|
|
- updateLoadingText("正在上传作品100%");
|
|
|
+ toUpdateLoadingText(getCurrentProgress(100), getString(R.string.upload_works_tip));
|
|
|
toNotify(url);
|
|
|
}
|
|
|
|
|
@@ -354,10 +387,10 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onUploadProgress(double v) {
|
|
|
- updateLoadingText("正在上传作品"+ UiUtils.convertDouble(v)+"%");
|
|
|
+ toUpdateLoadingText(getCurrentProgress((int) v), getString(R.string.upload_works_tip));
|
|
|
}
|
|
|
});
|
|
|
- uploadHelper.setLoadingTip("正在上传作品");
|
|
|
+ uploadHelper.setLoadingTip(getString(R.string.upload_works_tip));
|
|
|
|
|
|
uploadHelper.uploadFile(file);
|
|
|
}
|
|
@@ -365,15 +398,17 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
private void toNotify(String url) {
|
|
|
String configJson = mSettingFragment.getConfigJson();
|
|
|
MusicInfoBean value = mViewModel.getMusicInfoLiveData().getValue();
|
|
|
+ String videoCover = "";
|
|
|
String cover = imgCover;
|
|
|
if (value != null) {
|
|
|
- String preCover = value.getPreCover();
|
|
|
- if (!TextUtils.isEmpty(preCover)) {
|
|
|
- cover = preCover;
|
|
|
- }
|
|
|
des = value.getDes();
|
|
|
+ videoCover = value.getVideoCover();
|
|
|
+ String cover1 = value.getCover();
|
|
|
+ if (!TextUtils.isEmpty(cover1)) {
|
|
|
+ cover = cover1;
|
|
|
+ }
|
|
|
}
|
|
|
- presenter.save(mRecordId, url, cover, des, configJson);
|
|
|
+ presenter.save(mRecordId, url, cover, videoCover, des, configJson);
|
|
|
}
|
|
|
|
|
|
private void toNotifyDraft(String url) {
|
|
@@ -384,24 +419,28 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
}
|
|
|
|
|
|
public void startMixForMp4(String accompanimentMp3Path, String recordFilePath, int offsetValue, float recordFileVolume, float accompanyFileVolume, boolean isNeedNotify) {
|
|
|
- setLoadingCancelable(false);
|
|
|
- showLoading(String.format(Locale.getDefault(), "视频合成中 %d%%", 0));
|
|
|
+ currentStep = 0;
|
|
|
+ toSetLoadingCancelable(false);
|
|
|
+ toShowLoading(getCurrentProgress(0), getString(R.string.video_merge_tip));
|
|
|
MixHelper.getInstance().startMixForMp4(accompanimentMp3Path, recordFilePath, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
|
|
|
@Override
|
|
|
public void onSuccess(String s) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- updateLoadingText(String.format(Locale.getDefault(), "视频合成中 %d%%", 100));
|
|
|
+ toUpdateLoadingText(getCurrentProgress(100), getString(R.string.video_merge_tip));
|
|
|
if (!TextUtils.isEmpty(s)) {
|
|
|
-// ToastUtil.getInstance().showShort("mix completed:" + s);
|
|
|
- FileUtils.notifySystemToScan(s);
|
|
|
if (isNeedNotify) {
|
|
|
upload(s);
|
|
|
} else {
|
|
|
+ FileUtils.notifySystemToScan(s);
|
|
|
ToastUtil.getInstance().showShort("保存成功");
|
|
|
}
|
|
|
} else {
|
|
|
+ hideLoading();
|
|
|
ToastUtil.getInstance().showShort("mix onFail");
|
|
|
}
|
|
|
}
|
|
@@ -410,17 +449,23 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onProgress(int progressPercent) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
LOG.i("progressPercent:" + progressPercent);
|
|
|
- updateLoadingText(String.format(Locale.getDefault(), "视频合成中 %d%%", progressPercent));
|
|
|
+ toUpdateLoadingText(getCurrentProgress(progressPercent), getString(R.string.video_merge_tip));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFail(int errorCode, String errorStr) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -433,25 +478,28 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
}
|
|
|
|
|
|
private void startMix(String accompanimentMp3Path, String recordFilePath, int offsetValue, float recordFileVolume, float accompanyFileVolume, boolean isNeedNotify) {
|
|
|
- setLoadingCancelable(false);
|
|
|
- showLoading(String.format(Locale.getDefault(), "音频合成中 %d%%", 0));
|
|
|
+ currentStep = 0;
|
|
|
+ toSetLoadingCancelable(false);
|
|
|
+ toShowLoading(getCurrentProgress(0), getString(R.string.audio_merge_tip));
|
|
|
MixHelper.getInstance().startMix(accompanimentMp3Path, recordFilePath, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
|
|
|
@Override
|
|
|
public void onSuccess(String s) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- updateLoadingText(String.format(Locale.getDefault(), "音频合成中 %d%%", 100));
|
|
|
- hideLoading();
|
|
|
-// ToastUtil.getInstance().showShort("mix completed:" + s);
|
|
|
+ toUpdateLoadingText(getCurrentProgress(100), getString(R.string.audio_merge_tip));
|
|
|
if (!TextUtils.isEmpty(s)) {
|
|
|
- FileUtils.notifySystemToScan(s);
|
|
|
if (isNeedNotify) {
|
|
|
upload(s);
|
|
|
} else {
|
|
|
+ FileUtils.notifySystemToScan(s);
|
|
|
ToastUtil.getInstance().showShort("保存成功");
|
|
|
}
|
|
|
} else {
|
|
|
+ hideLoading();
|
|
|
ToastUtil.getInstance().showShort("mix onFail");
|
|
|
}
|
|
|
}
|
|
@@ -460,17 +508,23 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onProgress(int progressPercent) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
LOG.i("progressPercent:" + progressPercent);
|
|
|
- updateLoadingText(String.format(Locale.getDefault(), "音频合成中 %d%%", progressPercent));
|
|
|
+ toUpdateLoadingText(getCurrentProgress(progressPercent), getString(R.string.audio_merge_tip));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFail(int errorCode, String errorStr) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -630,7 +684,7 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
layoutParams.width = w;
|
|
|
layoutParams.height = h;
|
|
|
mSurfaceView.setLayoutParams(layoutParams);
|
|
|
- mSurfaceView.getHolder().setFixedSize(w, h);
|
|
|
+// mSurfaceView.getHolder().setFixedSize(w, h);
|
|
|
}
|
|
|
|
|
|
private boolean checkRecordFile() {
|
|
@@ -664,6 +718,9 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
MixHelper.getInstance().download(recordUrl, fileEndSuffix, new ResultCallback<String>() {
|
|
|
@Override
|
|
|
public void onSuccess(String s) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -675,6 +732,9 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onProgress(int progressPercent) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -685,6 +745,9 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onFail(int errorCode, String errorStr) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -712,6 +775,9 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
MixHelper.getInstance().download(accompanyUrl, MyFileUtils.MP3_FILE_SUFFIX, new ResultCallback<String>() {
|
|
|
@Override
|
|
|
public void onSuccess(String s) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -723,6 +789,9 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onProgress(int progressPercent) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -733,6 +802,9 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
|
|
|
@Override
|
|
|
public void onFail(int errorCode, String errorStr) {
|
|
|
+ if(!checkActivityExist()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -749,11 +821,15 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
@Override
|
|
|
public void hideLoading() {
|
|
|
setLoadingCancelable(true);
|
|
|
+ toSetLoadingCancelable(true);
|
|
|
+ if (mLoadingTipDialog != null) {
|
|
|
+ mLoadingTipDialog.hide();
|
|
|
+ }
|
|
|
super.hideLoading();
|
|
|
}
|
|
|
|
|
|
private String getAccompanyPath() {
|
|
|
- String accompanyPath = MixHelper.getInstance().getDownloadSavePath(accompanyUrl);
|
|
|
+ String accompanyPath = MixHelper.getInstance().getDownloadSavePath(accompanyUrl, MyFileUtils.MP3_FILE_SUFFIX);
|
|
|
return accompanyPath;
|
|
|
}
|
|
|
|
|
@@ -941,12 +1017,15 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
if (!checkActivityExist()) {
|
|
|
return;
|
|
|
}
|
|
|
- showToastViewAndFinish("发布成功");
|
|
|
+ currentStep = 2;
|
|
|
+ showToastViewAndFinish("发布成功",true);
|
|
|
}
|
|
|
|
|
|
- private void toFinish() {
|
|
|
+ private void toFinish(boolean isReCallBack) {
|
|
|
Intent intent = new Intent();
|
|
|
- intent.putExtra("saveWorksStatus", 1);
|
|
|
+ if (isReCallBack) {
|
|
|
+ intent.putExtra("saveWorksStatus", 1);
|
|
|
+ }
|
|
|
setResult(RESULT_OK, intent);
|
|
|
finish();
|
|
|
}
|
|
@@ -983,38 +1062,58 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
if (!checkActivityExist()) {
|
|
|
return;
|
|
|
}
|
|
|
+ currentStep = 1;
|
|
|
mViewModel.getUpdateEvent().setValue(false);
|
|
|
if (isNeedFinishPage) {
|
|
|
- showToastViewAndFinish("保存成功");
|
|
|
+ showToastViewAndFinish("保存成功",false);
|
|
|
} else {
|
|
|
- ToastUtil.getInstance().showShort("保存成功");
|
|
|
+ toUpdateLoadingText(getCurrentProgress(100), "保存成功");
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ hideLoading();
|
|
|
+ }
|
|
|
+ }, 1500);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void showToastViewAndFinish(String tip) {
|
|
|
+ private void showToastViewAndFinish(String tip, boolean isReCallBack) {
|
|
|
//测试lyr提出提示要在当前面提示,所以给出延迟finish
|
|
|
- viewBinding.tvToastView.setText(tip);
|
|
|
- viewBinding.tvToastView.setVisibility(View.VISIBLE);
|
|
|
+// viewBinding.tvToastView.setText(tip);
|
|
|
+// viewBinding.tvToastView.setVisibility(View.VISIBLE);
|
|
|
+ toUpdateLoadingText(getCurrentProgress(100), tip);
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- toFinish();
|
|
|
+ hideLoading();
|
|
|
+ toFinish(isReCallBack);
|
|
|
}
|
|
|
}, 1500);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void upLoadImageSuccess(String url) {
|
|
|
+ public void upLoadImageSuccess(String url, boolean isVideoCover) {
|
|
|
if (!checkActivityExist()) {
|
|
|
return;
|
|
|
}
|
|
|
- refreshMusicInfoPreCover(url);
|
|
|
+ if (mViewModel != null) {
|
|
|
+ if (isVideoCover) {
|
|
|
+ mViewModel.refreshMusicVideoCover(url);
|
|
|
+ } else {
|
|
|
+ mViewModel.refreshMusicWorksCover(url);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void refreshMusicInfoPreCover(String imgCover) {
|
|
|
mViewModel.refreshMusicPreCover(imgCover);
|
|
|
}
|
|
|
|
|
|
+ private void refreshMusicInfoVideoCover(String imgCover) {
|
|
|
+ mViewModel.refreshMusicVideoCover(imgCover);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void refreshMusicInfo(String imgCover) {
|
|
|
MusicInfoBean bean = new MusicInfoBean();
|
|
|
bean.setCover(imgCover);
|
|
@@ -1022,16 +1121,24 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
mViewModel.getMusicInfoLiveData().setValue(bean);
|
|
|
}
|
|
|
|
|
|
+ private int getCurrentProgress(int progress) {
|
|
|
+ float singleStepMaxProgress = MAX_PROGRESS * 1.0f / MAX_STEP;
|
|
|
+ float progressPercent = progress * 1.0f / 100;
|
|
|
+ int result = (int) (singleStepMaxProgress * currentStep + singleStepMaxProgress * progressPercent);
|
|
|
+ LOG.i("progress:" + progress + "--currentStep:" + currentStep + "--currentStepProgress" + singleStepMaxProgress * currentStep + "--progressPercent:" + progressPercent + "--result:" + result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void upLoadImageFailure() {
|
|
|
- ToastUtil.getInstance().showShort("上传失败,请重试");
|
|
|
+ ToastUtil.getInstance().showShort("封面上传失败");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
- if (requestCode == REQUEST_CODE_LOCAL) {
|
|
|
+ if (requestCode == REQUEST_CODE_LOCAL || requestCode == REQUEST_CODE_LOCAL_VIDEO_COVER) {
|
|
|
if (data != null) {
|
|
|
// 图片、视频、音频选择结果回调
|
|
|
List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
|
|
@@ -1042,13 +1149,48 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
if (!TextUtils.isEmpty(v_path)) {
|
|
|
boolean isImg = MyFileUtils.isImg(v_path);
|
|
|
if (isImg) {
|
|
|
- presenter.upLoadImage(MusicHandleActivity.this, v_path);
|
|
|
+ if (requestCode == REQUEST_CODE_LOCAL_VIDEO_COVER) {
|
|
|
+ refreshMusicInfoVideoCover(v_path);
|
|
|
+ } else {
|
|
|
+ refreshMusicInfoPreCover(v_path);
|
|
|
+ }
|
|
|
} else {
|
|
|
ToastUtil.getInstance().showShort("请选择图片类型文件");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (requestCode == REQUEST_CODE_VIDEO_COVER) {
|
|
|
+ if (data != null) {
|
|
|
+ String imgPath = data.getStringExtra(Constants.COMMON_EXTRA_KEY);
|
|
|
+ refreshMusicInfoVideoCover(imgPath);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void toShowLoading(int progress, String text) {
|
|
|
+ if (mLoadingTipDialog != null) {
|
|
|
+ mLoadingTipDialog.showLoading(progress, text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void toSetLoadingCancelable(boolean flag) {
|
|
|
+ if (mLoadingTipDialog != null) {
|
|
|
+ mLoadingTipDialog.setLoadingCancelable(flag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void toUpdateLoadingText(int progress, String text) {
|
|
|
+ if (mLoadingTipDialog != null) {
|
|
|
+ mLoadingTipDialog.updateLoadingText(progress, text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initLoadingDialog() {
|
|
|
+ if (mLoadingTipDialog == null) {
|
|
|
+ mLoadingTipDialog = new MergeLoadingTipDialog(this);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1059,7 +1201,9 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
if (mHandler != null) {
|
|
|
mHandler.removeCallbacksAndMessages(null);
|
|
|
}
|
|
|
-
|
|
|
+ if (mSurfaceView != null && mSurfaceView.getSurfaceTexture() != null) {
|
|
|
+ mSurfaceView.getSurfaceTexture().release();
|
|
|
+ }
|
|
|
if (player1 != null) {
|
|
|
player1.release();
|
|
|
}
|
|
@@ -1083,26 +1227,32 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
|
|
- LOG.i("surfaceCreated");
|
|
|
- player1.setSurface(holder);
|
|
|
- toPlay(getAccompanyPath());
|
|
|
+ public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surface, int width, int height) {
|
|
|
+ if (mSurfaceTexture == null) {
|
|
|
+ mSurfaceTexture = surface;
|
|
|
+ } else {
|
|
|
+ mSurfaceView.setSurfaceTexture(mSurfaceTexture);
|
|
|
+ }
|
|
|
+ if (player1 != null) {
|
|
|
+ toPlay(getAccompanyPath());
|
|
|
+ player1.setSurface(new Surface(mSurfaceTexture));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
|
|
|
- LOG.i("surfaceChanged");
|
|
|
- player1.setSurface(holder);
|
|
|
+ public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surface, int width, int height) {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
|
|
|
- LOG.i("surfaceDestroyed");
|
|
|
- if (player1 != null && player1.isPlaying()) {
|
|
|
- pausePlay();
|
|
|
- }
|
|
|
+ public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surface) {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void finish() {
|