本文整理汇总了Java中com.squareup.picasso.Transformation类的典型用法代码示例。如果您正苦于以下问题:Java Transformation类的具体用法?Java Transformation怎么用?Java Transformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transformation类属于com.squareup.picasso包,在下文中一共展示了Transformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPauseImageFromUrl
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private void setPauseImageFromUrl() {
Picasso.with(this).load(pauseADInfo.getAd().get(0).getMaterial())
.skipMemoryCache().transform(new Transformation() {
@Override
public Bitmap transform(Bitmap arg0) {
pauseHeight = arg0.getHeight();
pauseWidth = arg0.getWidth();
PlayerUtil.resizeAdView(ADMediaPlayActivity.this, wm, ivPauseView, pauseWidth, pauseHeight);
return arg0;
}
@Override
public String key() {
return "pause";
}
}).into(ivPauseView);
}
示例2: setFrontImageFromUrl
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private void setFrontImageFromUrl() {
Picasso.with(this).load(frontADInfo.getAd().get(0).getMaterial())
.skipMemoryCache().transform(new Transformation() {
@Override
public Bitmap transform(Bitmap arg0) {
frontHeight = arg0.getHeight();
frontWidth = arg0.getWidth();
PlayerUtil.resizeAdView(ADMediaPlayActivity.this, wm, ivAd, frontWidth, frontHeight);
return arg0;
}
@Override
public String key() {
return "front";
}
}).into(ivAd);
}
示例3: loadRoundedImage
import com.squareup.picasso.Transformation; //导入依赖的package包/类
public static Bitmap loadRoundedImage(Context context, String url, @DrawableRes int ifErrorOrEmpty) {
final Context app = context.getApplicationContext();
Transformation transformation = CurrentTheme.createTransformationForAvatar(app);
int size = (int) Utils.dpToPx(64, app);
if(nonEmpty(url)){
try {
return PicassoInstance.with()
.load(url)
.resize(size, size)
.centerCrop()
.transform(transformation)
.config(Bitmap.Config.RGB_565)
.get();
} catch (IOException e) {
return loadRoundedImageFromResources(app, ifErrorOrEmpty, transformation, size);
}
} else {
return loadRoundedImageFromResources(app, ifErrorOrEmpty, transformation, size);
}
}
示例4: refreshHeader
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private void refreshHeader(User user) {
if (!isAdded()) return;
String avaUrl = user.getMaxSquareAvatar();
String fullName = user.getFullName();
Transformation transformation = new RoundTransformation();
if (nonNull(avaUrl) && !avaUrl.contains("camera")) {
PicassoInstance.with()
.load(avaUrl)
.transform(transformation)
.into(ivHeaderAvatar);
} else {
PicassoInstance.with()
.load(user.getSex() == Sex.WOMAN ? R.drawable.ic_sex_woman : R.drawable.ic_sex_man)
.transform(transformation)
.into(ivHeaderAvatar);
}
tvUserName.setText(fullName);
if (tvDomain != null) {
String domailText = "@" + user.getDomain();
tvDomain.setText(domailText);
}
}
示例5: displayAvatar
import com.squareup.picasso.Transformation; //导入依赖的package包/类
public static void displayAvatar(@NonNull ImageView dest, Transformation transformation, String url, String tag, @DrawableRes int ifEmpty) {
Picasso picasso = PicassoInstance.with();
RequestCreator requestCreator;
if (nonEmpty(url)) {
requestCreator = picasso.load(url);
} else {
requestCreator = picasso.load(ifEmpty);
}
if (transformation != null) {
requestCreator.transform(transformation);
}
if (tag != null) {
requestCreator.tag(tag);
}
requestCreator.into(dest);
}
示例6: createBitmap
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private static Bitmap createBitmap(Context mContext, String url) throws IOException {
int appIconSize = getLauncherIconSize(mContext);
Bitmap bm;
Transformation transformation = new RoundTransformation();
if (isEmpty(url)) {
bm = PicassoInstance.with()
.load(R.drawable.ic_avatar_unknown)
.transform(transformation)
.resize(appIconSize, appIconSize)
.get();
} else {
bm = PicassoInstance.with()
.load(url)
.transform(transformation)
.resize(appIconSize, appIconSize)
.get();
}
return bm;
}
示例7: build
import com.squareup.picasso.Transformation; //导入依赖的package包/类
public Transformation build() {
return new Transformation() {
public Bitmap transform(Bitmap source) {
Bitmap transformed = RoundedDrawable.fromBitmap(source).setScaleType
(RoundedTransformationBuilder.this.mScaleType).setCornerRadius
(RoundedTransformationBuilder.this.mCornerRadii[0],
RoundedTransformationBuilder.this.mCornerRadii[1],
RoundedTransformationBuilder.this.mCornerRadii[2],
RoundedTransformationBuilder.this.mCornerRadii[3]).setBorderWidth
(RoundedTransformationBuilder.this.mBorderWidth).setBorderColor
(RoundedTransformationBuilder.this.mBorderColor).setOval
(RoundedTransformationBuilder.this.mOval).toBitmap();
if (!source.equals(transformed)) {
source.recycle();
}
return transformed;
}
public String key() {
return "r:" + Arrays.toString(RoundedTransformationBuilder.this.mCornerRadii) +
"b:" + RoundedTransformationBuilder.this.mBorderWidth + "c:" +
RoundedTransformationBuilder.this.mBorderColor + "o:" + RoundedTransformationBuilder.this.mOval;
}
};
}
示例8: build
import com.squareup.picasso.Transformation; //导入依赖的package包/类
/**
* Creates a {@link Transformation} for use with picasso.
*
* @return the {@link Transformation}
*/
public Transformation build() {
return new Transformation() {
@Override public Bitmap transform(Bitmap source) {
Bitmap transformed = RoundedDrawable.fromBitmap(source)
.setScaleType(mScaleType)
.setCornerRadius(mCornerRadii[0], mCornerRadii[1], mCornerRadii[2], mCornerRadii[3])
.setBorderWidth(mBorderWidth)
.setBorderColor(mBorderColor)
.setOval(mOval)
.toBitmap();
if (!source.equals(transformed)) {
source.recycle();
}
return transformed;
}
@Override public String key() {
return "r:" + Arrays.toString(mCornerRadii)
+ "b:" + mBorderWidth
+ "c:" + mBorderColor
+ "o:" + mOval;
}
};
}
示例9: loadLoadingUrl
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private void loadLoadingUrl(@NonNull final String url, @NonNull final String loadingUrl, final boolean loadingBlur) {
final List<Transformation> transformations = new ArrayList<>();
if (loadingBlur) {
transformations.add(new BlurTransformation(getContext()));
}
Picasso.with(getContext()).load(loadingUrl).transform(transformations).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
loadUrl(url, bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
示例10: getTransformation
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private Transformation getTransformation(final String t) {
return new Transformation() {
@Override
public Bitmap transform(Bitmap b) {
Palette.from(b).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(final Palette palette) {
int defaultColor = rootView.getResources().getColor
(android.R.color.white);
int titleColor = palette.getLightVibrantColor
(defaultColor);
CollapsingToolbarLayout collapsingToolbar = get(R.id
.collapsing_toolbar);
collapsingToolbar.setExpandedTitleColor(titleColor);
}
});
return b;
}
@Override
public String key() {
return t;
}
};
}
示例11: loadBackgroundImage
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private void loadBackgroundImage() {
if (headerViewImageReference.size() == 0
|| headerViewImageReference.get(currentPageIndex) == null
|| headerViewImageReference.get(currentPageIndex).size() == 0) {
loadFallBackBackground();
return;
}
if (headerViewImageReference.get(currentPageIndex).size() <= currentImageIndex + 1) {
currentImageIndex = -1;
}
currentImageIndex++;
final Transformation tintTransformation = new ColorTintingGrayScaleTransformation(getColorByPosition(currentPageIndex));
picasso.load(headerViewImageReference.get(currentPageIndex).get(currentImageIndex))
.transform(tintTransformation)
.into(panningImage);
transitionsCount = 0;
}
示例12: blurTransformation
import com.squareup.picasso.Transformation; //导入依赖的package包/类
@Override
public Transformation blurTransformation(final String fileName) {
return new Transformation() {
private Bitmap blurredImage;
@Override
public Bitmap transform(Bitmap source) {
return getBlurredImage(source,
fileName, 20);
}
@Override
public String key() {
return fileName;
}
};
}
示例13: build
import com.squareup.picasso.Transformation; //导入依赖的package包/类
public Transformation build() {
return new Transformation() {
@Override
public Bitmap transform(Bitmap source) {
Bitmap transformed = RoundedDrawable.fromBitmap(source)
.setScaleType(mScaleType)
.setCornerRadius(mCornerRadius)
.setBorderWidth(mBorderWidth)
.setBorderColor(mBorderColor)
.setOval(mOval)
.toBitmap();
if (!source.equals(transformed)) {
source.recycle();
}
return transformed;
}
@Override
public String key() {
return "r:" + mCornerRadius
+ "b:" + mBorderWidth
+ "c:" + mBorderColor
+ "o:" + mOval;
}
};
}
示例14: getTransformation
import com.squareup.picasso.Transformation; //导入依赖的package包/类
private static Transformation getTransformation(Context context) {
if (PICASSO_CIRCLE_TRANSFORMATION == null) {
final int color;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
color = context.getResources().getColor(R.color.black);
} else {
color = context.getColor(R.color.black);
}
PICASSO_CIRCLE_TRANSFORMATION = new RoundedTransformationBuilder()
.borderColor(color)
.borderWidthDp(2)
.scaleType(ImageView.ScaleType.CENTER_CROP)
.oval(true)
.build();
}
return PICASSO_CIRCLE_TRANSFORMATION;
}
示例15: build
import com.squareup.picasso.Transformation; //导入依赖的package包/类
/**
* Creates a {@link Transformation} for use with picasso.
*
* @return the {@link Transformation}
*/
public Transformation build() {
return new Transformation() {
@Override public Bitmap transform(Bitmap source) {
Bitmap transformed = RoundedDrawable.fromBitmap(source)
.setScaleType(mScaleType)
.setCornerRadius(mCornerRadii[0], mCornerRadii[1], mCornerRadii[2], mCornerRadii[3])
.setBorderWidth(mBorderWidth)
.setBorderColor(mBorderColor)
.setOval(mOval)
.toBitmap();
if (!source.equals(transformed)) {
source.recycle();
}
return transformed;
}
@Override public String key() {
return "r:" + Arrays.toString(mCornerRadii)
+ "b:" + mBorderWidth
+ "c:" + mBorderColor
+ "o:" + mOval;
}
};
}