Skip to content

Commit

Permalink
fix a bug
Browse files Browse the repository at this point in the history
fix a bug which cause when the video hasn't been downloaded yet,then we finish the activity and enter again,the file is wrong!
  • Loading branch information
af913337456 authored Nov 27, 2017
1 parent 4348aac commit d10ec15
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public abstract class SurfaceVideoViewCreator
private boolean isUseCache = false;
private boolean mNeedResume;

private boolean isFinishDownload = false;
public boolean debugModel = false;

protected abstract Activity getActivity();
Expand Down Expand Up @@ -180,6 +181,14 @@ public void onDestroy(){
progressBar = null;
statusButton = null;
interceptFlag = true;
if(!isFinishDownload){
// 如果还没下载完,清空缓存文件
if(videoFile != null){
Log.d(TAG, "还没下载完,清空缓存文件");
videoFile.delete();
}
}
isFinishDownload = false;
if (surfaceVideoView != null) {
surfaceVideoView.release();
surfaceVideoView = null;
Expand Down Expand Up @@ -315,6 +324,7 @@ protected String doInBackground(String[] params) {
fos.write(buf,0,numread);
}while(!interceptFlag);//点击取消就停止下载.
Log.d(TAG,"下载结束 ");
isFinishDownload = true;
fos.close();
is.close();
} catch (MalformedURLException e) {
Expand Down

0 comments on commit d10ec15

Please sign in to comment.