diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-12-15 17:40:07 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-01-03 15:58:53 -0800 |
commit | 3fe4a146cf774261ab3552dd8ab392439c771e54 (patch) | |
tree | 5df73ef8f1166bfa827f46bb40a99974e8246cca /src/com/android/launcher3/compat | |
parent | bf8a265deb093e147a5289e0958cc9b1bc50a6e3 (diff) | |
download | android_packages_apps_Trebuchet-3fe4a146cf774261ab3552dd8ab392439c771e54.tar.gz android_packages_apps_Trebuchet-3fe4a146cf774261ab3552dd8ab392439c771e54.tar.bz2 android_packages_apps_Trebuchet-3fe4a146cf774261ab3552dd8ab392439c771e54.zip |
Simplifying IconCache access code
Providing a way to access icon cache without LauncherAcitivtiyInfo.
This allows fetching LauncherActivityInfo only when required, thus
avoiding system RPC when the icon is already in cache.
Change-Id: I92918c7a0d0d0796e5f7b70d4ecb6787c52c6600
Diffstat (limited to 'src/com/android/launcher3/compat')
-rw-r--r-- | src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java b/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java deleted file mode 100644 index 4dd05bb00..000000000 --- a/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher3.compat; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.graphics.drawable.Drawable; -import android.os.UserHandle; - -/** - * {@link LauncherActivityInfoCompat} which loads its data only when needed. - */ -public class DeferredLauncherActivityInfo extends LauncherActivityInfoCompat { - - private final ComponentName mComponent; - private final UserHandle mUser; - private final Context mContext; - - private LauncherActivityInfoCompat mActualInfo; - - public DeferredLauncherActivityInfo( - ComponentName component, UserHandle user, Context context) { - mComponent = component; - mUser = user; - mContext = context; - } - - @Override - public ComponentName getComponentName() { - return mComponent; - } - - @Override - public UserHandle getUser() { - return mUser; - } - - private synchronized LauncherActivityInfoCompat getActualInfo() { - if (mActualInfo == null) { - Intent intent = new Intent(Intent.ACTION_MAIN) - .addCategory(Intent.CATEGORY_LAUNCHER) - .setComponent(mComponent); - mActualInfo = LauncherAppsCompat.getInstance(mContext).resolveActivity(intent, mUser); - } - return mActualInfo; - } - - @Override - public CharSequence getLabel() { - return getActualInfo().getLabel(); - } - - @Override - public Drawable getIcon(int density) { - return getActualInfo().getIcon(density); - } - - @Override - public ApplicationInfo getApplicationInfo() { - return getActualInfo().getApplicationInfo(); - } - - @Override - public long getFirstInstallTime() { - return getActualInfo().getFirstInstallTime(); - } -} |