Bitmap tryLoadBitmap(ImageViewAware imageAware) { Bitmap bitmap = null; try { java.io.File imageFile = diskCache.get(getMessage().get_id()); if (imageFile != null && imageFile.exists() && imageFile.length() > 0) { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageSize imageSize = ImageSizeUtils.defineTargetSizeForView(imageAware, new ImageSize(MainApp.CONTEXT.getResources().getDisplayMetrics().widthPixels, MainApp.CONTEXT.getResources().getDisplayMetrics().heightPixels)); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(getMessage().get_id(), ImageDownloader.Scheme.FILE.wrap(imageFile.getAbsolutePath()), getMessage().get_id(), imageSize, viewScaleType, new BaseImageDownloader(MainApp.CONTEXT), options); bitmap = decoder.decode(decodingInfo); MainApp.memoryCache.put(getMessage().get_id(), bitmap); } } catch (Exception ignored) { ignored.printStackTrace(); } return bitmap; }
@Override public View getView(int i, View convertView, ViewGroup viewGroup) { ViewHolder viewHolder; if (convertView == null || convertView.getTag() == null) { viewHolder = new ViewHolder(); convertView = LayoutInflater.from(context).inflate(FakeR.getId(context, "layout", "item_albumfoler"), null); viewHolder.imageView = (ImageView) convertView.findViewById(FakeR.getId(context, "id", "imageView")); viewHolder.textView = (TextView) convertView.findViewById(FakeR.getId(context, "id", "textview")); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } String name = folderNames.get(i); List<LocalImageHelper.LocalFile> files = folders.get(name); viewHolder.textView.setText(name + "(" + files.size() + ")"); if (files.size() > 0) { ImageLoader.getInstance().displayImage(files.get(0).getThumbnailUri(), new ImageViewAware(viewHolder.imageView), options, null, null, files.get(0).getOrientation()); } return convertView; }
@Override public void load(String path, int defaultRes, ImageView iv, final AbsImageLoader.ImageLoadingListener listener) { if(!TextUtils.isEmpty(path)) { if (!path.equals(iv.getTag())) { iv.setTag(path); ImageAware imageAware = new ImageViewAware(iv, false); ImageLoader.getInstance().displayImage(path, imageAware, getDefaultOptions(false, defaultRes), new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { if(listener!=null){ listener.onSuccess(imageUri, view); } } }); } }else{ iv.setImageResource(defaultRes); } }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new RoundedDrawable(bitmap, cornerRadius, margin)); if ((animateFromNetwork && loadedFrom == LoadedFrom.NETWORK) || (animateFromDisk && loadedFrom == LoadedFrom.DISC_CACHE) || (animateFromMemory && loadedFrom == LoadedFrom.MEMORY_CACHE)) { animate(imageAware.getWrappedView(), durationMillis); } }
public void display(Bitmap bitmap, ImageAware imageaware, LoadedFrom loadedfrom) { if (!(imageaware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } Bitmap bitmap1 = Util.clipToRoundBitmap(bitmap); ImageView imageview = (ImageView)imageaware.getWrappedView(); if (bitmap1 == null || imageview == null) { return; } else { imageview.setBackground(new BitmapDrawable(imageview.getResources(), bitmap1)); return; } }
private boolean drawImageIfCacheHasImage(BitmapInfo bitmapInfo, ImageView imageView, int defaultResource, boolean drawRound){ ImageViewAware imageViewAware = new ImageViewAware(imageView, false); if(urlCacheMap.containsKey(bitmapInfo)){ Bitmap bitmap = urlCacheMap.get(bitmapInfo); if(bitmap.isRecycled() == false){ if(drawRound){ roundDisplayer.display(bitmap, imageViewAware, null); }else{ displayer.display(bitmap, imageViewAware, null); } if(localAnimDoneCache.containsKey(bitmapInfo) == false){ localAnimDoneCache.put(bitmapInfo, true); Animation anim = AnimationUtils.loadAnimation(this, R.anim.oto_fadein); imageView.startAnimation(anim); } }else{ imageView.setImageResource(defaultResource); } return true; } return false; }
public void dataToLayout(){ if(is_my_info){ if(user_info.getImagePath().length() != 0){ String img_path = TASatelite.makeImageUrl(user_info.getImagePath()); image.setImageResource(R.drawable.oto_friend_img_01); OTOApp.getInstance().getImageDownloader().requestImgDownload(img_path, new TAImageDataHandler() { @Override public void onHttpImagePacketReceived(String url, Bitmap bitmap) { roundDisplayer.display(bitmap, new ImageViewAware(image), null); } @Override public void onHttpImageException(Exception ex) { image.setImageResource(R.drawable.oto_friend_img_01); } }); }else{ image.setImageResource(R.drawable.oto_friend_img_01); } prevNickName = user_info.getNickName(); nickName.setText(user_info.getNickName()); introduce.setText(user_info.getIntroduce()); } }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } Bitmap roundedBitmap = roundCorners(bitmap, (ImageViewAware) imageAware, roundPixels); imageAware.setImageBitmap(roundedBitmap); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new RoundedDrawable(bitmap, cornerRadius, margin)); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new RoundedVignetteDrawable(bitmap, cornerRadius, margin)); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new CircleDrawable(bitmap, strokeColor, strokeWidth)); }
@Before public void setUp() throws Exception { mActivity = new Activity(); // Make and set view with some prelim values to test mView = new TestImageView(mActivity); mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY)); mImageAware = new ImageViewAware(mView); }
public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (imageAware instanceof ImageViewAware) { imageAware.setImageDrawable(new RoundedDrawable(bitmap, this.cornerRadius, this.margin)); return; } throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); }
public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (imageAware instanceof ImageViewAware) { imageAware.setImageDrawable(new RoundedVignetteDrawable(bitmap, this.cornerRadius, this.margin)); return; } throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(getImageDrawable(imageAware,bitmap)); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new CircleDrawable(bitmap, margin)); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom, int fileTypeStatus, String filepath) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } Bitmap roundedBitmap = roundCorners(bitmap, (ImageViewAware) imageAware, roundPixels); imageAware.setImageBitmap(roundedBitmap); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom, int fileTypeStatus, String filepath) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new RoundedDrawable(bitmap, cornerRadius, margin)); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom, int fileTypeStatus, String filepath) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new RoundedVignetteDrawable(bitmap, cornerRadius, margin)); }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom, int fileTypeStatus, String filepath) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } imageAware.setImageDrawable(new CircleDrawable(bitmap, strokeColor, strokeWidth)); }
public void displayImage(MQImageView imageView, String path, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final MQDisplayImageListener displayImageListener) { initImageLoader(imageView.getContext()); if (path == null) { path = ""; } if (!(path.startsWith("http") || path.startsWith("file"))) { path = "file://" + path; } String str = path; ImageLoader.getInstance().displayImage(str, new ImageViewAware(imageView), new DisplayImageOptions.Builder().showImageOnLoading(loadingResId).showImageOnFail (failResId).cacheInMemory(true).build(), new ImageSize(width, height), new SimpleImageLoadingListener() { public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { if (displayImageListener != null) { displayImageListener.onSuccess(view, imageUri); } } }, null); }
public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (imageAware instanceof ImageViewAware) { imageAware.setImageDrawable(new RoundedDrawable(bitmap, this.cornerRadius, this .margin)); return; } throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); }
public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (imageAware instanceof ImageViewAware) { imageAware.setImageDrawable(new RoundedVignetteDrawable(bitmap, this.cornerRadius, this.margin)); return; } throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is " + "expected."); }
public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (imageAware instanceof ImageViewAware) { imageAware.setImageDrawable(new CircleDrawable(bitmap, this.strokeColor, this .strokeWidth)); return; } throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); }
@Override public View getView(int position, View view, ViewGroup viewGroup) { ViewHolder holder; if (view == null) { view = View.inflate(mContext, R.layout.fragment_credits_item_list, null); holder = new ViewHolder(view); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } Credit credit = mCredits.get(position); holder.title.setText(credit.getName()); holder.subtitle.setText(credit.getContribution()); holder.container.setOnClickListener(view1 -> { String link = credit.getLink(); if (URLUtil.isValidUrl(link)) { try { mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); } catch (ActivityNotFoundException e) { LogUtil.e(Log.getStackTraceString(e)); } } }); if (credit.getContribution().length() == 0) { holder.subtitle.setVisibility(View.GONE); } else { holder.subtitle.setVisibility(View.VISIBLE); } ImageLoader.getInstance().displayImage(credit.getImage(), new ImageViewAware(holder.image), mOptions.build(), new ImageSize(144, 144), null, null); return view; }
@Override public void onBindViewHolder(ViewHolder holder, int position) { Category category = mCategories.get(position); holder.title.setText(category.getName()); ImageLoader.getInstance().displayImage( category.getThumbUrl(), new ImageViewAware(holder.image), mOptions.build(), ImageConfig.getBigThumbnailSize(), null, null); }
@Override public void onBindViewHolder(ViewHolder holder, int position) { holder.name.setText(mIcons.get(position).getTitle()); ImageLoader.getInstance().displayImage("drawable://" + mIcons.get(position).getRes(), new ImageViewAware(holder.icon), mOptions.build(), new ImageSize(144, 144), null, null); }
@Override public void displayImage(Activity activity, String path, GFImageView imageView, Drawable defaultDrawable, int width, int height) { DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheOnDisk(false) .cacheInMemory(false) .bitmapConfig(mImageConfig) .build(); ImageSize imageSize = new ImageSize(width, height); ImageLoader.getInstance().displayImage("file://" + path, new ImageViewAware(imageView), options, imageSize, null, null); }
@Override public View getView(final int i, View convertView, ViewGroup viewGroup) { ViewHolder viewHolder = new ViewHolder(); if (convertView == null || convertView.getTag() == null) { viewHolder = new ViewHolder(); LayoutInflater inflater = getLayoutInflater(); convertView = inflater.inflate(FakeR.getId(m_context, "layout", "simple_list_item"), null); viewHolder.imageView = (ImageView) convertView.findViewById(FakeR.getId(m_context, "id", "imageView")); viewHolder.checkBox = (CheckBox) convertView.findViewById(FakeR.getId(m_context, "id", "checkbox")); viewHolder.checkBox.setOnCheckedChangeListener(LocalAlbumDetail.this); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } ImageView imageView = viewHolder.imageView; LocalImageHelper.LocalFile localFile = paths.get(i); // FrescoLoader.getInstance().localDisplay(localFile.getThumbnailUri(), imageView, options); ImageLoader.getInstance().displayImage(localFile.getThumbnailUri(), new ImageViewAware(viewHolder.imageView), options, loadingListener, null, localFile.getOrientation()); viewHolder.checkBox.setTag(localFile); viewHolder.checkBox.setChecked(checkedItems.contains(localFile)); viewHolder.imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showViewPager(i); } }); return convertView; }
@Override public void loadAvator(String path, int defaultRes, ImageView iv) { if(!TextUtils.isEmpty(path)) { //解决ListView滚动时重复加载图片 if (!path.equals(iv.getTag())) { iv.setTag(path); ImageAware imageAware = new ImageViewAware(iv, false); ImageLoader.getInstance().displayImage(path, imageAware, getDefaultOptions(true, defaultRes)); } }else{ iv.setImageResource(defaultRes); } }
@Override public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { if (!(imageAware instanceof ImageViewAware)) { throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected."); } Bitmap roundedBitmap = roundCorners(bitmap, (ImageViewAware) imageAware); imageAware.setImageBitmap(roundedBitmap); return; }