From ad212c67c69f2987f5ab0576b6cf111da06fb28c Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Fri, 14 Oct 2011 15:46:34 -0700 Subject: [PATCH] Ensure that custom views are unique There are cases where Eclipse's code search engine returns multiple instances of the same fully qualified class name when searching for Views. In order not to show multiple versions of a custom view in the palette, this changeset changes the CustomViewFinder from using a list to using a set when accumulating class names. Change-Id: I4dd9aafe76404efcf8b7bc82a5392f6010ba16f2 --- .../internal/editors/layout/gle2/CustomViewFinder.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CustomViewFinder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CustomViewFinder.java index ab4b57f68..dda062724 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CustomViewFinder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CustomViewFinder.java @@ -54,7 +54,9 @@ import org.eclipse.swt.widgets.Display; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * The {@link CustomViewFinder} can look up the custom views and third party views @@ -190,8 +192,8 @@ public class CustomViewFinder { } private Pair,List> findViews(final boolean layoutsOnly) { - final List customViews = new ArrayList(); - final List thirdPartyViews = new ArrayList(); + final Set customViews = new HashSet(); + final Set thirdPartyViews = new HashSet(); ProjectState state = Sdk.getProjectState(mProject); final List libraries = state != null @@ -264,13 +266,17 @@ public class CustomViewFinder { AdtPlugin.log(e, null); } + + List custom = new ArrayList(customViews); + List thirdParty = new ArrayList(thirdPartyViews); + if (!layoutsOnly) { // Update our cached answers (unless we were filtered on only layouts) - mCustomViews = customViews; - mThirdPartyViews = thirdPartyViews; + mCustomViews = custom; + mThirdPartyViews = thirdParty; } - return Pair.of(customViews, thirdPartyViews); + return Pair.of(custom, thirdParty); } /** -- 2.11.0