From 1a1172aad8b668e93f4dfc312ff44928af5086b8 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Thu, 1 Jun 2023 15:47:57 +0530 Subject: [PATCH 1/3] create and use method filterDuplicateAccounts --- .../contacts/model/AccountTypeManager.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/com/android/contacts/model/AccountTypeManager.java b/src/com/android/contacts/model/AccountTypeManager.java index 253097bac8..908f806d8c 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -597,12 +597,29 @@ class AccountTypeManagerImpl extends AccountTypeManager result.add( typeProvider.getTypeForAccount(account).wrapAccount(mContext, account)); } + + filterDuplicateAccounts(result); + AccountInfo.sortAccounts(null, result); return result; } }, MoreExecutors.directExecutor()); } + private void filterDuplicateAccounts(List accountList) { + List uniqueList = new ArrayList<>(); + + for(AccountInfo resultInfo: accountList) { + boolean isPresent = uniqueList.stream().anyMatch(resultInfo::sameAccount); + if (!isPresent) { + uniqueList.add(resultInfo); + } + } + + accountList.clear(); + accountList.addAll(uniqueList); + } + @Override public ListenableFuture> filterAccountsAsync( final Predicate filter) { -- GitLab From 7fadeac8999750a2f305e12b48b14b67592e62c6 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 7 Jul 2023 15:50:32 +0000 Subject: [PATCH 2/3] Apply 1 suggestion(s) to 1 file(s) --- src/com/android/contacts/model/AccountTypeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/contacts/model/AccountTypeManager.java b/src/com/android/contacts/model/AccountTypeManager.java index 908f806d8c..e615a6c17c 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -609,7 +609,7 @@ class AccountTypeManagerImpl extends AccountTypeManager private void filterDuplicateAccounts(List accountList) { List uniqueList = new ArrayList<>(); - for(AccountInfo resultInfo: accountList) { + for (AccountInfo resultInfo: accountList) { boolean isPresent = uniqueList.stream().anyMatch(resultInfo::sameAccount); if (!isPresent) { uniqueList.add(resultInfo); -- GitLab From 5622454a20e33c29882b2e0b8fe195794fe2d770 Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Tue, 11 Jul 2023 06:43:14 +0000 Subject: [PATCH 3/3] Apply 2 suggestion(s) to 1 file(s) --- src/com/android/contacts/model/AccountTypeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/contacts/model/AccountTypeManager.java b/src/com/android/contacts/model/AccountTypeManager.java index e615a6c17c..7cb8657202 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -607,10 +607,10 @@ class AccountTypeManagerImpl extends AccountTypeManager } private void filterDuplicateAccounts(List accountList) { - List uniqueList = new ArrayList<>(); + final List uniqueList = new ArrayList<>(); for (AccountInfo resultInfo: accountList) { - boolean isPresent = uniqueList.stream().anyMatch(resultInfo::sameAccount); + final boolean isPresent = uniqueList.stream().anyMatch(resultInfo::sameAccount); if (!isPresent) { uniqueList.add(resultInfo); } -- GitLab