Reformat DownloadService
This commit is contained in:
parent
0a8d4dd1f2
commit
a091b07cb6
1 changed files with 18 additions and 29 deletions
|
@ -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<String> 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue