java类com.squareup.picasso.Transformation的实例源码

MainActivity.java 文件源码 项目:Prodigal 阅读 17 收藏 0 点赞 0 评论 0
public void loadBackground(SongBean bean) {
    if (bean == null ) {
        backgroundImage.setImageBitmap(null);
        return;
    }
    final Uri image = Uri.parse(MediaLibrary.getStaticInstance(getApplicationContext())
            .getCoverUriByAlbumId(bean.getAlbumId()));
    Picasso.with(this).load(image).resize(windowSize.x, windowSize.y)
            .centerCrop()
            .transform(new Transformation() {
                @Override
                public Bitmap transform(Bitmap source) {
                    BlurFactor factor = new BlurFactor();
                    factor.radius = 25;
                    factor.sampling = 4;
                    factor.width = windowSize.x;
                    factor.height = windowSize.y;
                    factor.color = ColorUtils.setAlphaComponent(
                            ThemeManager.getInstance(getApplicationContext())
                            .loadCurrentTheme().getBackgroundColor(), 20);
                    Bitmap ret = Blur.of(getApplicationContext(), source, factor);
                    source.recycle();
                    return ret;
                }

                @Override
                public String key() {
                    return image.toString() + "/blured";
                }
            })
            .config(Bitmap.Config.RGB_565).into(backgroundImage);

}
PicassoImageView.java 文件源码 项目:android-gto-support 阅读 17 收藏 0 点赞 0 评论 0
@UiThread
public final void setTransforms(@Nullable final List<? extends Transformation> transformations) {
    mTransforms.clear();
    if (transformations != null) {
        mTransforms.addAll(transformations);
    }
    triggerUpdate();
}
ImageLoader.java 文件源码 项目:Retrofit2SampleApp 阅读 30 收藏 0 点赞 0 评论 0
@Override
public void loadImage(String url,final ImageView imageView) {

    Picasso.with(imageView.getContext()).load(url).transform(new Transformation() {
        @Override
        public Bitmap transform(Bitmap source) {
            Bitmap combinedBitmap;
            combinedBitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight() / 3 + source.getHeight(), source.getConfig());

            Canvas combinedCanvas = new Canvas(combinedBitmap);
            combinedCanvas.drawBitmap(source, 0f, 0f, null);

            Matrix matrix = new Matrix();
            matrix.postRotate(180);
            matrix.preScale(-1, 1);
            matrix.postTranslate(0, source.getHeight() * 2);

            BlurTransformation blurTransformation = new BlurTransformation(imageView.getContext(), 15, 1);
            Bitmap bottom = blurTransformation.transform(source);

            combinedCanvas.setMatrix(matrix);
            combinedCanvas.drawBitmap(bottom, 0f, 0f, null);
            return combinedBitmap;
        }

        @Override
        public String key() {
            return ImageLoader.class.getName() + ".Transformation";
        }
    }).error(android.R.drawable.sym_contact_card).placeholder(android.R.drawable.sym_contact_card).
            into(imageView);
}
ThreePartImageCellFactory.java 文件源码 项目:Atlas-Android 阅读 20 收藏 0 点赞 0 评论 0
private Transformation getTransform(Context context) {
    if (mTransform == null) {
        float radius = context.getResources().getDimension(com.layer.atlas.R.dimen.atlas_message_item_cell_radius);
        mTransform = new RoundedTransform(radius);
    }

    return mTransform;
}
SinglePartImageCellFactory.java 文件源码 项目:Atlas-Android 阅读 23 收藏 0 点赞 0 评论 0
private Transformation getTransform(Context context) {
    if (mTransform == null) {
        float radius = context.getResources().getDimension(com.layer.atlas.R.dimen.atlas_message_item_cell_radius);
        mTransform = new RoundedTransform(radius);
    }

    return mTransform;
}
LocationCellFactory.java 文件源码 项目:Atlas-Android 阅读 18 收藏 0 点赞 0 评论 0
private Transformation getTransform(Context context) {
    if (mTransform == null) {
        float radius = context.getResources().getDimension(com.layer.atlas.R.dimen.atlas_message_item_cell_radius);
        mTransform = new RoundedTransform(radius);
    }

    return mTransform;
}
PicassoHandle.java 文件源码 项目:android-sidekick 阅读 19 收藏 0 点赞 0 评论 0
public void loadTransform(String path, Target target, Transformation transformer) {
    picasso.load(path)
            .placeholder(onLoadDrawable)
            .error(onErrorDrawable)
            .transform(transformer)
            .into(target);
}
PicassoImageLoader.java 文件源码 项目:Nox 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Uses the configuration previously applied using this ImageLoader builder to download a
 * resource asynchronously and notify the result to the listener.
 */
private void loadImage() {
  List<Transformation> transformations = getTransformations();
  boolean hasUrl = url != null;
  boolean hasResourceId = resourceId != null;
  boolean hasPlaceholder = placeholderId != null;
  ListenerTarget listenerTarget = getLinearTarget(listener);
  if (hasUrl) {
    RequestCreator bitmapRequest = Picasso.with(context).load(url).tag(PICASSO_IMAGE_LOADER_TAG);
    applyPlaceholder(bitmapRequest).resize(size, size)
        .transform(transformations)
        .into(listenerTarget);
  } else if (hasResourceId || hasPlaceholder) {
    Resources resources = context.getResources();
    Drawable placeholder = null;
    Drawable drawable = null;
    if (hasPlaceholder) {
      placeholder = resources.getDrawable(placeholderId);
      listenerTarget.onPrepareLoad(placeholder);
    }
    if (hasResourceId) {
      drawable = resources.getDrawable(resourceId);
      listenerTarget.onDrawableLoad(drawable);
    }
  } else {
    throw new IllegalArgumentException(
        "Review your request, you are trying to load an image without a url or a resource id.");
  }
}
PicassoImageLoader.java 文件源码 项目:Nox 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Lazy instantiation of the list of transformations used during the image download. This method
 * returns a List<Transformation> because Picasso doesn't support a null instance as
 * transformation.
 */
private List<Transformation> getTransformations() {
  if (transformations == null) {
    transformations = new LinkedList<Transformation>();
    if (useCircularTransformation) {
      transformations.add(new CircleTransformation());
    }
  }
  return transformations;
}
HomeListAdapter.java 文件源码 项目:BPic 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final StatusModel model = mList.get(position);
    holder.detailUrl = model.detail;
    holder.author.setText(model.author);
    if (!TextUtils.isEmpty(model.avatar)) {
        Picasso.with(mContext).load(model.avatar).noFade().placeholder(android.R.color.darker_gray).into(holder.avatar);
        holder.avatar.setVisibility(View.VISIBLE);
    }
    holder.cover.setOriginalSize(model.width, model.height);
    Picasso.with(mContext).load(model.cover).config(Bitmap.Config.RGB_565).placeholder(android.R.color.darker_gray).transform(new Transformation() {
        @Override
        public Bitmap transform(Bitmap source) {
            if (!(model.width > 0 && model.height > 0)) {
                model.width = source.getWidth();
                model.height = source.getHeight();
                holder.cover.setOriginalSize(source.getWidth(), source.getHeight());
            }
            return source;
        }

        @Override
        public String key() {
            return "setCoverViewSize";
        }
    }).into(holder.cover);
}


问题


面经


文章

微信
公众号

扫码关注公众号