.load(imageFile) .placeholder(R.drawable.mis_default_error) .tag(MultiImageSelectorFragment.TAG) .resize(mGridWidth, mGridWidth) .centerCrop()
/** * 固定大小的缩略图 加载本地图片 有标记,适用于列表显示 * * @param path * @param imageView * @param tag */ public void onLocadThumbnail(Context context, String path, ImageView imageView, Object tag) { if (!TextUtils.isEmpty(path) && null != imageView) { Picasso.with(context).load(new File(path)).tag(tag).transform(new Thumformation()).config(Config.RGB_565).placeholder(load_image).error(load_error).into(imageView); } }
/** * 设置圆形头像 使用列表 * * @param path 图片路径 * @param imageView 显示控件 * @param tag 标记 */ public void onLocadRoundnessImage(Context context, String path, ImageView imageView, Object tag) { if (!TextUtils.isEmpty(path) && null != imageView) { Picasso.with(context).load(new File(path)).tag(tag).transform(new RoundnessFormation()).config(Config.RGB_565).placeholder(load_image).error(load_error).into(imageView); } }
/** * 设置圆形头像 使用列表 * * @param path 图片路径 * @param imageView 显示控件 * @param tag 标记 */ public void onRoundnessImage(Context context, String path, ImageView imageView, Object tag) { if (!TextUtils.isEmpty(path) && null != imageView) { Picasso.with(context).load(path).tag(tag).transform(new RoundnessFormation()).config(Config.RGB_565).placeholder(load_image).error(load_error).into(imageView); } }
/** * 固定大小的缩略图 设置显示缩略图 没有带标记 使用于显示列表图片 * * @param path 图片的下载路径 * @param imageView 实现图片的控件 * @param tag 标记 */ public void onThumbnail(Context context, String path, ImageView imageView, Object tag) { if (!TextUtils.isEmpty(path) && null != imageView) { Picasso.with(context).load(path).tag(tag).transform(new Thumformation()).config(Config.RGB_565).placeholder(load_image).error(load_error).into(imageView); } }
/** * 根据图片控件大小压缩图片, 适用于列表显示 * * @param path 图片路径 * @param imageView 显示控件 * @param tag 标记 */ public void onWidgetImage(Context context, String path, ImageView imageView, Object tag) { if (!TextUtils.isEmpty(path) && null != imageView) { Picasso.with(context).load(path).tag(tag).transform(new Widgetformation(imageView)).config(Config.RGB_565).placeholder(load_image).error(load_error).into(imageView); } }
/** * 加载本地图片 * <p/> * 根据图片控件大小压缩图片, 适用于列表显示 * * @param path 图片路径 * @param imageView 显示控件 * @param tag 标记 */ public void onLocadWidgetImage(Context context, String path, ImageView imageView, Object tag) { if (!TextUtils.isEmpty(path) && null != imageView) { Picasso.with(context).load(new File(path)).tag(tag).transform(new Widgetformation(imageView)).config(Config.RGB_565).placeholder(load_image).error(load_error).into(imageView); } }
/** * Will download an image from a URL and put it in an ImageView.<br/> * It uses Square's Picasso library to download the image asynchronously and put the result into the ImageView.<br/> * Picasso manages recycling of views in a ListView.<br/> * If you need more control over the Picasso settings, use {BaseAdapterHelper#setImageBuilder}. * * @param viewId The view id. * @param imageUrl The image URL. * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper setImageUrl(int viewId, String imageUrl) { ImageView view = retrieveView(viewId); Picasso.with(context).load(getURLWithSize(imageUrl)) .placeholder(R.drawable.default_image) .error(R.drawable.default_image) .tag(context) .into(view); return this; }
/** * load the network images * * @param pictureIndex index */ private void loadNetImage(int pictureIndex) { if (list != null && list.size() != 0) { Picasso.with(context) .load((String) list.get(pictureIndex)) .placeholder(defaultImage) .error(errorImage) .tag(context) .into(mTarget); } }
static void attachToImage(final ImageView imageView, final String url, final Drawable placeHolder, final Transformation transformation, final Target target, final Callback callback) { if (imageView == null) { return; } final RequestCreator creator = attach(imageView.getContext(), url, placeHolder); if (creator == null) { return; } if (transformation != null) { creator.transform(transformation); } if (target != null) { creator.tag(target); } try { creator.into(imageView, callback); } catch (Throwable e) { e.printStackTrace(); } }
.load(imageFile) .placeholder(R.drawable.default_error) .tag(MultiImageSelectorFragment.TAG) .resize(mGridWidth, mGridWidth) .centerCrop()
.load(imageFile) .placeholder(R.drawable.oklib_default_error) .tag(MultiImageSelectorFragment.TAG) .resize(mGridWidth, mGridWidth) .centerCrop()
@BindingAdapter({"compressImageUrl"}) public static void loadImageCompress(ImageView imageView, String url) { //large -> b middle // Picasso.Builder builder = new Picasso.Builder(imageView.getContext().getApplicationContext()); // builder.listener(new Picasso.Listener() { // @Override // public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) { // exception.printStackTrace(); // Log.e("Picasso Error", uri.toString()); // } // }); //recycle bitmap // Drawable drawable = imageView.getDrawable(); // if (drawable instanceof BitmapDrawable) { // imageView.setImageDrawable(null); // Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); // Log.d(TAG, "recycle bitmap, w:" + bitmap.getWidth() + ", h:" + bitmap.getHeight()); // bitmap.recycle(); // } Picasso.with(imageView.getContext().getApplicationContext()) .load(url) .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) .placeholder(R.drawable.ic_image_load_place_holder) .config(Bitmap.Config.RGB_565) .tag(PicassoOnScrollListener.TAG) .into(imageView); }
@Override public void onBindViewHolder(ClickableViewHolder holder, int position) { // Android ,瞎推荐, 拓展资源 都是图片,加描述。 if(fragmentType!=FragmentType.Xiuxishipin) { ArticleAndGirlViewHolder mHolder = (ArticleAndGirlViewHolder) holder; AllResult.Results article = articleData.get(position); int girlSize=Girls.size(); AllResult.Results mezhi = position<girlSize ?Girls.get(position) : Girls.get((int)Math.random()*girlSize); mHolder.time.setText(article.getCreatedAt().substring(0, 10)); mHolder.desc.setText(article.getDesc()); String url = mezhi.getUrl(); // Trigger the download of the URL asynchronously into the image view. Picasso.with(mContext) .load(url) .placeholder(R.drawable.placeholder) .error(R.drawable.error) .fit() .centerCrop() .tag(mHolder.imageView.getContext()) .into(mHolder.imageView); }else{ //休息视频,只有文字描述。 ArticleAndGirlViewHolder mHolder = (ArticleAndGirlViewHolder) holder; AllResult.Results article = articleData.get(position); mHolder.itemView.setTag(article.getUrl()); mHolder.desc.setText(article.getDesc()); } }
@Override public void bindCellHolder(final CellHolder cellHolder, final Location location, Message message, CellHolderSpecs specs) { cellHolder.mImageView.setTag(location); cellHolder.mImageView.setOnClickListener(this); // Google Static Map API has max dimension 640 int mapWidth = Math.min(640, specs.maxWidth); int mapHeight = (int) Math.round((double) mapWidth / GOLDEN_RATIO); int[] cellDims = Util.scaleDownInside(specs.maxWidth, (int) Math.round((double) specs.maxWidth / GOLDEN_RATIO), specs.maxWidth, specs.maxHeight); ViewGroup.LayoutParams params = cellHolder.mImageView.getLayoutParams(); params.width = cellDims[0]; params.height = cellDims[1]; cellHolder.mProgressBar.show(); RequestCreator requestCreator = mPicasso.load("https://maps.googleapis.com/maps/api/staticmap?zoom=16&maptype=roadmap&scale=2¢er=" + location.mLatitude + "," + location.mLongitude + "&markers=color:red%7C" + location.mLatitude + "," + location.mLongitude + "&size=" + mapWidth + "x" + mapHeight) .tag(PICASSO_TAG).placeholder(PLACEHOLDER); if (cellDims[0] > 0 && cellDims[1] > 0) { requestCreator.resize(cellDims[0], cellDims[1]); } else if (Log.isLoggable(Log.ERROR)) { Log.e("Width or Height of image passed into LocationCellFactory is invalid"); } requestCreator.transform(getTransform(cellHolder.mImageView.getContext())).into(cellHolder.mImageView, new Callback() { @Override public void onSuccess() { cellHolder.mProgressBar.hide(); } @Override public void onError() { cellHolder.mProgressBar.hide(); } }); }
.tag(AtlasAvatar.TAG).noPlaceholder().noFade() .centerCrop().resize(size, size) .transform((avatarCount > 1) ? MULTI_TRANSFORM : SINGLE_TRANSFORM)
@Override public void bindCellHolder(final CellHolder cellHolder, PartId index, Message message, CellHolderSpecs specs) { cellHolder.mImageView.setTag(index); cellHolder.mImageView.setOnClickListener(this); cellHolder.mProgressBar.show(); RequestCreator requestCreator = mPicasso.load(index.mId).tag(PICASSO_TAG).placeholder(PLACEHOLDER) .centerInside(); if (specs.maxWidth > 0 && specs.maxHeight > 0) { requestCreator.resize(specs.maxWidth, specs.maxHeight); } else if (Log.isLoggable(Log.ERROR)) { Log.e("Width or Height of image passed into SinglePartImageCellFactory.bindCellHolder should be > 0"); } requestCreator.onlyScaleDown() .transform(getTransform(cellHolder.mImageView.getContext())); requestCreator.into(cellHolder.mImageView, new Callback() { @Override public void onSuccess() { cellHolder.mProgressBar.hide(); } @Override public void onError() { cellHolder.mProgressBar.hide(); } }); }
params.height = cellDims[1]; cellHolder.mProgressBar.show(); RequestCreator creator = mPicasso.load(parts.getPreviewPart().getId()).tag(PICASSO_TAG).placeholder(PLACEHOLDER);