Skip to content

Commit

Permalink
fix some handler
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuoSmall committed Nov 21, 2018
1 parent ef07cce commit 36c5405
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,10 @@ public void onAudioFocusChange(int focusChange) {
case AudioManager.AUDIOFOCUS_GAIN:
break;
case AudioManager.AUDIOFOCUS_LOSS:
post(new Runnable() {
@Override
public void run() {
//todo 判断如果不是外界造成的就不处理
}
});
//todo 判断如果不是外界造成的就不处理
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
post(new Runnable() {
@Override
public void run() {
//todo 判断如果不是外界造成的就不处理
}
});
//todo 判断如果不是外界造成的就不处理
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -899,6 +901,7 @@ protected void setTextAndProgress(int secProgress) {
int duration = getDuration();
int progress = position * 100 / (duration == 0 ? 1 : duration);
setProgressAndTime(progress, secProgress, position, duration);
setProgressAndTime(progress, secProgress, position, duration);
}

protected void setProgressAndTime(int progress, int secProgress, int currentTime, int totalTime) {
Expand Down Expand Up @@ -1042,12 +1045,14 @@ private class ProgressTimerTask extends TimerTask {
@Override
public void run() {
if (mCurrentState == CURRENT_STATE_PLAYING || mCurrentState == CURRENT_STATE_PAUSE) {
post(new Runnable() {
@Override
public void run() {
setTextAndProgress(0);
}
});
new Handler(Looper.getMainLooper()).post(
new Runnable() {
@Override
public void run() {
setTextAndProgress(0);
}
}
);
}
}
}
Expand All @@ -1060,16 +1065,18 @@ public void run() {
&& mCurrentState != CURRENT_STATE_ERROR
&& mCurrentState != CURRENT_STATE_AUTO_COMPLETE) {
if (getActivityContext() != null) {
((Activity) getActivityContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
hideAllWidget();
setViewShowState(mLockScreen, GONE);
if (mHideKey && mIfCurrentIsFullscreen && mShowVKey) {
hideNavKey(mContext);
new Handler(Looper.getMainLooper()).post(
new Runnable() {
@Override
public void run() {
hideAllWidget();
setViewShowState(mLockScreen, GONE);
if (mHideKey && mIfCurrentIsFullscreen && mShowVKey) {
hideNavKey(mContext);
}
}
}
}
});
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.graphics.RectF;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand All @@ -27,7 +29,6 @@
import java.io.File;
import java.util.HashMap;
import java.util.Map;

import static com.shuyu.gsyvideoplayer.utils.CommonUtil.getTextSpeed;

/**
Expand Down Expand Up @@ -364,7 +365,7 @@ protected void onGankAudio() {
* 失去了Audio Focus,并将会持续很长的时间
*/
protected void onLossAudio() {
this.post(new Runnable() {
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
if (GSYVideoView.this.mReleaseWhenLossAudio) {
GSYVideoView.this.releaseVideos();
Expand Down

0 comments on commit 36c5405

Please sign in to comment.