@Test public void testSetProperty() throws Exception { ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); mWXImage.mHost = imageView; mWXImage.setProperty(Constants.Name.RESIZE_MODE, "cover"); ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType(); assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP); }
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.RESIZE_MODE: String resizeMode = WXUtils.getString(param, null); if (resizeMode != null) { setResizeMode(resizeMode); } return true; case Constants.Name.RESIZE: String resize = WXUtils.getString(param, null); if (resize != null) { setResize(resize); } return true; case Constants.Name.SRC: String src = WXUtils.getString(param, null); if (src != null) { setSrc(src); } return true; case Constants.Name.IMAGE_QUALITY: return true; case Constants.Name.AUTO_RECYCLE: mAutoRecycle = WXUtils.getBoolean(param, mAutoRecycle); return true; case Constants.Name.FILTER: int blurRadius = 0; if (param != null && param instanceof String) { blurRadius = parseBlurRadius((String)param); } if (!TextUtils.isEmpty(this.mSrc)) { setBlurRadius(this.mSrc, blurRadius); } return true; default: return super.setProperty(key, param); } }
WXImage extends WXComponent<ImageView> { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.RESIZE_MODE: String resizeMode = WXUtils.getString(param, null); if (resizeMode != null) { setResizeMode(resizeMode); } return true; case Constants.Name.RESIZE: String resize = WXUtils.getString(param, null); if (resize != null) { setResize(resize); } return true; case Constants.Name.SRC: String src = WXUtils.getString(param, null); if (src != null) { setSrc(src); } return true; case Constants.Name.IMAGE_QUALITY: return true; case Constants.Name.AUTO_RECYCLE: mAutoRecycle = WXUtils.getBoolean(param, mAutoRecycle); return true; case Constants.Name.FILTER: int blurRadius = 0; if (param != null && param instanceof String) { blurRadius = parseBlurRadius((String)param); } if (!TextUtils.isEmpty(this.mSrc)) { setBlurRadius(this.mSrc, blurRadius); } return true; default: return super.setProperty(key, param); } } }
WXImage extends WXComponent<ImageView> { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.RESIZE_MODE: String resizeMode = WXUtils.getString(param, null); if (resizeMode != null) { setResizeMode(resizeMode); } return true; case Constants.Name.RESIZE: String resize = WXUtils.getString(param, null); if (resize != null) { setResize(resize); } return true; case Constants.Name.SRC: String src = WXUtils.getString(param, null); if (src != null) { setSrc(src); } return true; case Constants.Name.IMAGE_QUALITY: return true; case Constants.Name.AUTO_RECYCLE: mAutoRecycle = WXUtils.getBoolean(param, mAutoRecycle); return true; case Constants.Name.FILTER: int blurRadius = 0; if (param != null && param instanceof String) { blurRadius = parseBlurRadius((String)param); } if (!TextUtils.isEmpty(this.mSrc)) { setBlurRadius(this.mSrc, blurRadius); } return true; default: return super.setProperty(key, param); } } @Deprecated  WXImage(WXSDKInstance instance, WXVContainer parent, String instanceId, boolean isLazy, BasicComponentData basicComponentData);  WXImage(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData); }
WXImage extends WXComponent<ImageView> { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.RESIZE_MODE: String resizeMode = WXUtils.getString(param, null); if (resizeMode != null) { setResizeMode(resizeMode); } return true; case Constants.Name.RESIZE: String resize = WXUtils.getString(param, null); if (resize != null) { setResize(resize); } return true; case Constants.Name.SRC: String src = WXUtils.getString(param, null); if (src != null) { setSrc(src); } return true; case Constants.Name.IMAGE_QUALITY: return true; case Constants.Name.AUTO_RECYCLE: mAutoRecycle = WXUtils.getBoolean(param, mAutoRecycle); return true; case Constants.Name.FILTER: int blurRadius = 0; if (param != null && param instanceof String) { blurRadius = parseBlurRadius((String)param); } if (!TextUtils.isEmpty(this.mSrc)) { setBlurRadius(this.mSrc, blurRadius); } return true; default: return super.setProperty(key, param); } } @Deprecated  WXImage(WXSDKInstance instance, WXVContainer parent, String instanceId, boolean isLazy, BasicComponentData basicComponentData);  WXImage(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData); @Override void refreshData(WXComponent component); @WXComponentProp(name = Constants.Name.RESIZE_MODE) void setResizeMode(String resizeMode); @WXComponentProp(name = Constants.Name.RESIZE) void setResize(String resize); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); @Override void recycled(); void autoReleaseImage(); void autoRecoverImage(); @Override void updateProperties(Map<String, Object> props); @JSMethod(uiThread = false) void save(final JSCallback saveStatuCallback); @Override void destroy(); }
WXImage extends WXComponent<ImageView> { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.RESIZE_MODE: String resizeMode = WXUtils.getString(param, null); if (resizeMode != null) { setResizeMode(resizeMode); } return true; case Constants.Name.RESIZE: String resize = WXUtils.getString(param, null); if (resize != null) { setResize(resize); } return true; case Constants.Name.SRC: String src = WXUtils.getString(param, null); if (src != null) { setSrc(src); } return true; case Constants.Name.IMAGE_QUALITY: return true; case Constants.Name.AUTO_RECYCLE: mAutoRecycle = WXUtils.getBoolean(param, mAutoRecycle); return true; case Constants.Name.FILTER: int blurRadius = 0; if (param != null && param instanceof String) { blurRadius = parseBlurRadius((String)param); } if (!TextUtils.isEmpty(this.mSrc)) { setBlurRadius(this.mSrc, blurRadius); } return true; default: return super.setProperty(key, param); } } @Deprecated  WXImage(WXSDKInstance instance, WXVContainer parent, String instanceId, boolean isLazy, BasicComponentData basicComponentData);  WXImage(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData); @Override void refreshData(WXComponent component); @WXComponentProp(name = Constants.Name.RESIZE_MODE) void setResizeMode(String resizeMode); @WXComponentProp(name = Constants.Name.RESIZE) void setResize(String resize); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); @Override void recycled(); void autoReleaseImage(); void autoRecoverImage(); @Override void updateProperties(Map<String, Object> props); @JSMethod(uiThread = false) void save(final JSCallback saveStatuCallback); @Override void destroy(); static final String SUCCEED; static final String ERRORDESC; }