WXSDKInstance implements IWXActivityStateListener { public void setSize(int width, int height) { if (width < 0 || height < 0) { return; } mGodViewWidth = width; mGodViewHeight = height; float realWidth = WXViewUtils.getWebPxByWidth(width); float realHeight = WXViewUtils.getWebPxByWidth(height); View godView = mGodCom.getHostView(); if (godView != null) { ViewGroup.LayoutParams layoutParams = godView.getLayoutParams(); if (layoutParams != null) { layoutParams.width = width; layoutParams.height = height; godView.setLayoutParams(layoutParams); JSONObject style = new JSONObject(); if (mGodCom instanceof WXVContainer) { WXComponent rootComponent = ((WXVContainer) mGodCom).getChild(0); if (rootComponent != null && rootComponent.getDomObject() != null && rootComponent.getDomObject().isModifyHeight()) { style.put(Constants.Name.HEIGHT, realHeight); } if (rootComponent != null && rootComponent.getDomObject() != null && rootComponent.getDomObject().isModifyWidth()) { style.put(Constants.Name.WIDTH, realWidth); } updateRootComponentStyle(style); } } } } WXSDKInstance(Context context); WXComponent getGodCom(); WXComponent getRootCom(); void setNestedInstanceInterceptor(NestedInstanceInterceptor interceptor); WXSDKInstance createNestedInstance(NestedContainer container); void addOnInstanceVisibleListener(OnInstanceVisibleListener l); void removeOnInstanceVisibleListener(OnInstanceVisibleListener l); void init(Context context); void setBizType(String bizType); ScrollView getScrollView(); void setRootScrollView(ScrollView scrollView); @Deprecated void registerScrollViewListener(WXScrollViewListener scrollViewListener); @Deprecated WXScrollViewListener getScrollViewListener(); @Deprecated void setIWXUserTrackAdapter(IWXUserTrackAdapter adapter); void render(String template, Map<String, Object> options, String jsonInitData); void render(String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag); void render(String pageName, String template, Map<String, Object> options, String jsonInitData, int width, int height, WXRenderStrategy flag); void render(String template, int width, int height); void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final int width, final int height, final WXRenderStrategy flag); void refreshInstance(Map<String, Object> data); void refreshInstance(String jsonData); WXRenderStrategy getRenderStrategy(); String getInstanceId(); Context getContext(); int getWeexHeight(); int getWeexWidth(); IWXImgLoaderAdapter getImgLoaderAdapter(); @Deprecated void setImgLoaderAdapter(IWXImgLoaderAdapter adapter); IWXHttpAdapter getWXHttpAdapter(); void reloadImages(); void registerRenderListener(IWXRenderListener listener); void registerActivityStateListener(IWXActivityStateListener listener); @Override void onActivityCreate(); @Override void onActivityStart(); @Override void onActivityPause(); void onViewDisappear(); void onViewAppear(); @Override void onActivityResume(); @Override void onActivityStop(); @Override void onActivityDestroy(); @Override boolean onActivityBack(); void onViewCreated(final WXComponent component); void onUpdateFinish(); void runOnUiThread(Runnable action); void onRenderSuccess(final int width, final int height); void onRefreshSuccess(final int width, final int height); void onRenderError(final String errCode, final String msg); void onJSException(final String errCode, final String function, final String exception); void firstScreenCreateInstanceTime(long time); void callNativeTime(long time); void jsonParseTime(long time); void firstScreenRenderFinished(); void batchTime(long time); void cssLayoutTime(long time); void applyUpdateTime(long time); void updateDomObjTime(long time); void createInstanceFinished(long time); void commitUTStab(final String type, final WXErrorCode errorCode); synchronized void destroy(); boolean isDestroy(); String getBundleUrl(); ViewGroup getRootView(); void setRootView(ViewGroup rootView); synchronized List<OnWXScrollListener> getWXScrollListeners(); synchronized void registerOnWXScrollListener(OnWXScrollListener wxScrollListener); float getRefreshMargin(); void setRefreshMargin(float refreshMargin); void setSize(int width, int height); void fireGlobalEventCallback(String eventName, Map<String,Object> params); void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEvent(String elementRef,final String type, final Map<String, Object> data); void fireEvent(String ref, String type); public boolean mEnd; static final String BUNDLE_URL; }
@Test public void testSetSize() throws Exception { setupRoot(mInstance); mInstance.setSize(10,10); }