下面列出了android.widget.ImageView#setLayerType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean onException(Exception e, T model, Target<PictureDrawable> target, boolean isFirstResource) {
ImageView view = ((ImageViewTarget<?>) target).getView();
if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
}
return false;
}
@Override
public boolean onResourceReady(PictureDrawable resource, T model, Target<PictureDrawable> target,
boolean isFromMemoryCache, boolean isFirstResource) {
ImageView view = ((ImageViewTarget<?>) target).getView();
if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
}
return false;
}
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
boolean isFirstResource) {
ImageView view = ((ImageViewTarget<?>) target).getView();
view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
if (customListener != null) {
customListener.onLoadFailed();
}
return false;
}
@Override
public boolean onResourceReady(PictureDrawable resource, Object model,
Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) {
ImageView view = ((ImageViewTarget<?>) target).getView();
view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
if (customListener != null) {
customListener.onResourceReady();
}
return false;
}
@Override
public boolean onException(Exception e, T model, Target<PictureDrawable> target,
boolean isFirstResource) {
ImageView view = ((ImageViewTarget<?>) target).getView();
if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
}
return false;
}
@Override
public boolean onResourceReady(PictureDrawable resource, T model
, Target<PictureDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
ImageView view = ((ImageViewTarget<?>) target).getView();
if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
}
return false;
}
private void refreshItems() {
if(ABTextUtil.isEmpty(this.items)) {
throw new RuntimeException(this.getClass().getSimpleName() + "[items] can not be empty!");
} else {
this.contentView.removeAllViews();
int i = 0;
for(int size = this.items.size(); i < size; ++i) {
RFACLabelItem item = (RFACLabelItem)this.items.get(i);
View itemView = LayoutInflater.from(this.getContext()).inflate(com.wangjie.rapidfloatingactionbutton.R.layout.rfab__content_label_list_item, (ViewGroup)null);
View rootView = (ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_root_view));
TextView labelTv = (TextView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_label_tv);
ImageView iconIv = (ImageView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_icon_iv);
rootView.setOnClickListener(this);
labelTv.setOnClickListener(this);
iconIv.setOnClickListener(this);
rootView.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
labelTv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
iconIv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
CircleButtonProperties circleButtonProperties = (new CircleButtonProperties()).setStandardSize(RFABSize.MINI).setShadowColor(this.iconShadowColor).setShadowRadius(this.iconShadowRadius).setShadowDx(this.iconShadowDx).setShadowDy(this.iconShadowDy);
int shadowOffsetHalf = circleButtonProperties.getShadowOffsetHalf();
int minPadding = ABTextUtil.dip2px(this.getContext(), 8.0F);
int realItemSize;
if(shadowOffsetHalf < minPadding) {
realItemSize = minPadding - shadowOffsetHalf;
rootView.setPadding(0, realItemSize, 0, realItemSize);
}
realItemSize = circleButtonProperties.getRealSizePx(this.getContext());
android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams)iconIv.getLayoutParams();
if(null == lp) {
lp = new android.widget.LinearLayout.LayoutParams(-2, -2);
}
int rfabRealSize = this.onRapidFloatingActionListener.obtainRFAButton().getRfabProperties().getRealSizePx(this.getContext());
lp.rightMargin = (rfabRealSize - realItemSize) / 2;
lp.width = realItemSize;
lp.height = realItemSize;
iconIv.setLayoutParams(lp);
Integer normalColor = item.getIconNormalColor();
Integer pressedColor = item.getIconPressedColor();
CircleButtonDrawable rfacNormalDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == normalColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_normal):normalColor.intValue());
CircleButtonDrawable rfacPressedDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == pressedColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_pressed):pressedColor.intValue());
if(Build.VERSION.SDK_INT > 11) {
iconIv.setLayerType(1, rfacNormalDrawable.getPaint());
}
ABViewUtil.setBackgroundDrawable(iconIv, ABShape.selectorClickSimple(rfacNormalDrawable, rfacPressedDrawable));
int padding = ABTextUtil.dip2px(this.getContext(), 8.0F) + shadowOffsetHalf;
iconIv.setPadding(padding, padding, padding, padding);
String label = item.getLabel();
if(ABTextUtil.isEmpty(label)) {
labelTv.setVisibility(GONE);
} else {
if(item.isLabelTextBold()) {
labelTv.getPaint().setFakeBoldText(true);
}
labelTv.setVisibility(VISIBLE);
labelTv.setText(label);
Drawable resId = item.getLabelBackgroundDrawable();
if(null != resId) {
ABViewUtil.setBackgroundDrawable(labelTv, resId);
}
Integer drawable = item.getLabelColor();
if(null != drawable) {
labelTv.setTextColor(drawable.intValue());
}
Integer labelSize = item.getLabelSizeSp();
if(null != labelSize) {
labelTv.setTextSize(2, (float)labelSize.intValue());
}
}
Drawable var23 = item.getDrawable();
if(null != var23) {
iconIv.setVisibility(VISIBLE);
var23.setBounds(0, 0, this.rfacItemDrawableSizePx, this.rfacItemDrawableSizePx);
iconIv.setImageDrawable(var23);
} else {
int var24;
if((var24 = item.getResId()) > 0) {
iconIv.setVisibility(VISIBLE);
iconIv.setImageDrawable(ABImageProcess.getResourceDrawableBounded(this.getContext(), var24, this.rfacItemDrawableSizePx));
} else {
iconIv.setVisibility(GONE);
}
}
this.contentView.addView(itemView);
}
}
}
public Holder(View view) {
imageView = (ImageView) view.findViewById(R.id.image1);
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
textView = (TextView) view.findViewById(R.id.text1);
}