From 4b4bd0e1dca4a9a3fff259a919423fdbfebb4d66 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 6d6e81dbbc..ba2a6457fa 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -558,12 +558,29 @@ class AccountTypeManagerImpl extends AccountTypeManager result.add( typeProvider.getTypeForAccount(account).wrapAccount(mContext, account)); } + + filterDuplicateAccounts(result); + AccountInfo.sortAccounts(null, result); return result; } }); } + 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 935dad0dbc53f0c5cc20cd798ca11ca2c49fdd79 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 7 Jul 2023 15:54:09 +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 ba2a6457fa..dba3d1496e 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -570,7 +570,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 716d384d172d695c6beeb1431da3ac21a044bdd3 Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Tue, 11 Jul 2023 06:45:35 +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 dba3d1496e..e31dcb4f59 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -568,10 +568,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