OSDN Git Service

Merge: Cleanup ArrayList usage in SDK Manager.
authorRaphael Moll <ralf@android.com>
Fri, 7 Jan 2011 21:48:13 +0000 (13:48 -0800)
committerRaphael Moll <ralf@android.com>
Sat, 8 Jan 2011 06:53:12 +0000 (22:53 -0800)
Change-Id: Id03b96aa420a0aa83771c60880887577fd8c020e

sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdateChooserDialog.java
sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterLogic.java
sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/UpdaterLogicTest.java

index 277a9c2..81ca91e 100755 (executable)
@@ -55,6 +55,7 @@ import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Collection;\r
 \r
 \r
 /**\r
@@ -84,15 +85,15 @@ final class UpdateChooserDialog extends GridDialog {
 \r
     /**\r
      * List of all archives to be installed with dependency information.\r
-     *\r
+     * <p/>\r
      * Note: in a lot of cases, we need to find the archive info for a given archive. This\r
      * is currently done using a simple linear search, which is fine since we only have a very\r
      * limited number of archives to deal with (e.g. < 10 now). We might want to revisit\r
      * this later if it becomes an issue. Right now just do the simple thing.\r
-     *\r
+     *<p/>\r
      * Typically we could add a map Archive=>ArchiveInfo later.\r
      */\r
-    private final ArrayList<ArchiveInfo> mArchives;\r
+    private final Collection<ArchiveInfo> mArchives;\r
 \r
 \r
 \r
@@ -104,7 +105,7 @@ final class UpdateChooserDialog extends GridDialog {
      */\r
     public UpdateChooserDialog(Shell parentShell,\r
             UpdaterData updaterData,\r
-            ArrayList<ArchiveInfo> archives) {\r
+            Collection<ArchiveInfo> archives) {\r
         super(parentShell, 3, false/*makeColumnsEqual*/);\r
         mUpdaterData = updaterData;\r
         mArchives = archives;\r
index 33d756a..e8d3103 100755 (executable)
@@ -57,6 +57,7 @@ import java.util.Collections;
 import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.Iterator;\r
+import java.util.List;\r
 \r
 /**\r
  * Data shared between {@link UpdaterWindowImpl} and its pages.\r
@@ -399,7 +400,7 @@ class UpdaterData implements IUpdaterData {
      *\r
      * @param result The archives to install. Incompatible ones will be skipped.\r
      */\r
-    public void installArchives(final ArrayList<ArchiveInfo> result) {\r
+    public void installArchives(final Collection<ArchiveInfo> result) {\r
         if (mTaskFactory == null) {\r
             throw new IllegalArgumentException("Task Factory is null");\r
         }\r
@@ -633,7 +634,7 @@ class UpdaterData implements IUpdaterData {
         // resolve missing dependencies.\r
 \r
         UpdaterLogic ul = new UpdaterLogic(this);\r
-        ArrayList<ArchiveInfo> archives = ul.computeUpdates(\r
+        List<ArchiveInfo> archives = ul.computeUpdates(\r
                 selectedArchives,\r
                 getSources(),\r
                 getLocalSdkParser().getPackages(),\r
@@ -681,7 +682,7 @@ class UpdaterData implements IUpdaterData {
         refreshSources(true);\r
 \r
         UpdaterLogic ul = new UpdaterLogic(this);\r
-        ArrayList<ArchiveInfo> archives = ul.computeUpdates(\r
+        List<ArchiveInfo> archives = ul.computeUpdates(\r
                 null /*selectedArchives*/,\r
                 getSources(),\r
                 getLocalSdkParser().getPackages(),\r
index 505a613..824a89f 100755 (executable)
@@ -42,6 +42,7 @@ import com.android.sdklib.internal.repository.Package.UpdateInfo;
 import java.util.ArrayList;\r
 import java.util.Collection;\r
 import java.util.HashMap;\r
+import java.util.List;\r
 \r
 /**\r
  * The logic to compute which packages to install, based on the choices\r
@@ -65,14 +66,14 @@ class UpdaterLogic {
      * When the user doesn't provide a selection, looks at local packages to find\r
      * those that can be updated and compute dependencies too.\r
      */\r
-    public ArrayList<ArchiveInfo> computeUpdates(\r
+    public List<ArchiveInfo> computeUpdates(\r
             Collection<Archive> selectedArchives,\r
             SdkSources sources,\r
             Package[] localPkgs,\r
             boolean includeObsoletes) {\r
 \r
-        ArrayList<ArchiveInfo> archives = new ArrayList<ArchiveInfo>();\r
-        ArrayList<Package> remotePkgs = new ArrayList<Package>();\r
+        List<ArchiveInfo> archives = new ArrayList<ArchiveInfo>();\r
+        List<Package>   remotePkgs = new ArrayList<Package>();\r
         SdkSource[] remoteSources = sources.getAllSources();\r
 \r
         // Create ArchiveInfos out of local (installed) packages.\r
@@ -121,7 +122,7 @@ class UpdaterLogic {
      * and adds them to the list of archives to install.\r
      */\r
     public void addNewPlatforms(\r
-            ArrayList<ArchiveInfo> archives,\r
+            Collection<ArchiveInfo> archives,\r
             SdkSources sources,\r
             Package[] localPkgs,\r
             boolean includeObsoletes) {\r
@@ -280,7 +281,7 @@ class UpdaterLogic {
      */\r
     private Collection<Archive> findUpdates(\r
             ArchiveInfo[] localArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             boolean includeObsoletes) {\r
         ArrayList<Archive> updates = new ArrayList<Archive>();\r
@@ -320,9 +321,9 @@ class UpdaterLogic {
      * an appropriate package.\r
      */\r
     private void fixMissingLocalDependencies(\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives) {\r
 \r
@@ -364,9 +365,9 @@ class UpdaterLogic {
     }\r
 \r
     private ArchiveInfo insertArchive(Archive archive,\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives,\r
             boolean automated) {\r
@@ -430,9 +431,9 @@ class UpdaterLogic {
      * at least size 1 and contain no null elements.\r
      */\r
     private ArchiveInfo[] findDependency(Package pkg,\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives) {\r
 \r
@@ -534,9 +535,9 @@ class UpdaterLogic {
      */\r
     protected ArchiveInfo findToolsDependency(\r
             IMinToolsDependency pkg,\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives) {\r
         // This is the requirement to match.\r
@@ -632,9 +633,9 @@ class UpdaterLogic {
      */\r
     protected ArchiveInfo findPlatformToolsDependency(\r
             IMinPlatformToolsDependency pkg,\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives) {\r
         // This is the requirement to match.\r
@@ -773,9 +774,9 @@ class UpdaterLogic {
      */\r
     protected ArchiveInfo findPlatformDependency(\r
             IPlatformDependency pkg,\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives) {\r
         // This is the requirement to match.\r
@@ -872,9 +873,9 @@ class UpdaterLogic {
      */\r
     protected ArchiveInfo findMinApiLevelDependency(\r
             IMinApiLevelDependency pkg,\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives) {\r
 \r
@@ -987,9 +988,9 @@ class UpdaterLogic {
      */\r
     protected ArchiveInfo findExactApiLevelDependency(\r
             IExactApiLevelDependency pkg,\r
-            ArrayList<ArchiveInfo> outArchives,\r
+            Collection<ArchiveInfo> outArchives,\r
             Collection<Archive> selectedArchives,\r
-            ArrayList<Package> remotePkgs,\r
+            Collection<Package> remotePkgs,\r
             SdkSource[] remoteSources,\r
             ArchiveInfo[] localArchives) {\r
 \r
@@ -1095,7 +1096,7 @@ class UpdaterLogic {
      * @param remoteSources A list of available remote sources to fetch from.\r
      */\r
     protected void fetchRemotePackages(\r
-            final ArrayList<Package> remotePkgs,\r
+            final Collection<Package> remotePkgs,\r
             final SdkSource[] remoteSources) {\r
         if (remotePkgs.size() > 0) {\r
             return;\r
index dc65e14..fb956f2 100755 (executable)
@@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Shell;
 \r
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
+import java.util.Collection;\r
 \r
 import junit.framework.TestCase;\r
 \r
@@ -80,7 +81,7 @@ public class UpdaterLogicTest extends TestCase {
         }\r
 \r
         @Override\r
-        protected void fetchRemotePackages(ArrayList<Package> remotePkgs,\r
+        protected void fetchRemotePackages(Collection<Package> remotePkgs,\r
                 SdkSource[] remoteSources) {\r
             // Ignore remoteSources and instead uses the remotePackages list given to the\r
             // constructor.\r