From e20a8dcff5221790c97b14f8f868a3f7f2ccde1a 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 4184361133..b37a92c241 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -559,12 +559,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 992570c672d6fd012c78e7ac564a075146d15f67 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 7 Jul 2023 15:52:58 +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 b37a92c241..e702386407 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -571,7 +571,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 83066a12d65fc17a8a67eb87bbea39afc3f0fa6e Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Tue, 11 Jul 2023 06:44:42 +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 e702386407..63f4aa7c8b 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -569,10 +569,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