Skip to content

Commit c11f6a8

Browse files
committed
新增存储空间不足状态
1 parent c116e09 commit c11f6a8

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

app/src/main/java/jaygoo/m3u8downloader/VideoListAdapter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ private void setStateText(TextView stateTv, M3U8Task task){
7272
stateTv.setText("正在下载");
7373
break;
7474
case M3U8TaskState.ERROR:
75-
stateTv.setText("下载出错");
75+
stateTv.setText("下载异常,点击重试");
76+
break;
77+
//关于存储空间不足测试方案,参考 http://blog.csdn.net/google_acmer/article/details/78649720
78+
case M3U8TaskState.ENOSPC:
79+
stateTv.setText("存储空间不足");
7680
break;
7781
case M3U8TaskState.PREPARE:
7882
stateTv.setText("准备中");

library/src/main/java/jaygoo/library/m3u8downloader/M3U8Downloader.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,16 @@ public void onStart() {
348348

349349
@Override
350350
public void onError(Throwable errorMsg) {
351+
if (errorMsg.getMessage() != null && errorMsg.getMessage().contains("ENOSPC")){
352+
currentM3U8Task.setState(M3U8TaskState.ENOSPC);
353+
}else {
351354
currentM3U8Task.setState(M3U8TaskState.ERROR);
352-
if (onM3U8DownloadListener != null) {
353-
onM3U8DownloadListener.onDownloadError(currentM3U8Task, errorMsg);
354-
}
355-
M3U8Log.e("onError: " + errorMsg.getMessage());
356-
downloadNextTask();
355+
}
356+
if (onM3U8DownloadListener != null) {
357+
onM3U8DownloadListener.onDownloadError(currentM3U8Task, errorMsg);
358+
}
359+
M3U8Log.e("onError: " + errorMsg.getMessage());
360+
downloadNextTask();
357361
}
358362

359363
};

library/src/main/java/jaygoo/library/m3u8downloader/bean/M3U8TaskState.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ public class M3U8TaskState {
1616
public static final int SUCCESS = 3;//下载完成
1717
public static final int ERROR = 4;//下载出错
1818
public static final int PAUSE = 5;//下载暂停
19+
public static final int ENOSPC = 6;//空间不足
20+
1921
}

0 commit comments

Comments
 (0)