diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-03-30 23:37:42 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-30 23:37:42 +0000 |
commit | 917f4a44cb221ac51784e0bfde3a90e0e73bc46d (patch) | |
tree | 7f2c1560c26d19e129d3f1ea059fad7fbbfbc9ff /src/com/android/launcher3/compat | |
parent | 52f0130a76addcfec25775004c24346dc69b30d3 (diff) | |
parent | 4a907d0f9d1c80661c086aa95a8509698f38b324 (diff) | |
download | android_packages_apps_Trebuchet-917f4a44cb221ac51784e0bfde3a90e0e73bc46d.tar.gz android_packages_apps_Trebuchet-917f4a44cb221ac51784e0bfde3a90e0e73bc46d.tar.bz2 android_packages_apps_Trebuchet-917f4a44cb221ac51784e0bfde3a90e0e73bc46d.zip |
Merge "Delay the PinItemRequest#accept() call until the drop animation is finished." into ub-launcher3-dorval
am: 4a907d0f9d
Change-Id: Icd6d070199cd685633ead1301bda9d3e4de698c9
Diffstat (limited to 'src/com/android/launcher3/compat')
-rw-r--r-- | src/com/android/launcher3/compat/LauncherAppsCompat.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java index 2eb5b023b..4580b8108 100644 --- a/src/com/android/launcher3/compat/LauncherAppsCompat.java +++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java @@ -27,10 +27,12 @@ import android.os.UserHandle; import android.support.annotation.Nullable; import com.android.launcher3.LauncherAppState; +import com.android.launcher3.LauncherModel; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.Utilities; import com.android.launcher3.graphics.LauncherIcons; import com.android.launcher3.shortcuts.ShortcutInfoCompat; +import com.android.launcher3.util.LooperExecuter; import java.util.List; @@ -100,10 +102,32 @@ public abstract class LauncherAppsCompat { */ @Nullable public static ShortcutInfo createShortcutInfoFromPinItemRequest( - Context context, PinItemRequestCompat request) { + Context context, final PinItemRequestCompat request, final long acceptDelay) { if (request != null && request.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT && - request.isValid() && request.accept()) { + request.isValid()) { + + if (acceptDelay <= 0) { + if (!request.accept()) { + return null; + } + } else { + // Block the worker thread until the accept() is called. + new LooperExecuter(LauncherModel.getWorkerLooper()).execute(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(acceptDelay); + } catch (InterruptedException e) { + // Ignore + } + if (request.isValid()) { + request.accept(); + } + } + }); + } + ShortcutInfoCompat compat = new ShortcutInfoCompat(request.getShortcutInfo()); ShortcutInfo info = new ShortcutInfo(compat, context); // Apply the unbadged icon and fetch the actual icon asynchronously. |