From eed6d78baae20d6e198f123c0075bc99b7c6012e 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 1adacf83a1..1c3abc84c8 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 8b5a9c94ea026a393ed21316dc3d8b0e10e54a27 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 7 Jul 2023 11:27:38 +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 1c3abc84c8..ecd5355e42 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 fecbd2c461e3cda17bb5f4085c510a1e43d0a63a Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Tue, 11 Jul 2023 06:43:58 +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 ecd5355e42..27acfc249f 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