public LimitbuyAdapter(Context context, ArrayList<LimitBuyGoods> list) { this.context = context; this.limitbuyList = list; transparentDrawable = new ColorDrawable(Color.TRANSPARENT); inflater = LayoutInflater.from(context); imageLoaderManager = ImageLoaderManager.initImageLoaderManager(context); }
private void asyncLoadImage(LimitBuyGoods limitbuy, ImageView imgview, final ViewGroup parent) { String thumbUrl = limitbuy.getSkuThumbImgUrl(); if (TextUtils.isEmpty(thumbUrl)) return; limitbuy.setLoadImg(true); Bitmap bitmap = imageLoaderManager.getCacheBitmap(limitbuy.getSkuThumbImgUrl()); imgview.setImageBitmap(bitmap); imgview.setTag(thumbUrl); if (bitmap == null) { imageLoaderManager.asyncLoad( new ImageLoadTask(thumbUrl) { private static final long serialVersionUID = -4002124060243995848L; @Override protected Bitmap doInBackground() { return NetUtility.downloadNetworkBitmap(filePath); } @Override public void onImageLoaded(ImageLoadTask task, Bitmap bitmap) { if (bitmap != null) { View tagedView = parent.findViewWithTag(task.filePath); if (tagedView != null) { BitmapDrawable destDrawable = new BitmapDrawable(inflater.getContext().getResources(), bitmap); TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] {transparentDrawable, destDrawable}); ((ImageView) tagedView).setImageDrawable(transitionDrawable); transitionDrawable.startTransition(300); if (transitionDrawable != null) ((ImageView) tagedView) .setBackgroundResource(R.drawable.product_list_grid_item_icon_bg); } } } }); } else { imgview.setBackgroundResource(R.drawable.product_list_grid_item_icon_bg); } }