Replace HashMap with ArrayMap
This commit is contained in:
parent
52ee1f1258
commit
364dcef7a3
|
@ -1,6 +1,21 @@
|
|||
package de.test.antennapod.util.service.download;
|
||||
|
||||
import java.io.*;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
|
@ -14,7 +29,6 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -281,7 +295,7 @@ public abstract class NanoHTTPD {
|
|||
* @return HTTP response, see class Response for details
|
||||
*/
|
||||
public Response serve(IHTTPSession session) {
|
||||
Map<String, String> files = new HashMap<String, String>();
|
||||
Map<String, String> files = new ArrayMap<>();
|
||||
Method method = session.getMethod();
|
||||
if (Method.PUT.equals(method) || Method.POST.equals(method)) {
|
||||
try {
|
||||
|
@ -334,7 +348,7 @@ public abstract class NanoHTTPD {
|
|||
* @return a map of <code>String</code> (parameter name) to <code>List<String></code> (a list of the values supplied).
|
||||
*/
|
||||
protected Map<String, List<String>> decodeParameters(String queryString) {
|
||||
Map<String, List<String>> parms = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> parms = new ArrayMap<String, List<String>>();
|
||||
if (queryString != null) {
|
||||
StringTokenizer st = new StringTokenizer(queryString, "&");
|
||||
while (st.hasMoreTokens()) {
|
||||
|
@ -549,7 +563,7 @@ public abstract class NanoHTTPD {
|
|||
/**
|
||||
* Headers for the HTTP response. Use addHeader() to add lines.
|
||||
*/
|
||||
private Map<String, String> header = new HashMap<String, String>();
|
||||
private Map<String, String> header = new ArrayMap<String, String>();
|
||||
/**
|
||||
* The request method that spawned this response.
|
||||
*/
|
||||
|
@ -851,7 +865,7 @@ public abstract class NanoHTTPD {
|
|||
this.inputStream = new PushbackInputStream(inputStream, BUFSIZE);
|
||||
this.outputStream = outputStream;
|
||||
String remoteIp = inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() ? "127.0.0.1" : inetAddress.getHostAddress().toString();
|
||||
headers = new HashMap<String, String>();
|
||||
headers = new ArrayMap<String, String>();
|
||||
|
||||
headers.put("remote-addr", remoteIp);
|
||||
headers.put("http-client-ip", remoteIp);
|
||||
|
@ -895,16 +909,16 @@ public abstract class NanoHTTPD {
|
|||
inputStream.unread(buf, splitbyte, rlen - splitbyte);
|
||||
}
|
||||
|
||||
parms = new HashMap<String, String>();
|
||||
parms = new ArrayMap<String, String>();
|
||||
if(null == headers) {
|
||||
headers = new HashMap<String, String>();
|
||||
headers = new ArrayMap<String, String>();
|
||||
}
|
||||
|
||||
// Create a BufferedReader for parsing the header.
|
||||
BufferedReader hin = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buf, 0, rlen)));
|
||||
|
||||
// Decode the header into parms and header java properties
|
||||
Map<String, String> pre = new HashMap<String, String>();
|
||||
Map<String, String> pre = new ArrayMap<String, String>();
|
||||
decodeHeader(hin, pre, parms, headers);
|
||||
|
||||
method = Method.lookup(pre.get("method"));
|
||||
|
@ -1102,7 +1116,7 @@ public abstract class NanoHTTPD {
|
|||
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but next chunk does not start with boundary. Usage: GET /example/file.html");
|
||||
}
|
||||
boundarycount++;
|
||||
Map<String, String> item = new HashMap<String, String>();
|
||||
Map<String, String> item = new ArrayMap<String, String>();
|
||||
mpline = in.readLine();
|
||||
while (mpline != null && mpline.trim().length() > 0) {
|
||||
int p = mpline.indexOf(':');
|
||||
|
@ -1117,7 +1131,7 @@ public abstract class NanoHTTPD {
|
|||
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but no content-disposition info found. Usage: GET /example/file.html");
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(contentDisposition, ";");
|
||||
Map<String, String> disposition = new HashMap<String, String>();
|
||||
Map<String, String> disposition = new ArrayMap<String, String>();
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken().trim();
|
||||
int p = token.indexOf('=');
|
||||
|
@ -1352,7 +1366,7 @@ public abstract class NanoHTTPD {
|
|||
* @author LordFokas
|
||||
*/
|
||||
public class CookieHandler implements Iterable<String> {
|
||||
private HashMap<String, String> cookies = new HashMap<String, String>();
|
||||
private ArrayMap<String, String> cookies = new ArrayMap<String, String>();
|
||||
private ArrayList<Cookie> queue = new ArrayList<Cookie>();
|
||||
|
||||
public CookieHandler(Map<String, String> httpHeaders) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.graphics.Color;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -22,7 +23,6 @@ import com.joanzapata.iconify.fonts.FontAwesomeIcons;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class EpisodesApplyActionFragment extends Fragment {
|
|||
|
||||
public EpisodesApplyActionFragment() {
|
||||
this.episodes = new ArrayList<>();
|
||||
this.idMap = new HashMap<>();
|
||||
this.idMap = new ArrayMap<>();
|
||||
}
|
||||
|
||||
public void setEpisodes(List<FeedItem> episodes) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package de.danoeh.antennapod.core.gpoddernet.model;
|
||||
|
||||
import android.support.v4.util.ArrayMap;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GpodnetEpisodeActionPostResponse {
|
||||
|
@ -36,8 +37,8 @@ public class GpodnetEpisodeActionPostResponse {
|
|||
public static GpodnetEpisodeActionPostResponse fromJSONObject(String objectString) throws JSONException {
|
||||
final JSONObject object = new JSONObject(objectString);
|
||||
final long timestamp = object.getLong("timestamp");
|
||||
Map<String, String> updatedUrls = new HashMap<String, String>();
|
||||
JSONArray urls = object.getJSONArray("update_urls");
|
||||
Map<String, String> updatedUrls = new ArrayMap<String, String>(urls.length());
|
||||
for (int i = 0; i < urls.length(); i++) {
|
||||
JSONArray urlPair = urls.getJSONArray(i);
|
||||
updatedUrls.put(urlPair.getString(0), urlPair.getString(1));
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package de.danoeh.antennapod.core.gpoddernet.model;
|
||||
|
||||
import android.support.v4.util.ArrayMap;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +38,7 @@ public class GpodnetUploadChangesResponse {
|
|||
public static GpodnetUploadChangesResponse fromJSONObject(String objectString) throws JSONException {
|
||||
final JSONObject object = new JSONObject(objectString);
|
||||
final long timestamp = object.getLong("timestamp");
|
||||
Map<String, String> updatedUrls = new HashMap<String, String>();
|
||||
Map<String, String> updatedUrls = new ArrayMap<>();
|
||||
JSONArray urls = object.getJSONArray("update_urls");
|
||||
for (int i = 0; i < urls.length(); i++) {
|
||||
JSONArray urlPair = urls.getJSONArray(i);
|
||||
|
|
|
@ -8,12 +8,12 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -226,7 +226,7 @@ public class GpodnetSyncService extends Service {
|
|||
if(remoteActions.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Map<Pair<String, String>, GpodnetEpisodeAction> localMostRecentPlayAction = new HashMap<Pair<String, String>, GpodnetEpisodeAction>();
|
||||
Map<Pair<String, String>, GpodnetEpisodeAction> localMostRecentPlayAction = new ArrayMap<>();
|
||||
for(GpodnetEpisodeAction action : localActions) {
|
||||
Pair key = new Pair(action.getPodcast(), action.getEpisode());
|
||||
GpodnetEpisodeAction mostRecent = localMostRecentPlayAction.get(key);
|
||||
|
@ -238,7 +238,7 @@ public class GpodnetSyncService extends Service {
|
|||
}
|
||||
|
||||
// make sure more recent local actions are not overwritten by older remote actions
|
||||
Map<Pair<String, String>, GpodnetEpisodeAction> mostRecentPlayAction = new HashMap<Pair<String, String>, GpodnetEpisodeAction>();
|
||||
Map<Pair<String, String>, GpodnetEpisodeAction> mostRecentPlayAction = new ArrayMap<>();
|
||||
for (GpodnetEpisodeAction action : remoteActions) {
|
||||
switch (action.getAction()) {
|
||||
case NEW:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -229,7 +229,7 @@ public final class DBReader {
|
|||
for(int i=0, len=itemIds.length; i < len; i++) {
|
||||
ids[i] = String.valueOf(itemIds[i]);
|
||||
}
|
||||
Map<Long,FeedMedia> result = new HashMap<>(itemIds.length);
|
||||
Map<Long,FeedMedia> result = new ArrayMap<>(itemIds.length);
|
||||
Cursor cursor = adapter.getFeedMediaCursor(ids);
|
||||
try {
|
||||
if (cursor.moveToFirst()) {
|
||||
|
@ -871,7 +871,7 @@ public final class DBReader {
|
|||
ids[i] = String.valueOf(imageIds[i]);
|
||||
}
|
||||
Cursor cursor = adapter.getImageCursor(ids);
|
||||
Map<Long, FeedImage> result = new HashMap<>(cursor.getCount());
|
||||
Map<Long, FeedImage> result = new ArrayMap<>(cursor.getCount());
|
||||
try {
|
||||
if ((cursor.getCount() == 0) || !cursor.moveToFirst()) {
|
||||
return Collections.emptyMap();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package de.danoeh.antennapod.core.syndication.handler;
|
||||
|
||||
import android.support.v4.util.ArrayMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class HandlerState {
|
|||
/**
|
||||
* Namespaces that have been defined so far.
|
||||
*/
|
||||
protected HashMap<String, Namespace> namespaces;
|
||||
protected Map<String, Namespace> namespaces;
|
||||
protected Stack<Namespace> defaultNamespaces;
|
||||
/**
|
||||
* Buffer for saving characters.
|
||||
|
@ -42,16 +42,16 @@ public class HandlerState {
|
|||
/**
|
||||
* Temporarily saved objects.
|
||||
*/
|
||||
protected HashMap<String, Object> tempObjects;
|
||||
protected Map<String, Object> tempObjects;
|
||||
|
||||
public HandlerState(Feed feed) {
|
||||
this.feed = feed;
|
||||
alternateUrls = new LinkedHashMap<String, String>();
|
||||
alternateUrls = new ArrayMap<>();
|
||||
items = new ArrayList<FeedItem>();
|
||||
tagstack = new Stack<SyndElement>();
|
||||
namespaces = new HashMap<String, Namespace>();
|
||||
namespaces = new ArrayMap<>();
|
||||
defaultNamespaces = new Stack<Namespace>();
|
||||
tempObjects = new HashMap<String, Object>();
|
||||
tempObjects = new ArrayMap<>();
|
||||
}
|
||||
|
||||
public Feed getFeed() {
|
||||
|
@ -105,7 +105,7 @@ public class HandlerState {
|
|||
alternateUrls.put(url, title);
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getTempObjects() {
|
||||
public Map<String, Object> getTempObjects() {
|
||||
return tempObjects;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import android.support.v4.util.ArrayMap;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class LangUtils {
|
||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private static HashMap<String, String> languages;
|
||||
private static ArrayMap<String, String> languages;
|
||||
static {
|
||||
languages = new HashMap<String, String>();
|
||||
languages = new ArrayMap<>();
|
||||
languages.put("af", "Afrikaans");
|
||||
languages.put("sq", "Albanian");
|
||||
languages.put("sq", "Albanian");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.danoeh.antennapod.core.util.syndication;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
|
@ -10,7 +11,6 @@ import org.jsoup.select.Elements;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ public class FeedDiscoverer {
|
|||
}
|
||||
|
||||
private Map<String, String> findLinks(Document document, String baseUrl) {
|
||||
Map<String, String> res = new LinkedHashMap<String, String>();
|
||||
Map<String, String> res = new ArrayMap<>();
|
||||
Elements links = document.head().getElementsByTag("link");
|
||||
for (Element link : links) {
|
||||
String rel = link.attr("rel");
|
||||
|
|
Loading…
Reference in New Issue