diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-11-21 16:02:39 +0530 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-11-21 22:28:23 +0530 |
commit | dde4fd971e825749686e7aa77379c65e410eea54 (patch) | |
tree | f23e94c8931b2052d910f0dcba1b0d87a36305f1 /src/com/android/launcher3/shortcuts/DeepShortcutManager.java | |
parent | aa8a871e337fe42e9339b96833eaf37bf2b64b2f (diff) | |
download | android_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/DeepShortcutManager.java')
-rw-r--r-- | src/com/android/launcher3/shortcuts/DeepShortcutManager.java | 14 |
1 files changed, 13 insertions, 1 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); } |