From d704a40b66c58d0d63b584ba0c5f9115982eb383 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Sat, 22 Apr 2017 07:42:20 +0200 Subject: [PATCH] Regularly call cleanup() --- app/build.gradle | 6 +++--- .../abit/dialog/SelectEncodingDialogFragment.java | 3 +-- .../apps/abit/service/BitmessageService.java | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cdd925d..6284311 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,7 +39,7 @@ android { //ext.jabitVersion = '2.0.4' ext.jabitVersion = 'feature-extended-encoding-SNAPSHOT' -ext.supportVersion = '25.2.0' +ext.supportVersion = '25.3.1' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) @@ -63,9 +63,9 @@ dependencies { compile('com.mikepenz:aboutlibraries:5.9.5@aar') { transitive = true } - compile "com.mikepenz:iconics-core:2.8.2@aar" + compile "com.mikepenz:iconics-core:2.8.3@aar" compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar' - compile 'com.mikepenz:community-material-typeface:1.8.36.1@aar' + compile 'com.mikepenz:community-material-typeface:1.9.32.1@aar' compile 'com.journeyapps:zxing-android-embedded:3.5.0@aar' compile 'com.google.zxing:core:3.3.0' diff --git a/app/src/main/java/ch/dissem/apps/abit/dialog/SelectEncodingDialogFragment.java b/app/src/main/java/ch/dissem/apps/abit/dialog/SelectEncodingDialogFragment.java index 3b8b917..899ca0f 100644 --- a/app/src/main/java/ch/dissem/apps/abit/dialog/SelectEncodingDialogFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/dialog/SelectEncodingDialogFragment.java @@ -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); } diff --git a/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java b/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java index 5c8a528..ef64b61 100644 --- a/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java +++ b/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java @@ -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(); }