Regularly call cleanup()
This commit is contained in:
@ -46,8 +46,7 @@ public class SelectEncodingDialogFragment extends AppCompatDialogFragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
|
||||
savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (getArguments() != null && getArguments().containsKey(EXTRA_ENCODING)) {
|
||||
encoding = (Plaintext.Encoding) getArguments().getSerializable(EXTRA_ENCODING);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package ch.dissem.apps.abit.service;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
@ -38,6 +39,17 @@ public class BitmessageService extends Service {
|
||||
|
||||
private NetworkNotification notification = null;
|
||||
|
||||
private final Handler cleanupHandler = new Handler();
|
||||
private final Runnable cleanupTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bmc.cleanup();
|
||||
if (isRunning()) {
|
||||
cleanupHandler.postDelayed(this, 24 * 60 * 60 * 1000L);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static boolean isRunning() {
|
||||
return running && bmc.isRunning();
|
||||
}
|
||||
@ -61,6 +73,7 @@ public class BitmessageService extends Service {
|
||||
bmc.startup();
|
||||
}
|
||||
notification.show();
|
||||
cleanupHandler.postDelayed(cleanupTask, 24 * 60 * 60 * 1000L);
|
||||
}
|
||||
return Service.START_STICKY;
|
||||
}
|
||||
@ -72,6 +85,8 @@ public class BitmessageService extends Service {
|
||||
}
|
||||
running = false;
|
||||
notification.showShutdown();
|
||||
cleanupHandler.removeCallbacks(cleanupTask);
|
||||
bmc.cleanup();
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user