OSDN Git Service

LayoutLib: fix moveChild again.
authorXavier Ducrohet <xav@android.com>
Sat, 8 Jan 2011 00:16:21 +0000 (16:16 -0800)
committerXavier Ducrohet <xav@android.com>
Sat, 8 Jan 2011 00:16:21 +0000 (16:16 -0800)
Change-Id: Ib69a06e44be1e332f0f43c36c795c86270cb1b71

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java

index 6eef581..125c1e6 100644 (file)
@@ -150,7 +150,10 @@ public abstract class AnimationThread extends Thread {
             mListener.done(Status.SUCCESS.createResult());
 
         } catch (Throwable throwable) {
-            Bridge.getLog().error(null, "Error playing animation", throwable);
+            // can't use Bridge.getLog() as the exception might be thrown outside
+            // of an acquire/release block.
+            mSession.getLog().error(null, "Error playing animation", throwable);
+            mListener.done(Status.ERROR_UNKNOWN.createResult("Error playing animation", throwable));
 
         } finally {
             postAnimation();
index b624f58..19c3891 100644 (file)
@@ -28,6 +28,7 @@ import static com.android.ide.common.rendering.api.Result.Status.SUCCESS;
 import com.android.ide.common.rendering.api.IAnimationListener;
 import com.android.ide.common.rendering.api.ILayoutPullParser;
 import com.android.ide.common.rendering.api.IProjectCallback;
+import com.android.ide.common.rendering.api.LayoutLog;
 import com.android.ide.common.rendering.api.Params;
 import com.android.ide.common.rendering.api.RenderSession;
 import com.android.ide.common.rendering.api.ResourceDensity;
@@ -654,14 +655,20 @@ public class RenderSessionImpl {
                     previousParent.setLayoutTransition(removeTransition);
 
                     // no fade-out
-                    removeTransition.setAnimator(LayoutTransition.DISAPPEARING, null);
+                    // FIXME: set a non-null do-nothing Animator.
+                    // setting a null animator doesn't work because the child gets its parent
+                    // set to null too late.
+                    //removeTransition.setAnimator(LayoutTransition.DISAPPEARING, null);
 
                     // now for the new parent, if different
                     if (previousParent != newParentView) {
                         LayoutTransition addTransition = new LayoutTransition();
 
                         // no fade-in
-                        addTransition.setAnimator(LayoutTransition.APPEARING, null);
+                        // FIXME: set a non-null do-nothing Animator.
+                        // setting a null animator doesn't work because the child gets its parent
+                        // set to null too late.
+                        //addTransition.setAnimator(LayoutTransition.APPEARING, null);
 
                         newParentView.setLayoutTransition(addTransition);
                     }
@@ -827,6 +834,18 @@ public class RenderSessionImpl {
     }
 
     /**
+     * Returns the log associated with the session.
+     * @return the log or null if there are none.
+     */
+    public LayoutLog getLog() {
+        if (mParams != null) {
+            return mParams.getLog();
+        }
+
+        return null;
+    }
+
+    /**
      * Checks that the lock is owned by the current thread and that the current context is the one
      * from this scene.
      *