diff --git a/app/src/main/java/com/pxkj/jwzs/FirstActivity.java b/app/src/main/java/com/pxkj/jwzs/FirstActivity.java index 8fc540c..9170eb6 100644 --- a/app/src/main/java/com/pxkj/jwzs/FirstActivity.java +++ b/app/src/main/java/com/pxkj/jwzs/FirstActivity.java @@ -276,7 +276,6 @@ public class FirstActivity extends BaseActivity { DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); if (dm != null) { currentDownloadId = dm.enqueue(request); - Toast.makeText(this, "文件已开始下载,请等待" + currentDownloadId, Toast.LENGTH_SHORT).show(); startDownloadProgressMonitor(dm, currentDownloadId); } else { Toast.makeText(this, "系统下载服务不可用", Toast.LENGTH_SHORT).show(); @@ -299,24 +298,23 @@ public class FirstActivity extends BaseActivity { while (downloading) { try { + Toast.makeText(this, "文件已开始下载,请等待", Toast.LENGTH_SHORT).show(); Thread.sleep(1000); android.database.Cursor cursor = dm.query(query); - Toast.makeText(this, "文件已开始下载,请等待" + cursor, Toast.LENGTH_SHORT).show(); if (cursor != null && cursor.moveToFirst()) { int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)); long total = cursor.getLong(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)); long downloaded = cursor.getLong(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); - Toast.makeText(this, "文件已开始下载,请等待" + status + "," + total + "," + downloaded, Toast.LENGTH_SHORT).show(); if (status == DownloadManager.STATUS_RUNNING && total > 0) { int progress = (int) ((downloaded * 100L) / total); - Toast.makeText(this, "1.文件已开始下载,部分进度,调用前端js" + status + "," + total + "," + downloaded, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, "下载中,当前进度为" + progress + "%", Toast.LENGTH_SHORT).show(); handler.post(() -> sendProgressToJs(progress)); } else if (status == DownloadManager.STATUS_SUCCESSFUL) { - Toast.makeText(this, "2.文件已开始下载,进度成功,调用前端js" + status + "," + total + "," + downloaded, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, "下载完成,请到文件管理查看", Toast.LENGTH_SHORT).show(); downloading = false; handler.post(() -> sendProgressToJs(100)); } else if (status == DownloadManager.STATUS_FAILED) { - Toast.makeText(this, "3.文件已开始下载,进度失败,调用前端js" + status + "," + total + "," + downloaded, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, "下载失败" + status + "," + total + "," + downloaded, Toast.LENGTH_SHORT).show(); downloading = false; handler.post(() -> sendProgressToJs(-1)); }