LayoutLib: Fix logging.

- Use the new logging API
- remove log object reference everywhere but in Bridge
- all logging code accesses Bridge.getLog()
- prepareScene sets the current scene log object in Bridge.

Change-Id: Ib0517ccd6454c4baf218b6baa978a126f91671e7
diff --git a/bridge/src/android/graphics/BitmapFactory.java b/bridge/src/android/graphics/BitmapFactory.java
index 212223c..c36b37b 100644
--- a/bridge/src/android/graphics/BitmapFactory.java
+++ b/bridge/src/android/graphics/BitmapFactory.java
@@ -17,6 +17,7 @@
 package android.graphics;
 
 import com.android.layoutlib.api.IDensityBasedResourceValue.Density;
+import com.android.layoutlib.bridge.Bridge;
 
 import android.content.res.AssetManager;
 import android.content.res.Resources;
@@ -448,7 +449,9 @@
         Bitmap  bm;
 
         if (is instanceof AssetManager.AssetInputStream) {
-            // FIXME: log this.
+            Bridge.getLog().error(null,
+                    "Bitmap.decodeStream: " +
+                    "InputStream is unsupported (AssetManager.AssetInputStream)");
             return null;
         } else {
             // pass some temp storage down to the native code. 1024 is made up,
diff --git a/bridge/src/android/graphics/Canvas_Delegate.java b/bridge/src/android/graphics/Canvas_Delegate.java
index bc6ad64..b116d2b 100644
--- a/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/bridge/src/android/graphics/Canvas_Delegate.java
@@ -16,7 +16,7 @@
 
 package android.graphics;
 
-import com.android.layoutlib.api.ILayoutLog;
+import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.impl.DelegateManager;
 import com.android.layoutlib.bridge.impl.Stack;
 
@@ -59,7 +59,6 @@
     // ---- delegate data ----
     private BufferedImage mBufferedImage;
     private final Stack<Graphics2D> mGraphicsStack = new Stack<Graphics2D>();
-    private ILayoutLog mLogger;
 
     // ---- Public Helper methods ----
 
@@ -78,14 +77,6 @@
     }
 
     /**
-     * Sets the layoutlib logger into the canvas.
-     * @param logger
-     */
-    public void setLogger(ILayoutLog logger) {
-        mLogger = logger;
-    }
-
-    /**
      * Returns the current {@link Graphics2D} used to draw.
      */
     public Graphics2D getGraphics2d() {
@@ -408,10 +399,11 @@
         // give it to the graphics2D as a new matrix replacing all previous transform
         g.setTransform(matrixTx);
 
-        // FIXME: log
-//        if (mLogger != null && matrixDelegate.hasPerspective()) {
-//            mLogger.warning("android.graphics.Canvas#setMatrix(android.graphics.Matrix) only supports affine transformations in the Layout Editor.");
-//        }
+        if (matrixDelegate.hasPerspective()) {
+            Bridge.getLog().warning(null,
+                    "android.graphics.Canvas#setMatrix(android.graphics.Matrix) only " +
+                    "supports affine transformations in the Layout Preview.");
+        }
     }
 
     /*package*/ static boolean native_clipRect(int nCanvas,
@@ -1042,11 +1034,10 @@
                 g.setPaint(shaderPaint);
                 useColorPaint = false;
             } else {
-                if (mLogger != null) {
-                    mLogger.warning(String.format(
-                            "Shader '%1$s' is not supported in the Layout Editor.",
+                Bridge.getLog().warning(null,
+                        String.format(
+                            "Shader '%1$s' is not supported in the Layout Preview.",
                             shaderDelegate.getClass().getCanonicalName()));
-                }
             }
         }
 
@@ -1089,10 +1080,11 @@
             g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
 
             // if xfermode wasn't null, then it's something we don't support. log it.
-            if (mLogger != null && xfermodeDelegate != null) {
-                mLogger.warning(String.format(
-                        "Xfermode '%1$s' is not supported in the Layout Editor.",
-                        xfermodeDelegate.getClass().getCanonicalName()));
+            if (xfermodeDelegate != null) {
+                Bridge.getLog().warning(null,
+                        String.format(
+                            "Xfermode '%1$s' is not supported in the Layout Preview.",
+                            xfermodeDelegate.getClass().getCanonicalName()));
             }
         }
 
diff --git a/bridge/src/android/graphics/NinePatch_Delegate.java b/bridge/src/android/graphics/NinePatch_Delegate.java
index 3d26e47..a6c6dfd 100644
--- a/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -16,6 +16,7 @@
 
 package android.graphics;
 
+import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.impl.DelegateManager;
 import com.android.ninepatch.NinePatchChunk;
 
@@ -71,7 +72,7 @@
             oos = new ObjectOutputStream(baos);
             oos.writeObject(chunk);
         } catch (IOException e) {
-            //FIXME log this.
+            Bridge.getLog().error("Failed to serialize NinePatchChunk.", e);
             return null;
         } finally {
             if (oos != null) {
@@ -205,10 +206,10 @@
                     sChunkCache.put(array, new SoftReference<NinePatchChunk>(chunk));
                 }
             } catch (IOException e) {
-                // FIXME: log this
+                Bridge.getLog().error("Failed to deserialize NinePatchChunk content.", e);
                 return null;
             } catch (ClassNotFoundException e) {
-                // FIXME: log this
+                Bridge.getLog().error("Failed to deserialize NinePatchChunk class.", e);
                 return null;
             } finally {
                 if (ois != null) {
diff --git a/bridge/src/com/android/layoutlib/bridge/Bridge.java b/bridge/src/com/android/layoutlib/bridge/Bridge.java
index 2a94774..38e03ca 100644
--- a/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -17,7 +17,7 @@
 package com.android.layoutlib.bridge;
 
 import com.android.layoutlib.api.Capabilities;
-import com.android.layoutlib.api.ILayoutLog;
+import com.android.layoutlib.api.LayoutLog;
 import com.android.layoutlib.api.IProjectCallback;
 import com.android.layoutlib.api.IResourceValue;
 import com.android.layoutlib.api.IXmlPullParser;
@@ -133,14 +133,16 @@
     private final static IntArray sIntArrayWrapper = new IntArray();
 
     /**
-     * A default logger than prints to stdout/stderr.
+     * A default log than prints to stdout/stderr.
      */
-    private final static ILayoutLog sDefaultLogger = new ILayoutLog() {
-        public void error(String message) {
+    private final static LayoutLog sDefaultLog = new LayoutLog() {
+        @Override
+        public void error(String tag, String message) {
             System.err.println(message);
         }
 
-        public void error(Throwable t) {
+        @Override
+        public void error(String tag, Throwable t) {
             String message = t.getMessage();
             if (message == null) {
                 message = t.getClass().getName();
@@ -149,11 +151,23 @@
             System.err.println(message);
         }
 
-        public void warning(String message) {
+        @Override
+        public void error(String tag, String message, Throwable throwable) {
+            System.err.println(message);
+        }
+
+        @Override
+        public void warning(String tag, String message) {
             System.out.println(message);
         }
     };
 
+    /**
+     * Current log.
+     */
+    private static LayoutLog sCurrentLog = sDefaultLog;
+
+
     private EnumSet<Capabilities> mCapabilities;
 
 
@@ -203,7 +217,7 @@
             OverrideMethod.setDefaultListener(new MethodAdapter() {
                 @Override
                 public void onInvokeV(String signature, boolean isNative, Object caller) {
-                    sDefaultLogger.error("Missing Stub: " + signature +
+                    sDefaultLog.error(null, "Missing Stub: " + signature +
                             (isNative ? " (native)" : ""));
 
                     if (debug.equalsIgnoreCase("throw")) {
@@ -311,7 +325,7 @@
     @Override
     public BridgeLayoutScene createScene(SceneParams params) {
         try {
-            SceneResult lastResult = SceneStatus.SUCCESS.getResult();
+            SceneResult lastResult = SceneStatus.SUCCESS.createResult();
             LayoutSceneImpl scene = new LayoutSceneImpl(params);
             try {
                 prepareThread();
@@ -335,7 +349,7 @@
                 t2 = t.getCause();
             }
             return new BridgeLayoutScene(null,
-                    SceneStatus.ERROR_UNKNOWN.getResult(t2.getMessage(), t2));
+                    SceneStatus.ERROR_UNKNOWN.createResult(t2.getMessage(), t2));
         }
     }
 
@@ -383,6 +397,23 @@
         Looper.sThreadLocal.remove();
     }
 
+    public static LayoutLog getLog() {
+        return sCurrentLog;
+    }
+
+    public static void setLog(LayoutLog log) {
+        // check only the thread currently owning the lock can do this.
+        if (sLock.isHeldByCurrentThread() == false) {
+            throw new IllegalStateException("scene must be acquired first. see #acquire(long)");
+        }
+
+        if (log != null) {
+            sCurrentLog = log;
+        } else {
+            sCurrentLog = sDefaultLog;
+        }
+    }
+
     /**
      * Returns details of a framework resource from its integer value.
      * @param value the integer value
@@ -391,7 +422,6 @@
      */
     public static String[] resolveResourceValue(int value) {
         return sRMap.get(value);
-
     }
 
     /**
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 688f240..32b2fd4 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -16,7 +16,6 @@
 
 package com.android.layoutlib.bridge.android;
 
-import com.android.layoutlib.api.ILayoutLog;
 import com.android.layoutlib.api.IProjectCallback;
 import com.android.layoutlib.api.IResourceValue;
 import com.android.layoutlib.api.IStyleResourceValue;
@@ -97,7 +96,6 @@
     private BridgeInflater mInflater;
 
     private final IProjectCallback mProjectCallback;
-    private final ILayoutLog mLogger;
     private BridgeContentResolver mContentResolver;
 
     private final Stack<BridgeXmlBlockParser> mParserStack = new Stack<BridgeXmlBlockParser>();
@@ -122,11 +120,10 @@
             Map<String, Map<String, IResourceValue>> projectResources,
             Map<String, Map<String, IResourceValue>> frameworkResources,
             Map<IStyleResourceValue, IStyleResourceValue> styleInheritanceMap,
-            IProjectCallback projectCallback, ILayoutLog logger) {
+            IProjectCallback projectCallback) {
         mProjectKey = projectKey;
         mMetrics = metrics;
         mProjectCallback = projectCallback;
-        mLogger = logger;
 
         mThemeValues = currentTheme;
         mProjectResources = projectResources;
@@ -183,10 +180,6 @@
         return mProjectCallback;
     }
 
-    public ILayoutLog getLogger() {
-        return mLogger;
-    }
-
     public Map<String, String> getDefaultPropMap(Object key) {
         return mDefaultPropMaps.get(key);
     }
@@ -340,7 +333,7 @@
             // good, nothing to do.
         } else if (set != null) { // null parser is ok
             // really this should not be happening since its instantiated in Bridge
-            mLogger.error("Parser is not a BridgeXmlBlockParser!");
+            Bridge.getLog().error(null, "Parser is not a BridgeXmlBlockParser!");
             return null;
         }
 
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
index d9e26e2..057c9c3 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
@@ -178,7 +178,7 @@
 
                         return inflate(bridgeParser, root);
                     } catch (Exception e) {
-                        bridgeContext.getLogger().error(e);
+                        Bridge.getLog().error(null, e);
                         // return null below.
                     }
                 }
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
index affd1c6..678be9c 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
@@ -174,11 +174,11 @@
                         return ColorStateList.createFromXml(this,
                                 new BridgeXmlBlockParser(parser, mContext, resValue.isFramework()));
                     } catch (XmlPullParserException e) {
-                        mContext.getLogger().error(e);
+                        Bridge.getLog().error(null, e);
                     } catch (FileNotFoundException e) {
                         // will not happen, since we pre-check
                     } catch (IOException e) {
-                        mContext.getLogger().error(e);
+                        Bridge.getLog().error(null, e);
                     }
 
                 } else {
@@ -245,7 +245,7 @@
                     return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
                 }
             } catch (XmlPullParserException e) {
-                mContext.getLogger().error(e);
+                Bridge.getLog().error(null, e);
                 // we'll return null below.
             } catch (FileNotFoundException e) {
                 // this shouldn't happen since we check above.
@@ -279,7 +279,7 @@
                     return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
                 }
             } catch (XmlPullParserException e) {
-                mContext.getLogger().error(e);
+                Bridge.getLog().error(null, e);
                 // we'll return null below.
             } catch (FileNotFoundException e) {
                 // this shouldn't happen since we check above.
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
index c8dc9e6..800256b 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
@@ -205,7 +205,7 @@
                 if (i != null) {
                     result |= i.intValue();
                 } else {
-                    mContext.getLogger().warning(String.format(
+                    Bridge.getLog().warning(null, String.format(
                             "Unknown constant \"%s\" in attribute \"%2$s\"",
                             keyword, mNames[index]));
                 }
@@ -235,7 +235,7 @@
             try {
                 return Float.parseFloat(s);
             } catch (NumberFormatException e) {
-                mContext.getLogger().warning(String.format(
+                Bridge.getLog().warning(null, String.format(
                         "Unable to convert \"%s\" into a float in attribute \"%2$s\"",
                         s, mNames[index]));
 
@@ -267,7 +267,7 @@
         try {
             return ResourceHelper.getColor(s);
         } catch (NumberFormatException e) {
-            mContext.getLogger().warning(String.format(
+            Bridge.getLog().warning(null, String.format(
                     "Unable to convert \"%s\" into a color in attribute \"%2$s\"",
                     s, mNames[index]));
 
@@ -322,13 +322,13 @@
         } catch (Exception e) {
             // this is an error and not warning since the file existence is checked before
             // attempting to parse it.
-            mContext.getLogger().error(e);
+            Bridge.getLog().error(null, e);
 
             // return null below.
         }
 
         // looks like were unable to resolve the color value.
-        mContext.getLogger().warning(String.format(
+        Bridge.getLog().warning(null, String.format(
                 "Unable to resolve color value \"%1$s\" in attribute \"%2$s\"",
                 value, mNames[index]));
 
@@ -356,7 +356,7 @@
             try {
                 return Integer.parseInt(s);
             } catch (NumberFormatException e) {
-                mContext.getLogger().warning(String.format(
+                Bridge.getLog().warning(null, String.format(
                         "Unable to convert \"%s\" into a integer in attribute \"%2$s\"",
                         s, mNames[index]));
 
@@ -405,7 +405,7 @@
         }
 
         // looks like we were unable to resolve the dimension value
-        mContext.getLogger().warning(String.format(
+        Bridge.getLog().warning(null, String.format(
                 "Unable to resolve dimension value \"%1$s\" in attribute \"%2$s\"",
                 s, mNames[index]));
 
@@ -534,7 +534,7 @@
         }
 
         // looks like we were unable to resolve the fraction value
-        mContext.getLogger().warning(String.format(
+        Bridge.getLog().warning(null, String.format(
                 "Unable to resolve fraction value \"%1$s\" in attribute \"%2$s\"",
                 value, mNames[index]));
 
@@ -641,7 +641,7 @@
             return idValue.intValue();
         }
 
-        mContext.getLogger().warning(String.format(
+        Bridge.getLog().warning(null, String.format(
                 "Unable to resolve id \"%1$s\" for attribute \"%2$s\"", value, mNames[index]));
         return defValue;
     }
@@ -675,7 +675,7 @@
         }
 
         // looks like we were unable to resolve the drawable
-        mContext.getLogger().warning(String.format(
+        Bridge.getLog().warning(null, String.format(
                 "Unable to resolve drawable \"%1$s\" in attribute \"%2$s\"", stringValue,
                 mNames[index]));
 
@@ -704,7 +704,7 @@
             return new CharSequence[] { value };
         }
 
-        mContext.getLogger().warning(String.format(
+        Bridge.getLog().warning(null, String.format(
                 String.format("Unknown value for getTextArray(%d) => %s", //DEBUG
                 index, mData[index].getName())));
 
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java b/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
index 400a05f..4ee813c 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
@@ -146,7 +146,7 @@
                 }
             } while (mListener.isCanceled() == false && mQueue.size() > 0);
 
-            mListener.done(SceneStatus.SUCCESS.getResult());
+            mListener.done(SceneStatus.SUCCESS.createResult());
         } finally {
             postAnimation();
             Handler_Delegate.setCallback(null);
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java b/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
index 359180f..d58cde8 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
@@ -50,7 +50,6 @@
 import android.graphics.Bitmap;
 import android.graphics.Bitmap_Delegate;
 import android.graphics.Canvas;
-import android.graphics.Canvas_Delegate;
 import android.graphics.drawable.Drawable;
 import android.os.Handler;
 import android.util.DisplayMetrics;
@@ -174,7 +173,7 @@
         // build the context
         mContext = new BridgeContext(mParams.getProjectKey(), metrics, mCurrentTheme,
                 mParams.getProjectResources(), mParams.getFrameworkResources(),
-                styleParentMap, mParams.getProjectCallback(), mParams.getLogger());
+                styleParentMap, mParams.getProjectCallback());
 
         // set the current rendering context
         sCurrentContext = mContext;
@@ -202,7 +201,7 @@
         mBlockParser = new BridgeXmlBlockParser(mParams.getLayoutDescription(),
                 mContext, false /* platformResourceFlag */);
 
-        return SceneStatus.SUCCESS.getResult();
+        return SceneStatus.SUCCESS.createResult();
     }
 
     /**
@@ -243,8 +242,9 @@
         // scene
         mContext.initResources();
         sCurrentContext = mContext;
+        Bridge.setLog(mParams.getLog());
 
-        return SUCCESS.getResult();
+        return SUCCESS.createResult();
     }
 
     /**
@@ -267,10 +267,10 @@
                 boolean acquired = lock.tryLock(timeout, TimeUnit.MILLISECONDS);
 
                 if (acquired == false) {
-                    return ERROR_TIMEOUT.getResult();
+                    return ERROR_TIMEOUT.createResult();
                 }
             } catch (InterruptedException e) {
-                return ERROR_LOCK_INTERRUPTED.getResult();
+                return ERROR_LOCK_INTERRUPTED.createResult();
             }
         } else {
             // This thread holds the lock already. Checks that this wasn't for a different context.
@@ -279,7 +279,7 @@
             if (mContext != sCurrentContext) {
                 throw new IllegalStateException("Acquiring different scenes from same thread without releases");
             }
-            return SUCCESS.getResult();
+            return SUCCESS.createResult();
         }
 
         return null;
@@ -297,6 +297,7 @@
         if (lock.isHeldByCurrentThread()) {
             // Make sure to remove static references, otherwise we could not unload the lib
             mContext.disposeResources();
+            Bridge.setLog(null);
             sCurrentContext = null;
 
             lock.unlock();
@@ -344,9 +345,9 @@
                 mViewRoot.setBackgroundDrawable(d);
             }
 
-            return SceneStatus.SUCCESS.getResult();
+            return SceneStatus.SUCCESS.createResult();
         } catch (PostInflateException e) {
-            return SceneStatus.ERROR_INFLATION.getResult(e.getMessage(), e);
+            return SceneStatus.ERROR_INFLATION.createResult(e.getMessage(), e);
         } catch (Throwable e) {
             // get the real cause of the exception.
             Throwable t = e;
@@ -355,9 +356,9 @@
             }
 
             // log it
-            mParams.getLogger().error(t);
+            mParams.getLog().error("Scene inflate failed", t);
 
-            return SceneStatus.ERROR_INFLATION.getResult(t.getMessage(), t);
+            return SceneStatus.ERROR_INFLATION.createResult(t.getMessage(), t);
         }
     }
 
@@ -377,7 +378,7 @@
 
         try {
             if (mViewRoot == null) {
-                return SceneStatus.ERROR_NOT_INFLATED.getResult();
+                return SceneStatus.ERROR_NOT_INFLATED.createResult();
             }
             // measure the views
             int w_spec, h_spec;
@@ -457,10 +458,6 @@
                 mCanvas.setDensity(mParams.getDensity());
             }
 
-            // to set the logger, get the native delegate
-            Canvas_Delegate canvasDelegate = Canvas_Delegate.getDelegate(mCanvas);
-            canvasDelegate.setLogger(mParams.getLogger());
-
             long preDrawTime = System.currentTimeMillis();
 
             mViewRoot.draw(mCanvas);
@@ -472,7 +469,7 @@
             System.out.println(String.format("rendering (ms): %03d", drawTime - preDrawTime));
 
             // success!
-            return SceneStatus.SUCCESS.getResult();
+            return SceneStatus.SUCCESS.createResult();
         } catch (Throwable e) {
             // get the real cause of the exception.
             Throwable t = e;
@@ -481,9 +478,9 @@
             }
 
             // log it
-            mParams.getLogger().error(t);
+            mParams.getLog().error("Scene Render failed", t);
 
-            return SceneStatus.ERROR_UNKNOWN.getResult(t.getMessage(), t);
+            return SceneStatus.ERROR_UNKNOWN.createResult(t.getMessage(), t);
         }
     }
 
@@ -524,7 +521,7 @@
 
                     new PlayAnimationThread(anim, this, animationName, listener).start();
 
-                    return SceneStatus.SUCCESS.getResult();
+                    return SceneStatus.SUCCESS.createResult();
                 }
             } catch (Exception e) {
                 // get the real cause of the exception.
@@ -533,11 +530,11 @@
                     t = t.getCause();
                 }
 
-                return SceneStatus.ERROR_UNKNOWN.getResult(t.getMessage(), t);
+                return SceneStatus.ERROR_UNKNOWN.createResult(t.getMessage(), t);
             }
         }
 
-        return SceneStatus.ERROR_ANIM_NOT_FOUND.getResult();
+        return SceneStatus.ERROR_ANIM_NOT_FOUND.createResult();
     }
 
     /**
@@ -581,7 +578,7 @@
             }.start();
 
             // always return success since the real status will come through the listener.
-            return SceneStatus.SUCCESS.getResult(child);
+            return SceneStatus.SUCCESS.createResult(child);
         }
 
         // add it to the parentView in the correct location
@@ -612,10 +609,10 @@
     private SceneResult addView(ViewGroup parent, View view, int index) {
         try {
             parent.addView(view, index);
-            return SceneStatus.SUCCESS.getResult();
+            return SceneStatus.SUCCESS.createResult();
         } catch (UnsupportedOperationException e) {
             // looks like this is a view class that doesn't support children manipulation!
-            return SceneStatus.ERROR_VIEWGROUP_NO_CHILDREN.getResult();
+            return SceneStatus.ERROR_VIEWGROUP_NO_CHILDREN.createResult();
         }
     }
 
@@ -659,7 +656,7 @@
             }.start();
 
             // always return success since the real status will come through the listener.
-            return SceneStatus.SUCCESS.getResult(layoutParams);
+            return SceneStatus.SUCCESS.createResult(layoutParams);
         }
 
         SceneResult result = moveView(parentView, childView, index, layoutParams);
@@ -701,10 +698,10 @@
                 parent.addView(view, index);
             }
 
-            return SceneStatus.SUCCESS.getResult();
+            return SceneStatus.SUCCESS.createResult();
         } catch (UnsupportedOperationException e) {
             // looks like this is a view class that doesn't support children manipulation!
-            return SceneStatus.ERROR_VIEWGROUP_NO_CHILDREN.getResult();
+            return SceneStatus.ERROR_VIEWGROUP_NO_CHILDREN.createResult();
         }
     }
 
@@ -741,7 +738,7 @@
             }.start();
 
             // always return success since the real status will come through the listener.
-            return SceneStatus.SUCCESS.getResult();
+            return SceneStatus.SUCCESS.createResult();
         }
 
         SceneResult result = removeView(parent, childView);
@@ -764,10 +761,10 @@
     private SceneResult removeView(ViewGroup parent, View view) {
         try {
             parent.removeView(view);
-            return SceneStatus.SUCCESS.getResult();
+            return SceneStatus.SUCCESS.createResult();
         } catch (UnsupportedOperationException e) {
             // looks like this is a view class that doesn't support children manipulation!
-            return SceneStatus.ERROR_VIEWGROUP_NO_CHILDREN.getResult();
+            return SceneStatus.ERROR_VIEWGROUP_NO_CHILDREN.createResult();
         }
     }
 
@@ -927,7 +924,7 @@
             return (IStyleResourceValue)parent;
         }
 
-        mParams.getLogger().error(
+        mParams.getLog().error(null,
                 String.format("Unable to resolve parent style name: %s", parentName));
 
         return null;
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java b/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
index bbc7f4b..2e2c5f4 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
@@ -38,7 +38,7 @@
         // the queue is filled when this method returns.
         mAnimator.start();
 
-        return SceneStatus.SUCCESS.getResult();
+        return SceneStatus.SUCCESS.createResult();
     }
 
     @Override
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index ceb8a0d..5a4a0a5 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -17,8 +17,8 @@
 package com.android.layoutlib.bridge.impl;
 
 import com.android.layoutlib.api.IDensityBasedResourceValue;
-import com.android.layoutlib.api.IDensityBasedResourceValue.Density;
 import com.android.layoutlib.api.IResourceValue;
+import com.android.layoutlib.api.IDensityBasedResourceValue.Density;
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.android.BridgeContext;
 import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
@@ -188,11 +188,11 @@
                             new BridgeXmlBlockParser(parser, context, isFramework));
                     return d;
                 } catch (XmlPullParserException e) {
-                    context.getLogger().error(e);
+                    Bridge.getLog().error(null, e);
                 } catch (FileNotFoundException e) {
                     // will not happen, since we pre-check
                 } catch (IOException e) {
-                    context.getLogger().error(e);
+                    Bridge.getLog().error(null, e);
                 }
             }