From 91ea751d5996ff8d202a2fa74e80358265f565f9 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 21 Oct 2018 14:07:45 +0000 Subject: [PATCH] View model on clear --- app/src/main/java/eu/faircode/email/ViewModelBrowse.java | 9 +++++++++ .../main/java/eu/faircode/email/ViewModelMessages.java | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/ViewModelBrowse.java b/app/src/main/java/eu/faircode/email/ViewModelBrowse.java index d19eef07..4b070eb5 100644 --- a/app/src/main/java/eu/faircode/email/ViewModelBrowse.java +++ b/app/src/main/java/eu/faircode/email/ViewModelBrowse.java @@ -50,6 +50,14 @@ public class ViewModelBrowse extends ViewModel { this.loaded = 0; } + @Override + protected void onCleared() { + context = null; + istore = null; + ifolder = null; + imessages = null; + } + Context getContext() { return context; } @@ -158,6 +166,7 @@ public class ViewModelBrowse extends ViewModel { } catch (Throwable ex) { Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex)); } finally { + context = null; istore = null; ifolder = null; imessages = null; diff --git a/app/src/main/java/eu/faircode/email/ViewModelMessages.java b/app/src/main/java/eu/faircode/email/ViewModelMessages.java index 148b7190..b9d55030 100644 --- a/app/src/main/java/eu/faircode/email/ViewModelMessages.java +++ b/app/src/main/java/eu/faircode/email/ViewModelMessages.java @@ -10,6 +10,11 @@ public class ViewModelMessages extends ViewModel { this.messages = messages; } + @Override + protected void onCleared() { + messages = null; + } + Target[] getPrevNext(String thread) { if (messages == null) return new Target[]{null, null};