use of com.eros.framework.extend.hook.ui.view.HookWXImageView in project WeexErosFramework by bmfe.
the class HookImage method updateProperties.
@Override
public void updateProperties(Map<String, Object> props) {
super.updateProperties(props);
HookWXImageView imageView;
ImmutableDomObject imageDom;
if ((imageDom = getDomObject()) != null && getHostView() instanceof HookWXImageView) {
imageView = (HookWXImageView) getHostView();
BorderDrawable borderDrawable = WXViewUtils.getBorderDrawable(getHostView());
float[] borderRadius;
if (borderDrawable != null) {
RectF borderBox = new RectF(0, 0, WXDomUtils.getContentWidth(imageDom), WXDomUtils.getContentHeight(imageDom));
borderRadius = borderDrawable.getBorderRadius(borderBox);
} else {
borderRadius = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 };
}
imageView.setBorderRadius(borderRadius);
if (imageView.getDrawable() instanceof ImageDrawable) {
ImageDrawable imageDrawable = (ImageDrawable) imageView.getDrawable();
float[] previousRadius = imageDrawable.getCornerRadii();
if (!Arrays.equals(previousRadius, borderRadius)) {
imageDrawable.setCornerRadii(borderRadius);
}
}
readyToRender();
}
}
use of com.eros.framework.extend.hook.ui.view.HookWXImageView in project WeexErosFramework by bmfe.
the class HookImage method collateBorderRadius.
private void collateBorderRadius() {
if (getHostView() instanceof HookWXImageView) {
HookWXImageView hookWXImageView = (HookWXImageView) getHostView();
BorderDrawable borderDrawable = WXViewUtils.getBorderDrawable(hookWXImageView);
if (borderDrawable != null) {
ImmutableDomObject imageDom = getDomObject();
RectF borderBox = new RectF(0, 0, WXDomUtils.getContentWidth(imageDom), WXDomUtils.getContentHeight(imageDom));
float[] borderRadius = borderDrawable.getBorderRadius(borderBox);
hookWXImageView.collateBorderRadius(borderRadius);
}
}
}
use of com.eros.framework.extend.hook.ui.view.HookWXImageView in project WeexErosFramework by bmfe.
the class HookImage method initComponentHostView.
@Override
protected ImageView initComponentHostView(@NonNull Context context) {
HookWXImageView view = new HookWXImageView(context);
view.setScaleType(ScaleType.FIT_XY);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setCropToPadding(true);
}
view.holdComponent(this);
return view;
}
use of com.eros.framework.extend.hook.ui.view.HookWXImageView in project WeexErosFramework by bmfe.
the class DefaultWXImageAdapter method setImage.
@Override
public void setImage(final String url, final ImageView view, WXImageQuality quality, final WXImageStrategy strategy) {
if (view == null || !(view instanceof HookWXImageView))
return;
final String loadUri = url;
if (HookImage.AUTORECYCLE_URL.equals(loadUri)) {
// wximage被回收
view.setImageBitmap(null);
return;
}
final HookWXImageView wxImageView = (HookWXImageView) view;
if (TextUtils.isEmpty(loadUri)) {
// 设置的src为null
wxImageView.setImageBitmap(null);
handleError(wxImageView);
if (strategy != null && strategy.getImageListener() != null) {
strategy.getImageListener().onImageFinish(loadUri, view, true, null);
}
return;
}
wxImageView.hideErrorBitmap();
// set placeHolder
if (isDefaultPlaceHolder(strategy)) {
int[] wh = WXCommonUtil.getComponentWH(wxImageView.getComponent());
wxImageView.showLoading(wh[0], wh[1]);
} else if (isCustomPlaceHolder(strategy)) {
// customer placeHolder
BMHookGlide.load(BMWXApplication.getWXApplication(), strategy.placeHolder).apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)).into(wxImageView);
} else {
// no placeHolder
// 防止复用出现的问题
wxImageView.hideLoading();
}
DefaultImageViewTarget viewTarget = new DefaultImageViewTarget(wxImageView);
viewTarget.setImageLoadListener(new DefaultImageViewTarget.ImageLoadListener() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
if (strategy != null && strategy.getImageListener() != null) {
strategy.getImageListener().onImageFinish(loadUri, wxImageView, true, null);
}
if (isDefaultPlaceHolder(strategy)) {
wxImageView.hideLoading();
}
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
handleError((HookWXImageView) wxImageView);
if (strategy != null && strategy.getImageListener() != null) {
strategy.getImageListener().onImageFinish(loadUri, wxImageView, true, null);
}
if (isDefaultPlaceHolder(strategy)) {
wxImageView.hideLoading();
}
}
});
BMHookGlide.load(BMWXApplication.getWXApplication(), loadUri).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).transforms(new CenterCrop())).into(viewTarget);
}
Aggregations