Skip to content

Commit

Permalink
修复当选择分段录制模式录制视频然后删除恢复到初始模式时,无法进行拍照的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjh committed Nov 29, 2022
1 parent 3ba99aa commit f625d6b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,8 @@ public void resetStateAll() {

// 恢复底部按钮
getPhotoVideoLayout().reset();
// 恢复底部按钮操作模式
initPvLayoutButtonFeatures();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public class ClickOrLongButton extends View {
* 动画的预备时间
*/
private int mMinDurationAnimation = 1500;
/**
* 当前状态的动画预备时间
*/
private int mMinDurationAnimationCurrent = mMinDurationAnimation;
/**
* 记录当前录制的总共多长的时间秒
*/
Expand Down Expand Up @@ -185,6 +189,7 @@ public class ClickOrLongButton extends View {
* 如果中间中断或者重置,那就直接减1,就说明中断流程
*/
private int step;

/**
* 当前状态
*/
Expand Down Expand Up @@ -214,10 +219,10 @@ public void run() {
}
if (mIsSectionMode && mCurrentLocation.size() > 0) {
// 当处于分段录制模式并且有分段数据的时候,关闭启动前奏
mMinDurationAnimation = 0;
mMinDurationAnimationCurrent = 0;
}
long timeLapse = System.currentTimeMillis() - btnPressTime;
mRecordedTime = (timeLapse - mMinDurationAnimation);
mRecordedTime = (timeLapse - mMinDurationAnimationCurrent);
mRecordedTimeSection = mRecordedTime;
mRecordedTime = mRecordedTime + mCurrentSumTime;
float percent = mRecordedTime / timeLimitInMils;
Expand All @@ -244,10 +249,12 @@ public void run() {
* @param percent 当前百分比
*/
private void startAnimation(long timeLapse, float percent) {
if (timeLapse >= mMinDurationAnimation) {
Log.d(TAG, "startAnimation timeLapse " + timeLapse);
Log.d(TAG, "startAnimation mMinDurationAnimationCurrent " + mMinDurationAnimationCurrent);
if (timeLapse >= mMinDurationAnimationCurrent) {
synchronized (ClickOrLongButton.this) {
if (recordState == RECORD_NOT_STARTED) {
recordState = RECORD_STARTED;
setRecordState(RECORD_STARTED);
if (mClickOrLongListener != null) {
Log.d(TAG, "timeLapse " + timeLapse);
mClickOrLongListener.onLongClick();
Expand All @@ -270,7 +277,7 @@ private void startAnimation(long timeLapse, float percent) {
outMostWhiteCirclePaint.setColor(colorRoundBorder);
percentInDegree = (360.0F * percent);
if (mIsSectionMode) {
if (mCurrentLocation.size() > 0 || (timeLapse - mMinDurationAnimation) >= mMinDurationAnimation) {
if (mCurrentLocation.size() > 0 || (timeLapse - mMinDurationAnimationCurrent) >= mMinDurationAnimationCurrent) {
mCurrentSumNumberDegrees = percentInDegree;
}
}
Expand Down Expand Up @@ -556,10 +563,10 @@ public void refreshView() {
mClickOrLongListener.onLongClickEnd(mRecordedTime);
}
}
recordState = RECORD_ENDED;
setRecordState(RECORD_ENDED);
} else if (recordState == RECORD_ENDED) {
// 回到初始状态
recordState = RECORD_NOT_STARTED;
setRecordState(RECORD_NOT_STARTED);
} else {
// 如果只支持长按事件则不触发
if (mClickOrLongListener != null &&
Expand Down Expand Up @@ -640,7 +647,7 @@ public void setTouchable(boolean touchable) {
private void startTicking() {
synchronized (ClickOrLongButton.this) {
if (recordState != RECORD_NOT_STARTED) {
recordState = RECORD_NOT_STARTED;
setRecordState(RECORD_NOT_STARTED);
}
}
btnPressTime = System.currentTimeMillis();
Expand Down Expand Up @@ -693,6 +700,7 @@ public void setDuration(int duration) {
public void setMinDuration(int duration) {
mMinDuration = duration;
mMinDurationAnimation = duration;
mMinDurationAnimationCurrent = mMinDurationAnimation;
}

/**
Expand Down Expand Up @@ -746,7 +754,7 @@ public void setRecordingListener(ClickOrLongListener clickOrLongListener) {
public void setButtonFeatures(int buttonStateBoth) {
this.mButtonState = buttonStateBoth;
if (buttonStateBoth == BUTTON_STATE_CLICK_AND_HOLD) {
mMinDurationAnimation = 0;
mMinDurationAnimationCurrent = 0;
}
}

Expand All @@ -765,7 +773,15 @@ public void selectionRecordRollBack() {
*/
public void resetState() {
// 回到初始状态
recordState = RECORD_NOT_STARTED;
setRecordState(RECORD_NOT_STARTED);
// 预备时间也恢复到初始设置时的时间
mMinDurationAnimationCurrent = mMinDurationAnimation;
Log.d(TAG, "resetState");
}

private void setRecordState(int recordState) {
this.recordState = recordState;
Log.d(TAG, "setRecordState: " + recordState);
}

// endregion
Expand Down

0 comments on commit f625d6b

Please sign in to comment.