OSDN Git Service

Changing some lambda to java 1.7 compatible code to allow
authorSunny Goyal <sunnygoyal@google.com>
Wed, 1 Nov 2017 18:49:39 +0000 (11:49 -0700)
committerSunny Goyal <sunnygoyal@google.com>
Fri, 3 Nov 2017 18:10:10 +0000 (11:10 -0700)
using the lib without the system classes

Test: Launcher3 compiles
Change-Id: I2f01cb887ae1f6a3291fde24ff7593cedd6fb5ba

packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/AppTransitionAnimationSpecsFuture.java
packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/RecentsTransition.java

index a46fab3..7a24071 100644 (file)
@@ -22,6 +22,7 @@ import android.view.AppTransitionAnimationSpec;
 import android.view.IAppTransitionAnimationSpecsFuture;
 
 import java.util.List;
+import java.util.concurrent.Callable;
 import java.util.concurrent.FutureTask;
 
 /**
@@ -31,11 +32,13 @@ import java.util.concurrent.FutureTask;
 public abstract class AppTransitionAnimationSpecsFuture {
 
     private final Handler mHandler;
-    private FutureTask<List<AppTransitionAnimationSpec>> mComposeTask = new FutureTask<>(() -> {
-        synchronized (AppTransitionAnimationSpecsFuture.this) {
-            return composeSpecs();
-        }
-    });
+    private FutureTask<List<AppTransitionAnimationSpec>> mComposeTask = new FutureTask<>(
+            new Callable<List<AppTransitionAnimationSpec>>() {
+                @Override
+                public List<AppTransitionAnimationSpec> call() throws Exception {
+                    return composeSpecs();
+                }
+            });
 
     private final IAppTransitionAnimationSpecsFuture mFuture =
             new IAppTransitionAnimationSpecsFuture.Stub() {
index 3095d15..f8f86f0 100644 (file)
@@ -42,7 +42,7 @@ public class RecentsTransition {
      */
     public static ActivityOptions createAspectScaleAnimation(Context context, Handler handler,
             boolean scaleUp, AppTransitionAnimationSpecsFuture animationSpecsFuture,
-            OnAnimationStartedListener animationStartCallback) {
+            final OnAnimationStartedListener animationStartCallback) {
         final OnAnimationStartedListener animStartedListener = new OnAnimationStartedListener() {
             private boolean mHandled;
 
@@ -70,15 +70,20 @@ public class RecentsTransition {
     /**
      * Wraps a animation-start callback in a binder that can be called from window manager.
      */
-    public static IRemoteCallback wrapStartedListener(Handler handler,
-            OnAnimationStartedListener listener) {
+    public static IRemoteCallback wrapStartedListener(final Handler handler,
+            final OnAnimationStartedListener listener) {
         if (listener == null) {
             return null;
         }
         return new IRemoteCallback.Stub() {
             @Override
             public void sendResult(Bundle data) throws RemoteException {
-                handler.post(listener::onAnimationStarted);
+                handler.post(new Runnable() {
+                                 @Override
+                                 public void run() {
+                                     listener.onAnimationStarted();
+                                 }
+                             });
             }
         };
     }
@@ -87,15 +92,18 @@ public class RecentsTransition {
      * @return a {@link GraphicBuffer} with the {@param view} drawn into it. Result can be null if
      *         we were unable to allocate a hardware bitmap.
      */
-    public static GraphicBuffer drawViewIntoGraphicBuffer(int width, int height, View view,
-            float scale, int eraseColor) {
-        final Bitmap hwBitmap = createHardwareBitmap(width, height, (c) -> {
-            c.scale(scale, scale);
-            if (eraseColor != 0) {
-                c.drawColor(eraseColor);
-            }
-            if (view != null) {
-                view.draw(c);
+    public static GraphicBuffer drawViewIntoGraphicBuffer(int width, int height, final View view,
+            final float scale, final int eraseColor) {
+        final Bitmap hwBitmap = createHardwareBitmap(width, height, new Consumer<Canvas>() {
+            @Override
+            public void accept(Canvas c) {
+                c.scale(scale, scale);
+                if (eraseColor != 0) {
+                    c.drawColor(eraseColor);
+                }
+                if (view != null) {
+                    view.draw(c);
+                }
             }
         });
         return hwBitmap != null ? hwBitmap.createGraphicBufferHandle() : null;