summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java6
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java27
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java13
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java29
4 files changed, 33 insertions, 42 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index 759686e..59fcc52 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -292,14 +292,14 @@ public final class Bridge extends LayoutBridge {
@Override
public BridgeLayoutScene createScene(SceneParams params) {
try {
- SceneResult lastResult = SceneResult.SUCCESS;
+ SceneResult lastResult = SceneStatus.SUCCESS.getResult();
LayoutSceneImpl scene = new LayoutSceneImpl(params);
try {
prepareThread();
lastResult = scene.init(params.getTimeout());
- if (lastResult == SceneResult.SUCCESS) {
+ if (lastResult.isSuccess()) {
lastResult = scene.inflate();
- if (lastResult == SceneResult.SUCCESS) {
+ if (lastResult.isSuccess()) {
lastResult = scene.render();
}
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java
index abcbabc..2f7ef48 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java
@@ -66,7 +66,7 @@ public class BridgeLayoutScene extends LayoutScene {
try {
Bridge.prepareThread();
mLastResult = mScene.acquire(timeout);
- if (mLastResult == SceneResult.SUCCESS) {
+ if (mLastResult.isSuccess()) {
mLastResult = mScene.render();
}
} finally {
@@ -83,7 +83,7 @@ public class BridgeLayoutScene extends LayoutScene {
try {
Bridge.prepareThread();
mLastResult = mScene.acquire(SceneParams.DEFAULT_TIMEOUT);
- if (mLastResult == SceneResult.SUCCESS) {
+ if (mLastResult.isSuccess()) {
mLastResult = mScene.animate(targetObject, animationName, isFrameworkAnimation,
listener);
}
@@ -96,21 +96,17 @@ public class BridgeLayoutScene extends LayoutScene {
}
@Override
- public SceneResult insertChild(Object parentView, IXmlPullParser childXml, Object beforeSibling,
+ public SceneResult insertChild(Object parentView, IXmlPullParser childXml, int index,
IAnimationListener listener) {
if (parentView instanceof ViewGroup == false) {
throw new IllegalArgumentException("parentView is not a ViewGroup");
}
- if (beforeSibling != null && beforeSibling instanceof View == false) {
- throw new IllegalArgumentException("beforeSibling is not a View");
- }
try {
Bridge.prepareThread();
mLastResult = mScene.acquire(SceneParams.DEFAULT_TIMEOUT);
- if (mLastResult == SceneResult.SUCCESS) {
- mLastResult = mScene.insertChild((ViewGroup) parentView, childXml,
- (View) beforeSibling, listener);
+ if (mLastResult.isSuccess()) {
+ mLastResult = mScene.insertChild((ViewGroup) parentView, childXml, index, listener);
}
} finally {
mScene.release();
@@ -122,7 +118,7 @@ public class BridgeLayoutScene extends LayoutScene {
@Override
- public SceneResult moveChild(Object parentView, Object childView, Object beforeSibling,
+ public SceneResult moveChild(Object parentView, Object childView, int index,
IAnimationListener listener) {
if (parentView instanceof ViewGroup == false) {
throw new IllegalArgumentException("parentView is not a ViewGroup");
@@ -130,16 +126,13 @@ public class BridgeLayoutScene extends LayoutScene {
if (childView instanceof View == false) {
throw new IllegalArgumentException("childView is not a View");
}
- if (beforeSibling != null && beforeSibling instanceof View == false) {
- throw new IllegalArgumentException("beforeSibling is not a View");
- }
try {
Bridge.prepareThread();
mLastResult = mScene.acquire(SceneParams.DEFAULT_TIMEOUT);
- if (mLastResult == SceneResult.SUCCESS) {
- mLastResult = mScene.moveChild((ViewGroup) parentView, (View) childView,
- (View) beforeSibling, listener);
+ if (mLastResult.isSuccess()) {
+ mLastResult = mScene.moveChild((ViewGroup) parentView, (View) childView, index,
+ listener);
}
} finally {
mScene.release();
@@ -158,7 +151,7 @@ public class BridgeLayoutScene extends LayoutScene {
try {
Bridge.prepareThread();
mLastResult = mScene.acquire(SceneParams.DEFAULT_TIMEOUT);
- if (mLastResult == SceneResult.SUCCESS) {
+ if (mLastResult.isSuccess()) {
mLastResult = mScene.removeChild((View) childView, listener);
}
} finally {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
index 80a0b2d..2b9d52f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
@@ -16,8 +16,10 @@
package com.android.layoutlib.bridge.impl;
+import com.android.layoutlib.api.LayoutScene;
import com.android.layoutlib.api.SceneResult;
import com.android.layoutlib.api.LayoutScene.IAnimationListener;
+import com.android.layoutlib.api.SceneResult.SceneStatus;
import com.android.layoutlib.bridge.Bridge;
import android.animation.Animator;
@@ -76,6 +78,7 @@ public class AnimationThread extends Thread {
mAnimator.start();
// loop the animation
+ LayoutScene scene = mScene.getScene();
do {
// get the next message.
MessageBundle bundle = mQueue.poll();
@@ -89,14 +92,14 @@ public class AnimationThread extends Thread {
try {
sleep(bundle.mUptimeMillis - currentTime);
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
+ // FIXME log/do something/sleep again?
e.printStackTrace();
}
}
// ready to do the work, acquire the scene.
SceneResult result = mScene.acquire(250);
- if (result != SceneResult.SUCCESS) {
+ if (result.isSuccess() == false) {
mListener.done(result);
return;
}
@@ -105,15 +108,15 @@ public class AnimationThread extends Thread {
// the next message, so mQueue will have another one.
try {
bundle.mTarget.handleMessage(bundle.mMessage);
- if (mScene.render() == SceneResult.SUCCESS) {
- mListener.onNewFrame(mScene.getScene());
+ if (mScene.render().isSuccess()) {
+ mListener.onNewFrame(scene);
}
} finally {
mScene.release();
}
} while (mQueue.size() > 0);
- mListener.done(SceneResult.SUCCESS);
+ mListener.done(SceneStatus.SUCCESS.getResult());
} finally {
Handler_Delegate.setCallback(null);
Bridge.cleanupThread();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
index bb0a07c..74e7fb2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
@@ -200,7 +200,7 @@ public class LayoutSceneImpl {
mBlockParser = new BridgeXmlBlockParser(mParams.getLayoutDescription(),
mContext, false /* platformResourceFlag */);
- return SceneResult.SUCCESS;
+ return SceneStatus.SUCCESS.getResult();
}
/**
@@ -342,7 +342,7 @@ public class LayoutSceneImpl {
mViewRoot.setBackgroundDrawable(d);
}
- return SceneResult.SUCCESS;
+ return SceneStatus.SUCCESS.getResult();
} catch (PostInflateException e) {
return new SceneResult(SceneStatus.ERROR_INFLATION, e.getMessage(), e);
} catch (Throwable e) {
@@ -469,7 +469,7 @@ public class LayoutSceneImpl {
System.out.println(String.format("rendering (ms): %03d", drawTime - preDrawTime));
// success!
- return SceneResult.SUCCESS;
+ return SceneStatus.SUCCESS.getResult();
} catch (Throwable e) {
// get the real cause of the exception.
Throwable t = e;
@@ -520,7 +520,7 @@ public class LayoutSceneImpl {
new AnimationThread(this, anim, listener).start();
- return SceneResult.SUCCESS;
+ return SceneStatus.SUCCESS.getResult();
}
} catch (Exception e) {
// get the real cause of the exception.
@@ -537,14 +537,9 @@ public class LayoutSceneImpl {
}
public SceneResult insertChild(ViewGroup parentView, IXmlPullParser childXml,
- View beforeSibling, IAnimationListener listener) {
+ int index, IAnimationListener listener) {
checkLock();
- int index = parentView.indexOfChild(beforeSibling);
- if (beforeSibling != null && index == -1) {
- throw new IllegalArgumentException("beforeSibling not in parentView");
- }
-
// create a block parser for the XML
BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(childXml, mContext,
false /* platformResourceFlag */);
@@ -564,18 +559,18 @@ public class LayoutSceneImpl {
invalidateRenderingSize();
- return render();
+ SceneResult result = render();
+ if (result.isSuccess()) {
+ result.setData(child);
+ }
+
+ return result;
}
- public SceneResult moveChild(ViewGroup parentView, View childView, View beforeSibling,
+ public SceneResult moveChild(ViewGroup parentView, View childView, int index,
IAnimationListener listener) {
checkLock();
- int index = parentView.indexOfChild(beforeSibling);
- if (beforeSibling != null && index == -1) {
- throw new IllegalArgumentException("beforeSibling not in parentView");
- }
-
try {
ViewParent parent = childView.getParent();
if (parent instanceof ViewGroup) {