Clear contact info on low memory

This commit is contained in:
M66B 2020-09-27 10:42:12 +02:00
parent d0807bb283
commit e5bfbce6b0
2 changed files with 14 additions and 1 deletions

View File

@ -152,6 +152,9 @@ public class ApplicationEx extends Application {
Map<String, String> crumb = new HashMap<>();
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
Log.breadcrumb("low", crumb);
ContactInfo.clearCache(this, false);
super.onLowMemory();
}

View File

@ -138,12 +138,22 @@ public class ContactInfo {
}
static void clearCache(Context context) {
clearCache(context, true);
}
static void clearCache(Context context, boolean files) {
synchronized (emailContactInfo) {
emailContactInfo.clear();
}
final File dir = new File(context.getCacheDir(), "favicons");
synchronized (emailGravatar) {
emailGravatar.clear();
}
if (!files)
return;
final File dir = new File(context.getCacheDir(), "favicons");
executorFavicon.submit(new Runnable() {
@Override
public void run() {