diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-08-26 20:17:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-26 20:17:40 +0000 |
commit | b44f7fda759394b6447f19c0b3c9a3fdf8f9cd95 (patch) | |
tree | ad8b651cac58c10183ac12da3fa624f3e744d502 /tools | |
parent | 78d77bc379f42dfe020cf0719ceae14174cf1c33 (diff) | |
parent | 0a07bb95a1dd94c3457860a934d3ee546919cff2 (diff) | |
download | frameworks_base-b44f7fda759394b6447f19c0b3c9a3fdf8f9cd95.zip frameworks_base-b44f7fda759394b6447f19c0b3c9a3fdf8f9cd95.tar.gz frameworks_base-b44f7fda759394b6447f19c0b3c9a3fdf8f9cd95.tar.bz2 |
am 0a07bb95: am aa729889: Don\'t keep LayoutlibCallback reference. [DO NOT MERGE]
* commit '0a07bb95a1dd94c3457860a934d3ee546919cff2':
Don't keep LayoutlibCallback reference. [DO NOT MERGE]
Diffstat (limited to 'tools')
3 files changed, 14 insertions, 86 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ParserFactory.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ParserFactory.java index 6ca22b0..646f960 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ParserFactory.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ParserFactory.java @@ -19,7 +19,6 @@ package com.android.layoutlib.bridge.impl; import com.android.annotations.NonNull; import com.android.annotations.Nullable; -import com.android.ide.common.rendering.api.LayoutlibCallback; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -44,10 +43,11 @@ public class ParserFactory { // Used to get a new XmlPullParser from the client. @Nullable - private static LayoutlibCallback sLayoutlibCallback; + private static com.android.ide.common.rendering.api.ParserFactory sParserFactory; - public static void setLayoutlibCallback(@Nullable LayoutlibCallback callback) { - sLayoutlibCallback = callback; + public static void setParserFactory( + @Nullable com.android.ide.common.rendering.api.ParserFactory parserFactory) { + sParserFactory = parserFactory; } @NonNull @@ -77,10 +77,10 @@ public class ParserFactory { @NonNull public static XmlPullParser instantiateParser(@Nullable String name) throws XmlPullParserException { - if (sLayoutlibCallback == null) { + if (sParserFactory == null) { throw new XmlPullParserException("ParserFactory not initialized."); } - XmlPullParser parser = sLayoutlibCallback.createParser(name); + XmlPullParser parser = sParserFactory.createParser(name); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); return parser; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java index 66b0023..2b95488 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java @@ -39,8 +39,6 @@ import android.view.inputmethod.InputMethodManager_Accessor; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; -import javax.swing.text.html.parser.Parser; - import static com.android.ide.common.rendering.api.Result.Status.ERROR_LOCK_INTERRUPTED; import static com.android.ide.common.rendering.api.Result.Status.ERROR_TIMEOUT; import static com.android.ide.common.rendering.api.Result.Status.SUCCESS; @@ -102,7 +100,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso } // setup the ParserFactory - ParserFactory.setLayoutlibCallback(mParams.getLayoutlibCallback()); + ParserFactory.setParserFactory(mParams.getLayoutlibCallback().getParserFactory()); HardwareConfig hardwareConfig = mParams.getHardwareConfig(); @@ -276,7 +274,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso mContext.getRenderResources().setFrameworkResourceIdProvider(null); mContext.getRenderResources().setLogger(null); } - ParserFactory.setLayoutlibCallback(null); + ParserFactory.setParserFactory(null); } diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java index d87c99f..4623f69 100644 --- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java +++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java @@ -17,15 +17,7 @@ package com.android.layoutlib.bridge.android; import com.android.annotations.NonNull; -import com.android.ide.common.rendering.api.ActionBarCallback; -import com.android.ide.common.rendering.api.AdapterBinding; -import com.android.ide.common.rendering.api.ILayoutPullParser; -import com.android.ide.common.rendering.api.LayoutlibCallback; -import com.android.ide.common.rendering.api.ResourceReference; -import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.impl.ParserFactory; -import com.android.resources.ResourceType; -import com.android.util.Pair; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -40,8 +32,8 @@ import static org.junit.Assert.assertEquals; public class BridgeXmlBlockParserTest { @BeforeClass - public void setUp() { - ParserFactory.setLayoutlibCallback(new LayoutlibTestCallback()); + public static void setUp() { + ParserFactory.setParserFactory(new ParserFactoryImpl()); } @Test @@ -128,79 +120,17 @@ public class BridgeXmlBlockParserTest { } @AfterClass - public void tearDown() { - ParserFactory.setLayoutlibCallback(null); + public static void tearDown() { + ParserFactory.setParserFactory(null); } - private static class LayoutlibTestCallback extends LayoutlibCallback { + private static class ParserFactoryImpl + extends com.android.ide.common.rendering.api.ParserFactory { @NonNull @Override public XmlPullParser createParser(String displayName) throws XmlPullParserException { return new KXmlParser(); } - - @Override - public boolean supports(int ideFeature) { - throw new AssertionError(); - } - - @Override - public Object loadView(String name, Class[] constructorSignature, Object[] constructorArgs) - throws Exception { - throw new AssertionError(); - } - - @Override - public String getNamespace() { - throw new AssertionError(); - } - - @Override - @SuppressWarnings("deprecation") - public Pair<ResourceType, String> resolveResourceId(int id) { - throw new AssertionError(); - } - - @Override - public String resolveResourceId(int[] id) { - throw new AssertionError(); - } - - @Override - public Integer getResourceId(ResourceType type, String name) { - throw new AssertionError(); - } - - @Override - @SuppressWarnings("deprecation") - public ILayoutPullParser getParser(String layoutName) { - throw new AssertionError(); - } - - @Override - public ILayoutPullParser getParser(ResourceValue layoutResource) { - throw new AssertionError(); - } - - @Override - public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie, - ResourceReference itemRef, int fullPosition, int positionPerType, - int fullParentPosition, int parentPositionPerType, ResourceReference viewRef, - ViewAttribute viewAttribute, Object defaultValue) { - throw new AssertionError(); - } - - @Override - public AdapterBinding getAdapterBinding(ResourceReference adapterViewRef, - Object adapterCookie, - Object viewObject) { - throw new AssertionError(); - } - - @Override - public ActionBarCallback getActionBarCallback() { - throw new AssertionError(); - } } } |