From 7c39cc9cd15e911660876c4fe97d598e279838a2 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 8 Aug 2018 07:11:03 +0000 Subject: [PATCH] Fixed flickering This is why AndroidX was required --- .../main/java/eu/faircode/email/FragmentAccount.java | 2 +- .../main/java/eu/faircode/email/FragmentAccounts.java | 2 +- .../main/java/eu/faircode/email/FragmentCompose.java | 2 +- .../main/java/eu/faircode/email/FragmentFolder.java | 2 +- .../main/java/eu/faircode/email/FragmentFolders.java | 4 ++-- .../java/eu/faircode/email/FragmentIdentities.java | 2 +- .../main/java/eu/faircode/email/FragmentIdentity.java | 2 +- .../main/java/eu/faircode/email/FragmentMessage.java | 10 +++++----- .../main/java/eu/faircode/email/FragmentMessages.java | 4 ++-- app/src/main/java/eu/faircode/email/FragmentSetup.java | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 30d13a89..273abdcc 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -202,7 +202,7 @@ public class FragmentAccount extends FragmentEx { long id = (args == null ? -1 : args.getLong("id", -1)); // Observe - DB.getInstance(getContext()).account().liveAccount(id).observe(this, new Observer() { + DB.getInstance(getContext()).account().liveAccount(id).observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(@Nullable EntityAccount account) { etName.setText(account == null ? null : account.name); diff --git a/app/src/main/java/eu/faircode/email/FragmentAccounts.java b/app/src/main/java/eu/faircode/email/FragmentAccounts.java index aa7a202c..0024e0fd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccounts.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccounts.java @@ -90,7 +90,7 @@ public class FragmentAccounts extends FragmentEx { super.onActivityCreated(savedInstanceState); // Observe accounts - DB.getInstance(getContext()).account().liveAccounts().observe(this, new Observer>() { + DB.getInstance(getContext()).account().liveAccounts().observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List accounts) { adapter.set(accounts); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 9084e0f0..11c486ed 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -190,7 +190,7 @@ public class FragmentCompose extends FragmentEx { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - DB.getInstance(getContext()).identity().liveIdentities(true).observe(FragmentCompose.this, new Observer>() { + DB.getInstance(getContext()).identity().liveIdentities(true).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable final List identities) { Collections.sort(identities, new Comparator() { diff --git a/app/src/main/java/eu/faircode/email/FragmentFolder.java b/app/src/main/java/eu/faircode/email/FragmentFolder.java index b4304c58..a0d3fe16 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolder.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolder.java @@ -101,7 +101,7 @@ public class FragmentFolder extends FragmentEx { long id = (args == null ? -1 : args.getLong("id")); // Observe - DB.getInstance(getContext()).folder().liveFolder(id).observe(this, new Observer() { + DB.getInstance(getContext()).folder().liveFolder(id).observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(@Nullable EntityFolder folder) { if (folder != null) { diff --git a/app/src/main/java/eu/faircode/email/FragmentFolders.java b/app/src/main/java/eu/faircode/email/FragmentFolders.java index 2d53ff80..c590016b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolders.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolders.java @@ -90,7 +90,7 @@ public class FragmentFolders extends FragmentEx { DB db = DB.getInstance(getContext()); // Observe account - db.account().liveAccount(account).observe(this, new Observer() { + db.account().liveAccount(account).observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(@Nullable EntityAccount account) { setSubtitle(account.name); @@ -98,7 +98,7 @@ public class FragmentFolders extends FragmentEx { }); // Observe folders - db.folder().liveFolders(account).observe(this, new Observer>() { + db.folder().liveFolders(account).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List folders) { adapter.set(folders); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentities.java b/app/src/main/java/eu/faircode/email/FragmentIdentities.java index 72249e1b..fea61093 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentities.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentities.java @@ -90,7 +90,7 @@ public class FragmentIdentities extends FragmentEx { super.onActivityCreated(savedInstanceState); // Observe identities - DB.getInstance(getContext()).identity().liveIdentities().observe(this, new Observer>() { + DB.getInstance(getContext()).identity().liveIdentities().observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List identities) { adapter.set(identities); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 6a9963cc..6206da94 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -231,7 +231,7 @@ public class FragmentIdentity extends FragmentEx { long id = (args == null ? -1 : args.getLong("id", -1)); // Observer - DB.getInstance(getContext()).identity().liveIdentity(id).observe(this, new Observer() { + DB.getInstance(getContext()).identity().liveIdentity(id).observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(@Nullable EntityIdentity identity) { etName.setText(identity == null ? null : identity.name); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index cbb28c3d..bbd8e5ce 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -238,7 +238,7 @@ public class FragmentMessage extends FragmentEx { final DB db = DB.getInstance(getContext()); // Observe message - db.message().liveMessage(id).observe(this, new Observer() { + db.message().liveMessage(id).observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(@Nullable final TupleMessageEx message) { if (message == null || message.ui_hide) { @@ -267,8 +267,8 @@ public class FragmentMessage extends FragmentEx { tvFrom.setTextColor(colorUnseen); tvTime.setTextColor(colorUnseen); - db.attachment().liveAttachments(id).removeObservers(FragmentMessage.this); - db.attachment().liveAttachments(id).observe(FragmentMessage.this, + db.attachment().liveAttachments(id).removeObservers(getViewLifecycleOwner()); + db.attachment().liveAttachments(id).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List attachments) { @@ -291,8 +291,8 @@ public class FragmentMessage extends FragmentEx { bottom_navigation.setTag(message.folderType); - db.folder().liveFolders(message.account).removeObservers(FragmentMessage.this); - db.folder().liveFolders(message.account).observe(FragmentMessage.this, new Observer>() { + db.folder().liveFolders(message.account).removeObservers(getViewLifecycleOwner()); + db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable final List folders) { boolean hasTrash = false; diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index f3ea162c..f3928884 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -118,7 +118,7 @@ public class FragmentMessages extends FragmentEx { setSubtitle(R.string.title_folder_unified); messages = new LivePagedListBuilder<>(db.message().pagedUnifiedInbox(debug), PAGE_SIZE).build(); } else { - db.folder().liveFolderEx(folder).observe(this, new Observer() { + db.folder().liveFolderEx(folder).observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(@Nullable TupleFolderEx folder) { setSubtitle(folder == null ? null : Helper.localizeFolderName(getContext(), folder.name)); @@ -132,7 +132,7 @@ public class FragmentMessages extends FragmentEx { } Log.i(Helper.TAG, "Observing messages"); - messages.observe(this, new Observer>() { + messages.observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable PagedList messages) { Log.i(Helper.TAG, "Submit messages=" + messages.size()); diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index 17f3fa77..54225d4c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -178,14 +178,14 @@ public class FragmentSetup extends FragmentEx { DB db = DB.getInstance(getContext()); - db.account().liveAccounts(true).observe(this, new Observer>() { + db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List accounts) { tvAccountDone.setVisibility(accounts.size() > 0 ? View.VISIBLE : View.INVISIBLE); } }); - db.identity().liveIdentities(true).observe(this, new Observer>() { + db.identity().liveIdentities(true).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List identities) { tvIdentityDone.setVisibility(identities.size() > 0 ? View.VISIBLE : View.INVISIBLE);