From c4a5e8dc86fd6060bc21effc5f6f9242760741d4 Mon Sep 17 00:00:00 2001 From: kapodamy Date: Tue, 15 Jan 2019 14:58:56 -0300 Subject: [PATCH] misc fixes * add null checks before resuming a download * (MissionAdapter.java) reset percent after resuming a download. prevents the "Error" string get stuck, until the download start --- app/src/main/java/us/shandian/giga/get/DownloadMission.java | 5 +++-- .../java/us/shandian/giga/ui/adapter/MissionAdapter.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/us/shandian/giga/get/DownloadMission.java b/app/src/main/java/us/shandian/giga/get/DownloadMission.java index c25d517f1..b41cfc350 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadMission.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadMission.java @@ -407,7 +407,8 @@ public class DownloadMission extends Mission { // ensure that the previous state is completely paused. joinForThread(init); - for (Thread thread : threads) joinForThread(thread); + if (threads != null) + for (Thread thread : threads) joinForThread(thread); enqueued = false; running = true; @@ -420,7 +421,7 @@ public class DownloadMission extends Mission { init = null; - if (threads.length < 1) { + if (threads == null || threads.length < 1) { threads = new Thread[currentThreadCount]; } diff --git a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java index 5057ed6db..28e7ef480 100644 --- a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java +++ b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java @@ -447,6 +447,7 @@ public class MissionAdapter extends Adapter { if (mission != null) { switch (id) { case R.id.start: + h.status.setText(UNDEFINED_SPEED); h.state = -1; h.size.setText(Utility.formatBytes(mission.getLength())); mDownloadManager.resumeMission(mission);