Some cleanups in IconCache class:

1. Make an instance variable final
2. Replace explicit type argument with <>
3. Get rid of an unnecessary return statement

Change-Id: Ifd0017e973c33a40d398fceb65125464f877ff56
This commit is contained in:
Rajeev Kumar 2017-06-27 12:44:56 -07:00
parent 8db04610f9
commit ba9065cffd
1 changed files with 5 additions and 8 deletions

View File

@ -41,7 +41,6 @@ import android.os.UserHandle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
@ -52,7 +51,6 @@ import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Provider;
import com.android.launcher3.util.SQLiteCacheHelper;
import com.android.launcher3.util.Thunk;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@ -91,7 +89,7 @@ public class IconCache {
private final Context mContext;
private final PackageManager mPackageManager;
private IconProvider mIconProvider;
private final IconProvider mIconProvider;
@Thunk final UserManagerCompat mUserManager;
private final LauncherAppsCompat mLauncherApps;
private final HashMap<ComponentKey, CacheEntry> mCache =
@ -193,7 +191,7 @@ public class IconCache {
* Remove any records for the supplied package name from memory.
*/
private void removeFromMemCacheLocked(String packageName, UserHandle user) {
HashSet<ComponentKey> forDeletion = new HashSet<ComponentKey>();
HashSet<ComponentKey> forDeletion = new HashSet<>();
for (ComponentKey key: mCache.keySet()) {
if (key.componentName.getPackageName().equals(packageName)
&& key.user.equals(user)) {
@ -219,7 +217,6 @@ public class IconCache {
}
} catch (NameNotFoundException e) {
Log.d(TAG, "Package not found", e);
return;
}
}
@ -264,7 +261,7 @@ public class IconCache {
Set<String> ignorePackages) {
long userSerial = mUserManager.getSerialNumberForUser(user);
PackageManager pm = mContext.getPackageManager();
HashMap<String, PackageInfo> pkgInfoMap = new HashMap<String, PackageInfo>();
HashMap<String, PackageInfo> pkgInfoMap = new HashMap<>();
for (PackageInfo info : pm.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES)) {
pkgInfoMap.put(info.packageName, info);
}
@ -274,7 +271,7 @@ public class IconCache {
componentMap.put(app.getComponentName(), app);
}
HashSet<Integer> itemsToRemove = new HashSet<Integer>();
HashSet<Integer> itemsToRemove = new HashSet<>();
Stack<LauncherActivityInfo> appsToUpdate = new Stack<>();
Cursor c = null;
@ -704,7 +701,7 @@ public class IconCache {
private final HashMap<String, PackageInfo> mPkgInfoMap;
private final Stack<LauncherActivityInfo> mAppsToAdd;
private final Stack<LauncherActivityInfo> mAppsToUpdate;
private final HashSet<String> mUpdatedPackages = new HashSet<String>();
private final HashSet<String> mUpdatedPackages = new HashSet<>();
@Thunk SerializedIconUpdateTask(long userSerial, HashMap<String, PackageInfo> pkgInfoMap,
Stack<LauncherActivityInfo> appsToAdd,