Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java +4 −4 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class BridgeRenderSession extends RenderSession { @Override public Result insertChild(Object parentView, ILayoutPullParser childXml, int index, IAnimationListener listener) { if (parentView instanceof ViewGroup == false) { if (!(parentView instanceof ViewGroup)) { throw new IllegalArgumentException("parentView is not a ViewGroup"); } Loading @@ -155,10 +155,10 @@ public class BridgeRenderSession extends RenderSession { @Override public Result moveChild(Object parentView, Object childView, int index, Map<String, String> layoutParams, IAnimationListener listener) { if (parentView instanceof ViewGroup == false) { if (!(parentView instanceof ViewGroup)) { throw new IllegalArgumentException("parentView is not a ViewGroup"); } if (childView instanceof View == false) { if (!(childView instanceof View)) { throw new IllegalArgumentException("childView is not a View"); } Loading @@ -179,7 +179,7 @@ public class BridgeRenderSession extends RenderSession { @Override public Result removeChild(Object childView, IAnimationListener listener) { if (childView instanceof View == false) { if (!(childView instanceof View)) { throw new IllegalArgumentException("childView is not a View"); } Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/MockView.java +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class MockView extends FrameLayout { mView.setText(text); } public void setGravity(int gravity) { private void setGravity(int gravity) { mView.setGravity(gravity); } } tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java +2 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,7 @@ class Layout extends RelativeLayout { return Bridge.getResourceId(ResourceType.ID, ID_PREFIX + name); } @SuppressWarnings("deprecation") @Override public void requestFitSystemWindows() { // The framework call would usually bubble up to ViewRootImpl but, in layoutlib, Layout will Loading Loading @@ -416,6 +417,7 @@ class Layout extends RelativeLayout { } } @SuppressWarnings("SameParameterValue") private int getDimension(String attr, boolean isFramework, int defaultValue) { ResourceValue value = mResources.findItemInTheme(attr, isFramework); value = mResources.resolveResValue(value); Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +16 −17 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { private static final class PostInflateException extends Exception { private static final long serialVersionUID = 1L; public PostInflateException(String message) { private PostInflateException(String message) { super(message); } } Loading Loading @@ -242,11 +242,13 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // Then measure only the content with UNSPECIFIED to see the size difference // and apply this to the screen size. View measuredView = mContentRoot.getChildAt(0); // first measure the full layout, with EXACTLY to get the size of the // content as it is inside the decor/dialog @SuppressWarnings("deprecation") Pair<Integer, Integer> exactMeasure = measureView( mViewRoot, mContentRoot.getChildAt(0), mViewRoot, measuredView, mMeasuredScreenWidth, MeasureSpec.EXACTLY, mMeasuredScreenHeight, MeasureSpec.EXACTLY); Loading @@ -258,6 +260,10 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { mMeasuredScreenWidth, widthMeasureSpecMode, mMeasuredScreenHeight, heightMeasureSpecMode); // If measuredView is not null, exactMeasure nor result will be null. assert exactMeasure != null; assert result != null; // now look at the difference and add what is needed. if (renderingMode.isHorizExpand()) { int measuredWidth = exactMeasure.getFirst(); Loading Loading @@ -406,8 +412,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * @param canvas an optional canvas to render the views to. If null, only the measure and * layout steps will be executed. */ private static Result renderAndBuildResult(@NonNull BridgeContext context, @NonNull ViewGroup viewRoot, @Nullable Canvas canvas, int width, int height) { private static Result renderAndBuildResult(@NonNull ViewGroup viewRoot, @Nullable Canvas canvas) { if (canvas == null) { return SUCCESS.createResult(); } Loading Loading @@ -551,7 +556,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { long initialTime = System_Delegate.nanoTime(); if (!mFirstFrameExecuted) { // We need to run an initial draw call to initialize the animations renderAndBuildResult(getContext(), mViewRoot, NOP_CANVAS, mMeasuredScreenWidth, mMeasuredScreenHeight); renderAndBuildResult(mViewRoot, NOP_CANVAS); // The first frame will initialize the animations Choreographer_Delegate.doFrame(initialTime); Loading @@ -560,8 +565,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // Second frame will move the animations Choreographer_Delegate.doFrame(initialTime + mElapsedFrameTimeNanos); } renderResult = renderAndBuildResult(getContext(), mViewRoot, mCanvas, mMeasuredScreenWidth, mMeasuredScreenHeight); renderResult = renderAndBuildResult(mViewRoot, mCanvas); } mSystemViewInfoList = Loading Loading @@ -1206,7 +1210,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * Sets up a {@link TabHost} object. * @param tabHost the TabHost to setup. * @param layoutlibCallback The project callback object to access the project R class. * @throws PostInflateException * @throws PostInflateException if TabHost is missing the required ids for TabHost */ private void setupTabHost(TabHost tabHost, LayoutlibCallback layoutlibCallback) throws PostInflateException { Loading Loading @@ -1254,12 +1258,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { TabSpec spec = tabHost.newTabSpec("tag") .setIndicator("Tab Label", tabHost.getResources() .getDrawable(android.R.drawable.ic_menu_info_details, null)) .setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String tag) { return new LinearLayout(getContext()); } }); .setContent(tag -> new LinearLayout(getContext())); tabHost.addTab(spec); } else { // for each child of the frameLayout, add a new TabSpec Loading Loading @@ -1333,8 +1332,8 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { int childCount = viewGroup.getChildCount(); if (viewGroup == mContentRoot) { List<ViewInfo> childrenWithoutOffset = new ArrayList<ViewInfo>(childCount); List<ViewInfo> childrenWithOffset = new ArrayList<ViewInfo>(childCount); List<ViewInfo> childrenWithoutOffset = new ArrayList<>(childCount); List<ViewInfo> childrenWithOffset = new ArrayList<>(childCount); for (int i = 0; i < childCount; i++) { ViewInfo[] childViewInfo = visitContentRoot(viewGroup.getChildAt(i), hOffset, vOffset, Loading @@ -1345,7 +1344,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { mViewInfoList = childrenWithOffset; return childrenWithoutOffset; } else { List<ViewInfo> children = new ArrayList<ViewInfo>(childCount); List<ViewInfo> children = new ArrayList<>(childCount); for (int i = 0; i < childCount; i++) { children.add(visit(viewGroup.getChildAt(i), hOffset, vOffset, setExtendedInfo, isContentFrame)); Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/NinePatchInputStream.java +2 −5 Original line number Diff line number Diff line Loading @@ -34,12 +34,9 @@ public class NinePatchInputStream extends FileInputStream { @Override public boolean markSupported() { if (mFakeMarkSupport) { // this is needed so that BitmapFactory doesn't wrap this in a BufferedInputStream. return true; } return mFakeMarkSupport || super.markSupported(); return super.markSupported(); } public void disableFakeMarkSupport() { Loading Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java +4 −4 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class BridgeRenderSession extends RenderSession { @Override public Result insertChild(Object parentView, ILayoutPullParser childXml, int index, IAnimationListener listener) { if (parentView instanceof ViewGroup == false) { if (!(parentView instanceof ViewGroup)) { throw new IllegalArgumentException("parentView is not a ViewGroup"); } Loading @@ -155,10 +155,10 @@ public class BridgeRenderSession extends RenderSession { @Override public Result moveChild(Object parentView, Object childView, int index, Map<String, String> layoutParams, IAnimationListener listener) { if (parentView instanceof ViewGroup == false) { if (!(parentView instanceof ViewGroup)) { throw new IllegalArgumentException("parentView is not a ViewGroup"); } if (childView instanceof View == false) { if (!(childView instanceof View)) { throw new IllegalArgumentException("childView is not a View"); } Loading @@ -179,7 +179,7 @@ public class BridgeRenderSession extends RenderSession { @Override public Result removeChild(Object childView, IAnimationListener listener) { if (childView instanceof View == false) { if (!(childView instanceof View)) { throw new IllegalArgumentException("childView is not a View"); } Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/MockView.java +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class MockView extends FrameLayout { mView.setText(text); } public void setGravity(int gravity) { private void setGravity(int gravity) { mView.setGravity(gravity); } }
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java +2 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,7 @@ class Layout extends RelativeLayout { return Bridge.getResourceId(ResourceType.ID, ID_PREFIX + name); } @SuppressWarnings("deprecation") @Override public void requestFitSystemWindows() { // The framework call would usually bubble up to ViewRootImpl but, in layoutlib, Layout will Loading Loading @@ -416,6 +417,7 @@ class Layout extends RelativeLayout { } } @SuppressWarnings("SameParameterValue") private int getDimension(String attr, boolean isFramework, int defaultValue) { ResourceValue value = mResources.findItemInTheme(attr, isFramework); value = mResources.resolveResValue(value); Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +16 −17 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { private static final class PostInflateException extends Exception { private static final long serialVersionUID = 1L; public PostInflateException(String message) { private PostInflateException(String message) { super(message); } } Loading Loading @@ -242,11 +242,13 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // Then measure only the content with UNSPECIFIED to see the size difference // and apply this to the screen size. View measuredView = mContentRoot.getChildAt(0); // first measure the full layout, with EXACTLY to get the size of the // content as it is inside the decor/dialog @SuppressWarnings("deprecation") Pair<Integer, Integer> exactMeasure = measureView( mViewRoot, mContentRoot.getChildAt(0), mViewRoot, measuredView, mMeasuredScreenWidth, MeasureSpec.EXACTLY, mMeasuredScreenHeight, MeasureSpec.EXACTLY); Loading @@ -258,6 +260,10 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { mMeasuredScreenWidth, widthMeasureSpecMode, mMeasuredScreenHeight, heightMeasureSpecMode); // If measuredView is not null, exactMeasure nor result will be null. assert exactMeasure != null; assert result != null; // now look at the difference and add what is needed. if (renderingMode.isHorizExpand()) { int measuredWidth = exactMeasure.getFirst(); Loading Loading @@ -406,8 +412,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * @param canvas an optional canvas to render the views to. If null, only the measure and * layout steps will be executed. */ private static Result renderAndBuildResult(@NonNull BridgeContext context, @NonNull ViewGroup viewRoot, @Nullable Canvas canvas, int width, int height) { private static Result renderAndBuildResult(@NonNull ViewGroup viewRoot, @Nullable Canvas canvas) { if (canvas == null) { return SUCCESS.createResult(); } Loading Loading @@ -551,7 +556,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { long initialTime = System_Delegate.nanoTime(); if (!mFirstFrameExecuted) { // We need to run an initial draw call to initialize the animations renderAndBuildResult(getContext(), mViewRoot, NOP_CANVAS, mMeasuredScreenWidth, mMeasuredScreenHeight); renderAndBuildResult(mViewRoot, NOP_CANVAS); // The first frame will initialize the animations Choreographer_Delegate.doFrame(initialTime); Loading @@ -560,8 +565,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // Second frame will move the animations Choreographer_Delegate.doFrame(initialTime + mElapsedFrameTimeNanos); } renderResult = renderAndBuildResult(getContext(), mViewRoot, mCanvas, mMeasuredScreenWidth, mMeasuredScreenHeight); renderResult = renderAndBuildResult(mViewRoot, mCanvas); } mSystemViewInfoList = Loading Loading @@ -1206,7 +1210,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * Sets up a {@link TabHost} object. * @param tabHost the TabHost to setup. * @param layoutlibCallback The project callback object to access the project R class. * @throws PostInflateException * @throws PostInflateException if TabHost is missing the required ids for TabHost */ private void setupTabHost(TabHost tabHost, LayoutlibCallback layoutlibCallback) throws PostInflateException { Loading Loading @@ -1254,12 +1258,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { TabSpec spec = tabHost.newTabSpec("tag") .setIndicator("Tab Label", tabHost.getResources() .getDrawable(android.R.drawable.ic_menu_info_details, null)) .setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String tag) { return new LinearLayout(getContext()); } }); .setContent(tag -> new LinearLayout(getContext())); tabHost.addTab(spec); } else { // for each child of the frameLayout, add a new TabSpec Loading Loading @@ -1333,8 +1332,8 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { int childCount = viewGroup.getChildCount(); if (viewGroup == mContentRoot) { List<ViewInfo> childrenWithoutOffset = new ArrayList<ViewInfo>(childCount); List<ViewInfo> childrenWithOffset = new ArrayList<ViewInfo>(childCount); List<ViewInfo> childrenWithoutOffset = new ArrayList<>(childCount); List<ViewInfo> childrenWithOffset = new ArrayList<>(childCount); for (int i = 0; i < childCount; i++) { ViewInfo[] childViewInfo = visitContentRoot(viewGroup.getChildAt(i), hOffset, vOffset, Loading @@ -1345,7 +1344,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { mViewInfoList = childrenWithOffset; return childrenWithoutOffset; } else { List<ViewInfo> children = new ArrayList<ViewInfo>(childCount); List<ViewInfo> children = new ArrayList<>(childCount); for (int i = 0; i < childCount; i++) { children.add(visit(viewGroup.getChildAt(i), hOffset, vOffset, setExtendedInfo, isContentFrame)); Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/NinePatchInputStream.java +2 −5 Original line number Diff line number Diff line Loading @@ -34,12 +34,9 @@ public class NinePatchInputStream extends FileInputStream { @Override public boolean markSupported() { if (mFakeMarkSupport) { // this is needed so that BitmapFactory doesn't wrap this in a BufferedInputStream. return true; } return mFakeMarkSupport || super.markSupported(); return super.markSupported(); } public void disableFakeMarkSupport() { Loading