Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2021-05-24 18:21:52 +0300
committerStefan Niedermann <info@niedermann.it>2021-05-24 18:21:52 +0300
commitc57fb713acbfa6f531b0df85374719ef24500d63 (patch)
tree21f5fa7c3baee7d034ad2b2c09724473ecaf1c6d /app/src
parentb4d4cf5965073cdecdd2e2814d5f5e7e311b62e5 (diff)
Use executor for clearing Glide disk cache and fix unit tests
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/util/CustomAppGlideModule.java10
-rw-r--r--app/src/test/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapterTest.java7
2 files changed, 12 insertions, 5 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/util/CustomAppGlideModule.java b/app/src/main/java/it/niedermann/nextcloud/deck/util/CustomAppGlideModule.java
index 0b3841ac1..3e7b2d44b 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/util/CustomAppGlideModule.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/util/CustomAppGlideModule.java
@@ -12,10 +12,16 @@ import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
import it.niedermann.nextcloud.deck.DeckLog;
@GlideModule
public class CustomAppGlideModule extends AppGlideModule {
+
+ private static final ExecutorService clearDiskCacheExecutor = Executors.newSingleThreadExecutor();
+
@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
super.registerComponents(context, glide, registry);
@@ -29,10 +35,10 @@ public class CustomAppGlideModule extends AppGlideModule {
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
DeckLog.info("Clearing Glide memory cache");
Glide.get(context).clearMemory();
- new Thread(() -> {
+ clearDiskCacheExecutor.submit(() -> {
DeckLog.info("Clearing Glide disk cache");
Glide.get(context.getApplicationContext()).clearDiskCache();
- }).start();
+ });
} else {
DeckLog.info("Do not clear Glide caches, because the user currently does not have a working internet connection");
}
diff --git a/app/src/test/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapterTest.java b/app/src/test/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapterTest.java
index 68de2914a..d8e7ee83e 100644
--- a/app/src/test/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapterTest.java
+++ b/app/src/test/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapterTest.java
@@ -20,6 +20,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutorService;
@@ -81,7 +82,7 @@ public class DataBaseAdapterTest {
add(user);
}};
- final Method fillSqlWithListValues = DataBaseAdapter.class.getDeclaredMethod("fillSqlWithListValues", StringBuilder.class, List.class, List.class);
+ final Method fillSqlWithListValues = DataBaseAdapter.class.getDeclaredMethod("fillSqlWithListValues", StringBuilder.class, Collection.class, List.class);
fillSqlWithListValues.setAccessible(true);
fillSqlWithListValues.invoke(adapter, builder, args, entities);
assertEquals("?", builder.toString());
@@ -98,7 +99,7 @@ public class DataBaseAdapterTest {
add(leet);
}};
- final Method fillSqlWithListValues = DataBaseAdapter.class.getDeclaredMethod("fillSqlWithListValues", StringBuilder.class, List.class, List.class);
+ final Method fillSqlWithListValues = DataBaseAdapter.class.getDeclaredMethod("fillSqlWithListValues", StringBuilder.class, Collection.class, List.class);
fillSqlWithListValues.setAccessible(true);
fillSqlWithListValues.invoke(adapter, builder, args, entities);
assertEquals("?", builder.toString());
@@ -115,7 +116,7 @@ public class DataBaseAdapterTest {
add(leet+1);
}};
- final Method fillSqlWithListValues = DataBaseAdapter.class.getDeclaredMethod("fillSqlWithListValues", StringBuilder.class, List.class, List.class);
+ final Method fillSqlWithListValues = DataBaseAdapter.class.getDeclaredMethod("fillSqlWithListValues", StringBuilder.class, Collection.class, List.class);
fillSqlWithListValues.setAccessible(true);
fillSqlWithListValues.invoke(adapter, builder, args, entities);
assertEquals("?, ?", builder.toString());