Bug 956360 - Use Arrays.asList when possible. r=jchen

This commit is contained in:
Marcos Cezar 2014-03-04 14:32:47 -03:00
parent fecf79feba
commit fa09f6da3c
7 changed files with 26 additions and 26 deletions

View File

@ -16,6 +16,7 @@ import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
@ -678,10 +679,7 @@ public abstract class GeckoApp
Intent intent = GeckoAppShell.getOpenURIIntent(sAppContext, message.optString("url"),
message.optString("mime"), message.optString("action"), message.optString("title"));
String[] handlers = GeckoAppShell.getHandlersForIntent(intent);
ArrayList<String> appList = new ArrayList<String>(handlers.length);
for (int i = 0; i < handlers.length; i++) {
appList.add(handlers[i]);
}
List<String> appList = Arrays.asList(handlers);
JSONObject handlersJSON = new JSONObject();
handlersJSON.put("apps", new JSONArray(appList));
EventDispatcher.sendResponse(message, handlersJSON);

View File

@ -10,6 +10,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.mozilla.gecko.background.common.log.Logger;
@ -118,9 +119,9 @@ public class BrowserIDRemoteVerifierClient implements BrowserIDVerifierClient {
r.delegate = new RemoteVerifierResourceDelegate(r, delegate);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("audience", audience));
nvps.add(new BasicNameValuePair("assertion", assertion));
List<NameValuePair> nvps = Arrays.asList(new NameValuePair[] {
new BasicNameValuePair("audience", audience),
new BasicNameValuePair("assertion", assertion) });
try {
r.post(new UrlEncodedFormEntity(nvps, "UTF-8"));

View File

@ -30,8 +30,10 @@ import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class Favicons {
@ -396,9 +398,9 @@ public class Favicons {
// Load and cache the built-in favicon in each of its sizes.
// TODO: don't open the zip twice!
ArrayList<Bitmap> toInsert = new ArrayList<Bitmap>(2);
toInsert.add(loadBrandingBitmap(context, "favicon64.png"));
toInsert.add(loadBrandingBitmap(context, "favicon32.png"));
List<Bitmap> toInsert = Arrays.asList(loadBrandingBitmap(context, "favicon64.png"),
loadBrandingBitmap(context, "favicon32.png"));
putFaviconsInMemCache(BUILT_IN_FAVICON_URL, toInsert.iterator(), true);
}

View File

@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@ -789,9 +790,9 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener
new MeasurementFields() {
@Override
public Iterable<FieldSpec> getFields() {
ArrayList<FieldSpec> out = new ArrayList<FieldSpec>(2);
out.add(new FieldSpec("normal", Field.TYPE_JSON_DISCRETE));
out.add(new FieldSpec("abnormal", Field.TYPE_JSON_DISCRETE));
List<FieldSpec> out = Arrays.asList(
new FieldSpec("normal", Field.TYPE_JSON_DISCRETE),
new FieldSpec("abnormal", Field.TYPE_JSON_DISCRETE));
return out;
}
});

View File

@ -13,6 +13,7 @@ import android.util.Log;
import org.mozilla.gecko.mozglue.RobocopTarget;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map.Entry;
/*
@ -200,9 +201,7 @@ public class SQLiteBridge {
if (!TextUtils.isEmpty(whereClause)) {
sb.append(" WHERE ");
sb.append(whereClause);
for (int i = 0; i < whereArgs.length; i++) {
valueNames.add(whereArgs[i]);
}
valueNames.addAll(Arrays.asList(whereArgs));
}
String[] binds = new String[valueNames.size()];

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.sync.repositories.android;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
@ -313,9 +314,9 @@ public class FormHistoryRepositorySession extends
}
};
ArrayList<Callable<Cursor>> callableCursors = new ArrayList<Callable<Cursor>>();
callableCursors.add(regularCallable);
callableCursors.add(deletedCallable);
@SuppressWarnings("unchecked")
List<Callable<Cursor>> callableCursors = Arrays.asList(regularCallable, deletedCallable);
fetchHelper(delegate, sharedEnd, callableCursors);
}
@ -348,9 +349,9 @@ public class FormHistoryRepositorySession extends
}
};
ArrayList<Callable<Cursor>> callableCursors = new ArrayList<Callable<Cursor>>();
callableCursors.add(regularCallable);
callableCursors.add(deletedCallable);
@SuppressWarnings("unchecked")
List<Callable<Cursor>> callableCursors = Arrays.asList(regularCallable, deletedCallable);
fetchHelper(delegate, sharedEnd, callableCursors);
}

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.sync.setup.activities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.content.Intent;
@ -50,10 +51,7 @@ public class SendTabData {
// For URL, take first URL from EXTRA_TEXT, EXTRA_SUBJECT, and EXTRA_TITLE
// (in that order).
List<String> strings = new ArrayList<String>();
strings.add(text);
strings.add(subject);
strings.add(title);
List<String> strings = Arrays.asList(text, subject, title);
String theUri = new WebURLFinder(strings).bestWebURL();
return new SendTabData(theTitle, theUri);