一、ImageLoader使用情况一
image = Image.get(LiveImageUtils.getAvatarUrl(String.valueOf(mRoomData.liveId), mAvartSize), false); if(image != null) { if(null == mAccountTransform){ mAccountTransform = new CircleImageTransform(); } ImageLoader.loadImage(getContext(), mLiveHeadView, image.getFullUrl(), R.drawable.account_avator, mAccountTransform, mImageLoadTag); }else{ ImageLoader.bindImagePlaceHolder(getContext(), mLiveHeadView, R.drawable.account_avator); }
/** * 获取头像地址 * @param avatar * @param size * @return */ public static String getAvatarUrl(String avatar, int size){ StringBuilder sb = new StringBuilder(AVATAR_URL); sb.append(avatar); sb.append(THUMBBAIL_FORMAT); sb.append(getNearSize(size)); return sb.toString(); }
public void onRecycler(){ImageLoader.bindImagePlaceHolder(getContext(), mLiveHeadView, R.drawable.account_avator);}
ImageLoader进行图片空间加载,圆形头像需要使用 getAvatarUrl 方法获取,最后要在onRecycler方法里添加上默认情况时的图片;
二、ImageLoader使用情况二
Image image = Image.get(CdnDomainUrl.RES_TYPE_THUMBNAIL, String.format(Locale.US, "w%dh%d", mHotPicWidth, mHotPicHeight), mRoomData.hotPic); if(image != null ) { mHotTopics.setVisibility(View.VISIBLE); ImageLoader.loadImage(getContext(),mHotTopics, image.getFullUrl(), R.drawable.hot_topics, null, mImageLoadTag, mHotPicWidth, mHotPicHeight); }else{ mHotTopics.setVisibility(View.GONE); }需要具体传入宽和高,从cdnUrl方式加载 ,并且设置 mImageLoadTag属性