@Override public void run() { Bitmap bitmap = null; if (width != 0 && height != 0) bitmap = readImage(mImagePath, width, height); else { int[] viewSizes = new int[2]; measureSize(mImageView, viewSizes); bitmap = readImage(mImagePath, viewSizes[0], viewSizes[1]); } addImageToCache(mImagePath + width + height, bitmap); ImgBeanHolder holder = new ImgBeanHolder(); holder.bitmap = getImageFromCache(mImagePath + width + height); holder.imageView = mImageView; holder.imagePath = mImagePath; holder.imageLoadListener = imageLoadListener; getPostHandler().post(holder); }
/** * According to the specified width high loading pictures, wide high, the greater the picture * clearer, more memory * * @param imageView ImageView * @param imagePath Path from local SDCard * @param width Target width * @param height Target height */ public void loadImage( ImageView imageView, String imagePath, int width, int height, ImageLoadListener imageLoadListener) { if (imageLoadListener == null) imageView.setTag(imagePath); Bitmap bitmap = getImageFromCache(imagePath + width + height); if (bitmap != null) { ImgBeanHolder holder = new ImgBeanHolder(); holder.imageView = imageView; holder.imagePath = imagePath; holder.bitmap = bitmap; holder.imageLoadListener = imageLoadListener; getPostHandler().post(holder); } else { imageView.setImageDrawable(mDefaultDrawable); mExecutorService.execute( new TaskThread(imageView, imagePath, width, height, imageLoadListener)); } }