本文整理汇总了Java中com.squareup.picasso.RequestCreator类的典型用法代码示例。如果您正苦于以下问题:Java RequestCreator类的具体用法?Java RequestCreator怎么用?Java RequestCreator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestCreator类属于com.squareup.picasso包,在下文中一共展示了RequestCreator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayRaw
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public void displayRaw(@NonNull ImageView img, @NonNull String absPath, int width, int height, final IBoxingCallback callback) {
String path = "file://" + absPath;
RequestCreator creator = Picasso.with(img.getContext())
.load(path);
if (width > 0 && height > 0) {
creator.transform(new BitmapTransform(width, height));
}
creator.into(img, new Callback() {
@Override
public void onSuccess() {
if (callback != null) {
callback.onSuccess();
}
}
@Override
public void onError() {
if (callback != null) {
callback.onFail(null);
}
}
});
}
示例2: displayAvatar
import com.squareup.picasso.RequestCreator; //导入依赖的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);
}
示例3: loadImage
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
/**
* Loads an image into a target view.
* @param context context
* @param image image
* @param centerCrop boolean
* @param errorResourceId image of error
* @param target imageView
* @param callback callback
*/
public static void loadImage(final Context context, final String image,
final boolean centerCrop, final int errorResourceId,
final ImageView target, final Callback callback) {
Picasso pic = Picasso.with(context);
RequestCreator request;
int errorRId = errorResourceId;
if (image != null )
request = pic.load(image).fit();
else {
request = pic.load(errorResourceId).fit();
errorRId = 0;
}
if (centerCrop)
request = request.centerCrop();
if (errorRId != 0)
request = request.error(errorResourceId);
if (callback != null)
request.into(target, callback);
else
request.into(target);
}
示例4: getView
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View entry = convertView != null ? convertView : inflater.inflate(R.layout.flair_entry, parent, false);
String id = ids[position];
((TextView) entry.findViewById(R.id.flairText)).setText(id);
ImageView imageView = (ImageView) entry.findViewById(R.id.flair);
Picasso.with(context).cancelRequest(imageView);
RequestCreator request = flairStylesheet.loadFlairById(id, context);
if(request != null) request.into(imageView);
imageView.getLayoutParams().width = (int) (flairStylesheet.prevDimension.width * context.getResources().getDisplayMetrics().density);
imageView.getLayoutParams().height = (int) (flairStylesheet.prevDimension.height * context.getResources().getDisplayMetrics().density);
return entry;
}
示例5: displayImage
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public void displayImage(Context context, String path, FixImageView imageView, Drawable defaultDrawable, Bitmap.Config config, boolean resize, boolean isGif, int width, int height, int rotate) {
RequestCreator creator = Picasso.with(context)
.load(new File(path))
.placeholder(defaultDrawable)
.error(defaultDrawable)
.rotate(rotate)
.networkPolicy(NetworkPolicy.NO_STORE)
.config(config)
.tag(context);
if (resize) {
creator = creator.resize(width, height)
.centerCrop();
}
creator.into(imageView);
}
示例6: loadImage
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public ILoaderProxy loadImage(View view, String path) {
if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
//判断缓存中是否已经缓存过该图片,有则直接拿Bitmap,没有则直接调用Glide加载并缓存Bitmap
Bitmap bitmap = LruCacheUtils.getInstance().getBitmapFromMemCache(path);
if (bitmap != null) {
imageView.setImageBitmap(bitmap);
} else {
RequestCreator requestCreator = getPicasso().load(path);
loadOptions(requestCreator).into(imageView);
}
}
return obtain();
}
示例7: loadOptions
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
private RequestCreator loadOptions(RequestCreator requestCreator) {
if (options == null) {
return requestCreator;
}
if (options.targetHeight > 0 && options.targetWidth > 0) {
requestCreator.resize(options.targetWidth, options.targetHeight);
}
if (options.isCenterInside) {
requestCreator.centerInside();
} else if (options.isCenterCrop) {
requestCreator.centerCrop();
}
if (options.config != null) {
requestCreator.config(options.config);
}
if (options.errorResId != 0) {
requestCreator.error(options.errorResId);
}
if (options.placeholderResId != 0) {
requestCreator.placeholder(options.placeholderResId);
}
if (options.bitmapAngle != 0) {
requestCreator.transform(new PicassoTransformation(options.bitmapAngle));
}
return requestCreator;
}
示例8: getDrawable
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public Drawable getDrawable(String source) {
RichTextView.URLDrawable urlDrawable = new RichTextView.URLDrawable();
RichTextView.ImageTarget target = new RichTextView.ImageTarget(urlDrawable);
RichTextView.this.addTarget(target);
RichTextView.ImageHolder holder = mImages.get(source);
RequestCreator load = Picasso.with(getContext()).load(source);
if ((onImageFixListener != null) && (holder != null)) {
onImageFixListener.onFix(holder);
if ((holder.width != -1) && (holder != null))
load.resize(holder.width, holder.height);
if (holder.scaleType == 1) load.centerCrop();
else load.centerInside();
}
load.placeholder(placeImage).error(errorImage).into(target);
return urlDrawable;
}
示例9: loadAvatarImage
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
/**
* Load an agent's or visitor's avatar into an {@link ImageView}.
* <br>
* Images get transformed into circular shaped. If there's no or no valid
* url to the image {@code R.drawable.ic_chat_default_avatar} will be displayed.
*
* @param imageView the {@link ImageView}
* @param avatarUri uri as a {@link String} to avatar image
*/
static void loadAvatarImage(@NonNull final ImageView imageView, @Nullable final String avatarUri) {
final Picasso picasso = Picasso.with(imageView.getContext());
final RequestCreator requestCreator;
if(StringUtils.hasLength(avatarUri)) {
requestCreator = picasso
.load(avatarUri).error(DEFAULT_AVATAR)
.error(DEFAULT_AVATAR)
.placeholder(DEFAULT_AVATAR);
} else {
requestCreator = picasso
.load(DEFAULT_AVATAR);
}
requestCreator
.transform(new CircleTransform())
.into(imageView);
}
示例10: setPicasso
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
public static void setPicasso(Context context, Uri url, ImageView imageView, @DrawableRes int placeHolder) {
Picasso picasso = Picasso.with(context);
if (BuildConfig.DEBUG)
picasso.setLoggingEnabled(true);
RequestCreator requestCreator = picasso.load(url);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
requestCreator.placeholder(placeHolder);
requestCreator.error(placeHolder);
} else {
Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, placeHolder);
requestCreator.placeholder(drawable);
requestCreator.error(drawable);
}
requestCreator.into(imageView);
}
示例11: processScaleType
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
/**
* 处理ScaleType
*
* @param uri
* @param view
* @return
*/
private static RequestCreator processScaleType(String uri, ImageView view) {
if (view.getScaleType() == ImageView.ScaleType.CENTER) {
view.setScaleType(ImageView.ScaleType.CENTER);
return initWithResize(uri, view);
} else if (view.getScaleType() == ImageView.ScaleType.CENTER_INSIDE) {
return initWithResize(uri, view).centerInside();
} else if (view.getScaleType() == ImageView.ScaleType.CENTER_CROP) {
return initWithResize(uri, view).centerCrop();
} else if (view.getScaleType() == ImageView.ScaleType.FIT_CENTER) {
view.setScaleType(ImageView.ScaleType.FIT_CENTER);
return init(uri, view);
} else if (view.getScaleType() == ImageView.ScaleType.FIT_START) {
view.setScaleType(ImageView.ScaleType.FIT_START);
return init(uri, view);
} else if (view.getScaleType() == ImageView.ScaleType.FIT_END) {
view.setScaleType(ImageView.ScaleType.FIT_END);
return init(uri, view);
} else {
return init(uri, view).fit();
}
}
示例12: fetchBitmap
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
private @Nullable Bitmap fetchBitmap(final @Nullable String url, final boolean transformIntoCircle) {
if (url == null) {
return null;
}
try {
RequestCreator requestCreator = Picasso.with(this.context).load(url).transform(new CropSquareTransformation());
if (transformIntoCircle) {
requestCreator = requestCreator.transform(new CircleTransformation());
}
return requestCreator.get();
} catch (IOException e) {
Timber.e("Failed to load large icon: %s", e);
return null;
}
}
示例13: bind
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public void bind(@NonNull final RepoEntity poRepo) {
mTextView.setText(poRepo.url);
final RequestCreator loRequest = mPicasso.load(poRepo.avatarUrl);
if (loRequest != null) {
loRequest
.placeholder(R.drawable.git_icon)
.error(R.drawable.git_icon)
.into(mImageViewAvatar);
}
setOnClickListener((final View poView) ->
notifyItemAction(ROW_PRESSED)
);
}
示例14: loadWallpaperFromSD
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
private void loadWallpaperFromSD() {
String path = ThemeManager.getWallpaperPath(this);
ImageView ivWallpaper = (ImageView) findViewById(R.id.ivWallpaper);
if (!TextUtils.isEmpty(path)) {
int blurRadius = PrefManager.getInt(SettingsFragment.KEY_BLUR_RADIUS);
boolean applyBlur = PrefManager.getBoolean(SettingsFragment.KEY_BLUR_WALLPAPER);
ivWallpaper.setVisibility(View.VISIBLE);
final RequestCreator creator = Picasso.with(this)
.load(new File(path));
if (applyBlur) {
creator.transform(new AndroidUtils.PicassoBlurTransform(blurRadius));
}
creator.into(ivWallpaper);
} else {
ivWallpaper.setVisibility(View.GONE);
}
}
示例15: loadWallpaper
import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
private void loadWallpaper() {
String wallpaperPath = ThemeManager.getWallpaperPath(this);
if (TextUtils.isEmpty(wallpaperPath)) {
return;
}
ImageView ivWallpaper = (ImageView) findViewById(R.id.ivWallpaper);
ivWallpaper.setVisibility(View.VISIBLE);
boolean applyBlur = PrefManager.getBoolean(SettingsFragment.KEY_BLUR_WALLPAPER);
RequestCreator creator = Picasso.with(this)
.load(new File(wallpaperPath));
if (applyBlur) {
creator.transform(new AndroidUtils.PicassoBlurTransform(PrefManager.getInt(SettingsFragment.KEY_BLUR_RADIUS)));
}
creator.into(ivWallpaper);
}