summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/shortcuts
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-11-21 16:02:39 +0530
committerSunny Goyal <sunnygoyal@google.com>2016-11-21 22:28:23 +0530
commitdde4fd971e825749686e7aa77379c65e410eea54 (patch)
treef23e94c8931b2052d910f0dcba1b0d87a36305f1 /src/com/android/launcher3/shortcuts
parentaa8a871e337fe42e9339b96833eaf37bf2b64b2f (diff)
downloadandroid_packages_apps_Trebuchet-dde4fd971e825749686e7aa77379c65e410eea54.tar.gz
android_packages_apps_Trebuchet-dde4fd971e825749686e7aa77379c65e410eea54.tar.bz2
android_packages_apps_Trebuchet-dde4fd971e825749686e7aa77379c65e410eea54.zip
Changing DeepShortcutManager to have a singleton contructor instead
of getting it from LauncherAppState This follows the design of other managers and makes it easier to access it from other processes and non-ui thread. Bug: 33032833 Change-Id: I8ad82ae5b6cc47bae885f9896985675c7dd0d5b8
Diffstat (limited to 'src/com/android/launcher3/shortcuts')
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutManager.java14
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java3
2 files changed, 14 insertions, 3 deletions
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
index c2c7c1772..41f1a47af 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
@@ -45,10 +45,22 @@ public class DeepShortcutManager {
private static final int FLAG_GET_ALL = ShortcutQuery.FLAG_MATCH_DYNAMIC
| ShortcutQuery.FLAG_MATCH_MANIFEST | ShortcutQuery.FLAG_MATCH_PINNED;
+ private static DeepShortcutManager sInstance;
+ private static final Object sInstanceLock = new Object();
+
+ public static DeepShortcutManager getInstance(Context context) {
+ synchronized (sInstanceLock) {
+ if (sInstance == null) {
+ sInstance = new DeepShortcutManager(context.getApplicationContext());
+ }
+ return sInstance;
+ }
+ }
+
private final LauncherApps mLauncherApps;
private boolean mWasLastCallSuccess;
- public DeepShortcutManager(Context context, ShortcutCache shortcutCache) {
+ private DeepShortcutManager(Context context) {
mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
index 08ca2429f..314a8628b 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
@@ -52,7 +52,6 @@ import com.android.launcher3.IconCache;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
-import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherViewPropertyAnimator;
@@ -103,7 +102,7 @@ public class DeepShortcutsContainer extends AbstractFloatingView
public DeepShortcutsContainer(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mLauncher = Launcher.getLauncher(context);
- mDeepShortcutsManager = LauncherAppState.getInstance().getShortcutManager();
+ mDeepShortcutsManager = DeepShortcutManager.getInstance(context);
mStartDragThreshold = getResources().getDimensionPixelSize(
R.dimen.deep_shortcuts_start_drag_threshold);