diff --git a/davinci/src/main/java/cn/hadcn/davinci/base/ImageLoader.java b/davinci/src/main/java/cn/hadcn/davinci/base/ImageLoader.java index 3df032a..c0c7779 100644 --- a/davinci/src/main/java/cn/hadcn/davinci/base/ImageLoader.java +++ b/davinci/src/main/java/cn/hadcn/davinci/base/ImageLoader.java @@ -54,11 +54,11 @@ public class ImageLoader { * that we can coalesce multiple requests to the same URL into a single network request. */ private final HashMap mInFlightRequests = - new HashMap(); + new HashMap<>(); /** HashMap of the currently pending responses (waiting to be delivered). */ private final HashMap mBatchedResponses = - new HashMap(); + new HashMap<>(); /** Handler to the main thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()); @@ -367,7 +367,7 @@ private class BatchedImageRequest { private VolleyError mError; /** List of all of the active ImageContainers that are interested in the request */ - private final LinkedList mContainers = new LinkedList(); + private final LinkedList mContainers = new LinkedList<>(); /** * Constructs a new BatchedImageRequest object diff --git a/davinci/src/main/java/cn/hadcn/davinci/http/impl/PersistentCookieStore.java b/davinci/src/main/java/cn/hadcn/davinci/http/impl/PersistentCookieStore.java index 3289565..e0dbd54 100644 --- a/davinci/src/main/java/cn/hadcn/davinci/http/impl/PersistentCookieStore.java +++ b/davinci/src/main/java/cn/hadcn/davinci/http/impl/PersistentCookieStore.java @@ -52,7 +52,7 @@ public PersistentCookieStore(Context context) { } private void loadAllFromPersistence() { - allCookies = new HashMap>(); + allCookies = new HashMap<>(); Map allPairs = sharedPreferences.getAll(); for (Map.Entry entry : allPairs.entrySet()) { @@ -66,7 +66,7 @@ private void loadAllFromPersistence() { Set targetCookies = allCookies.get(uri); if (targetCookies == null) { - targetCookies = new HashSet(); + targetCookies = new HashSet<>(); allCookies.put(uri, targetCookies); } // Repeated cookies cannot exist in persistence @@ -84,7 +84,7 @@ public synchronized void add(URI uri, HttpCookie cookie) { Set targetCookies = allCookies.get(uri); if (targetCookies == null) { - targetCookies = new HashSet(); + targetCookies = new HashSet<>(); allCookies.put(uri, targetCookies); } targetCookies.remove(cookie); @@ -136,7 +136,7 @@ public synchronized List get(URI uri) { @Override public synchronized List getCookies() { - List allValidCookies = new ArrayList(); + List allValidCookies = new ArrayList<>(); for (URI storedUri : allCookies.keySet()) { allValidCookies.addAll(getValidCookies(storedUri)); } @@ -145,7 +145,7 @@ public synchronized List getCookies() { } private List getValidCookies(URI uri) { - List targetCookies = new ArrayList(); + List targetCookies = new ArrayList<>(); // If the stored URI does not have a path then it must match any URI in // the same domain for (URI storedUri : allCookies.keySet()) { @@ -160,7 +160,7 @@ private List getValidCookies(URI uri) { // Check it there are expired cookies and remove them if (!targetCookies.isEmpty()) { - List cookiesToRemoveFromPersistence = new ArrayList(); + List cookiesToRemoveFromPersistence = new ArrayList<>(); for (Iterator it = targetCookies.iterator(); it .hasNext(); ) { HttpCookie currentCookie = it.next(); @@ -230,7 +230,7 @@ private void removeFromPersistence(URI uri, List cookiesToRemove) { @Override public synchronized List getURIs() { - return new ArrayList(allCookies.keySet()); + return new ArrayList<>(allCookies.keySet()); } @Override diff --git a/davinci/src/main/java/cn/hadcn/davinci/image/DiskLruCache.java b/davinci/src/main/java/cn/hadcn/davinci/image/DiskLruCache.java index 09bd706..82c1526 100644 --- a/davinci/src/main/java/cn/hadcn/davinci/image/DiskLruCache.java +++ b/davinci/src/main/java/cn/hadcn/davinci/image/DiskLruCache.java @@ -149,7 +149,7 @@ public final class DiskLruCache implements Closeable { private long size = 0; private Writer journalWriter; private final LinkedHashMap lruEntries = - new LinkedHashMap(0, 0.75f, true); + new LinkedHashMap<>(0, 0.75f, true); private int redundantOpCount; /** @@ -634,7 +634,7 @@ public synchronized void close() throws IOException { if (journalWriter == null) { return; // Already closed. } - for (Entry entry : new ArrayList(lruEntries.values())) { + for (Entry entry : new ArrayList<>(lruEntries.values())) { if (entry.currentEditor != null) { entry.currentEditor.abort(); } diff --git a/davinci/src/main/java/cn/hadcn/davinci/image/LruCache.java b/davinci/src/main/java/cn/hadcn/davinci/image/LruCache.java index 0c9c194..0396288 100644 --- a/davinci/src/main/java/cn/hadcn/davinci/image/LruCache.java +++ b/davinci/src/main/java/cn/hadcn/davinci/image/LruCache.java @@ -44,7 +44,7 @@ public LruCache(int maxSize) { throw new IllegalArgumentException("maxSize <= 0"); } this.maxSize = maxSize; - this.map = new LinkedHashMap(0, 0.75f, true); + this.map = new LinkedHashMap<>(0, 0.75f, true); } /** * Returns the value for {@code key} if it exists in the cache or can be @@ -215,7 +215,7 @@ public synchronized final int evictionCount() { * recently accessed to most recently accessed. */ public synchronized final Map snapshot() { - return new LinkedHashMap(map); + return new LinkedHashMap<>(map); } @Override public synchronized final String toString() { int accesses = hitCount + missCount;