diff options
author | Andreas Gampe <agampe@google.com> | 2015-03-12 23:10:53 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2015-03-12 23:25:27 -0700 |
commit | d88a9bc821a660bd86056e39fe8189d521b0f860 (patch) | |
tree | a2baa728e17e955228b6d9ee58abede7c7f5bbb1 /tools/layoutlib/bridge/src/android | |
parent | b3fd7e1be658b331cc3e9229aa594fbd1b3d0deb (diff) | |
parent | ef1741d27b19fe63a7d8541b8745e166eb135252 (diff) | |
download | frameworks_base-d88a9bc821a660bd86056e39fe8189d521b0f860.zip frameworks_base-d88a9bc821a660bd86056e39fe8189d521b0f860.tar.gz frameworks_base-d88a9bc821a660bd86056e39fe8189d521b0f860.tar.bz2 |
resolved conflicts for merge of ef1741d2 to master
Change-Id: I5379d5f756695f5176d92249ac6304bffcf95751
Diffstat (limited to 'tools/layoutlib/bridge/src/android')
-rw-r--r-- | tools/layoutlib/bridge/src/android/view/BridgeInflater.java | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tools/layoutlib/bridge/src/android/view/BridgeInflater.java b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java index 7e4ff69..fbd5e2a 100644 --- a/tools/layoutlib/bridge/src/android/view/BridgeInflater.java +++ b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java @@ -22,9 +22,13 @@ import com.android.ide.common.rendering.api.MergeCookie; import com.android.ide.common.rendering.api.ResourceReference; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; +import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.android.BridgeContext; import com.android.layoutlib.bridge.android.BridgeXmlBlockParser; +import com.android.layoutlib.bridge.android.support.RecyclerViewUtil; +import com.android.layoutlib.bridge.android.support.RecyclerViewUtil.LayoutManagerType; import com.android.layoutlib.bridge.impl.ParserFactory; +import com.android.layoutlib.bridge.impl.RenderSessionImpl; import com.android.resources.ResourceType; import com.android.util.Pair; @@ -111,8 +115,7 @@ public final class BridgeInflater extends LayoutInflater { } catch (Exception e) { // Wrap the real exception in a ClassNotFoundException, so that the calling method // can deal with it. - ClassNotFoundException exception = new ClassNotFoundException("onCreateView", e); - throw exception; + throw new ClassNotFoundException("onCreateView", e); } setupViewInContext(view, attrs); @@ -123,7 +126,7 @@ public final class BridgeInflater extends LayoutInflater { @Override public View createViewFromTag(View parent, String name, AttributeSet attrs, boolean inheritContext) { - View view = null; + View view; try { view = super.createViewFromTag(parent, name, attrs, inheritContext); } catch (InflateException e) { @@ -134,7 +137,7 @@ public final class BridgeInflater extends LayoutInflater { // Wrap the real exception in an InflateException so that the calling // method can deal with it. InflateException exception = new InflateException(); - if (e2.getClass().equals(ClassNotFoundException.class) == false) { + if (!e2.getClass().equals(ClassNotFoundException.class)) { exception.initCause(e2); } else { exception.initCause(e); @@ -184,7 +187,7 @@ public final class BridgeInflater extends LayoutInflater { return inflate(bridgeParser, root); } catch (Exception e) { Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, - "Failed to parse file " + f.getAbsolutePath(), e, null /*data*/); + "Failed to parse file " + f.getAbsolutePath(), e, null); return null; } @@ -194,8 +197,7 @@ public final class BridgeInflater extends LayoutInflater { return null; } - private View loadCustomView(String name, AttributeSet attrs) throws ClassNotFoundException, - Exception{ + private View loadCustomView(String name, AttributeSet attrs) throws Exception { if (mProjectCallback != null) { // first get the classname in case it's not the node name if (name.equals("view")) { @@ -227,6 +229,20 @@ public final class BridgeInflater extends LayoutInflater { if (viewKey != null) { bc.addViewKey(view, viewKey); } + if (RenderSessionImpl.isInstanceOf(view, RecyclerViewUtil.CN_RECYCLER_VIEW)) { + String type = attrs.getAttributeValue(BridgeConstants.NS_RESOURCES, + BridgeConstants.ATTR_LAYOUT_MANAGER_TYPE); + if (type != null) { + LayoutManagerType layoutManagerType = LayoutManagerType.getByDisplayName(type); + if (layoutManagerType == null) { + Bridge.getLog().warning(LayoutLog.TAG_UNSUPPORTED, + "LayoutManager (" + type + ") not found, falling back to " + + "LinearLayoutManager", null); + } else { + bc.addCookie(view, layoutManagerType); + } + } + } } } |