@Override protected Bitmap doInBackground(Void... params) { if (imageView == null || url == null) { return bitmap; } if (Logger.isDebug()) Log.i(LOG_TAG, "Get Header image from remote!"); try { Bitmap newBitmap = ImageUtil.getBitmapByUrl(url); /** 加入cache中* */ if (newBitmap != null) { // 生成mini图 Bitmap scaleBitmap = ImageUtil.scaleBitmapTo(newBitmap, SheJiaoMaoApplication.getSmallAvatarSize()); Bitmap roundBitmap = ImageUtil.getRoundedCornerBitmap(scaleBitmap); if (scaleBitmap != newBitmap) { scaleBitmap.recycle(); } CachedImage resultWrap = new CachedImage(roundBitmap); if (isMini) { bitmap = roundBitmap; } imageInfo.setCacheType(CachedImageKey.IMAGE_HEAD_MINI); imageCache.put(imageInfo, resultWrap); // 生成normal图 scaleBitmap = ImageUtil.scaleBitmapTo(newBitmap, SheJiaoMaoApplication.getNormalAvatarSize()); roundBitmap = ImageUtil.getRoundedCornerBitmap(scaleBitmap); scaleBitmap.recycle(); resultWrap = new CachedImage(roundBitmap); imageInfo.setCacheType(CachedImageKey.IMAGE_HEAD_NORMAL); imageCache.put(imageInfo, resultWrap); newBitmap.recycle(); if (!isMini) { bitmap = roundBitmap; } } } catch (LibException e) { if (Logger.isDebug()) Log.e(LOG_TAG, e.getMessage(), e); } return bitmap; }