diff --git a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java index 14b54c1..c4d8639 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java @@ -29,39 +29,17 @@ import btools.util.ProgressListener; public class DownloadService extends Service implements ProgressListener { private static final boolean DEBUG = false; - + public static boolean serviceState = false; private ServerConfig mServerConfig; - private NotificationHelper mNotificationHelper; private List mUrlList; private String baseDir; - private volatile String newDownloadAction = ""; private volatile String currentDownloadOperation = ""; private long availableSize; - private ServiceHandler mServiceHandler; - public static boolean serviceState = false; private boolean bIsDownloading; - // Handler that receives messages from the thread - private final class ServiceHandler extends Handler { - public ServiceHandler(Looper looper) { - super(looper); - } - - @Override - public void handleMessage(Message msg) { - bIsDownloading = true; - downloadFiles(); - - stopForeground(true); - stopSelf(msg.arg1); - mNotificationHelper.stopNotification(); - } - } - - @Override public void onCreate() { if (DEBUG) Log.d("SERVICE", "onCreate"); @@ -82,7 +60,6 @@ public class DownloadService extends Service implements ProgressListener { } - @Override public int onStartCommand(Intent intent, int flags, int startId) { if (DEBUG) Log.d("SERVICE", "onStartCommand"); @@ -105,7 +82,6 @@ public class DownloadService extends Service implements ProgressListener { return START_STICKY; } - @Override public void onDestroy() { if (DEBUG) Log.d("SERVICE", "onDestroy"); @@ -113,13 +89,11 @@ public class DownloadService extends Service implements ProgressListener { super.onDestroy(); } - @Override public IBinder onBind(Intent intent) { return null; } - public void downloadFiles() { // first check lookup table and profiles @@ -155,7 +129,6 @@ public class DownloadService extends Service implements ProgressListener { updateProgress("finished "); } - public void updateProgress(String progress) { if (!newDownloadAction.equals(progress)) { if (DEBUG) Log.d("BR", "up " + progress); @@ -466,9 +439,25 @@ public class DownloadService extends Service implements ProgressListener { } - public boolean isCanceled() { return BInstallerActivity.downloadCanceled; } + // Handler that receives messages from the thread + private final class ServiceHandler extends Handler { + public ServiceHandler(Looper looper) { + super(looper); + } + + @Override + public void handleMessage(Message msg) { + bIsDownloading = true; + downloadFiles(); + + stopForeground(true); + stopSelf(msg.arg1); + mNotificationHelper.stopNotification(); + } + } + }