use of com.squareup.picasso.RequestCreator in project MaterialList by dexafree.
the class CardProvider method render.
// ///////////////////////////////////////////////////////////////
//
// Functions for rendering.
//
// ///////////////////////////////////////////////////////////////
/**
* Renders the content and style of the card to the view.
*
* @param view to display the content and style on.
* @param card to render.
*/
@SuppressWarnings("unchecked")
public void render(@NonNull final View view, @NonNull final Card card) {
// The card background
final CardView cardView = findViewById(view, R.id.cardView, CardView.class);
if (cardView != null) {
cardView.setCardBackgroundColor(getBackgroundColor());
}
// Title
final TextView title = findViewById(view, R.id.title, TextView.class);
if (title != null) {
title.setText(getTitle());
title.setTextColor(getTitleColor());
title.setGravity(getTitleGravity());
}
// Subtitle
final TextView subtitle = findViewById(view, R.id.subtitle, TextView.class);
if (subtitle != null) {
subtitle.setText(getSubtitle());
subtitle.setTextColor(getSubtitleColor());
subtitle.setGravity(getSubtitleGravity());
if (getSubtitle() == null || getSubtitle().isEmpty()) {
subtitle.setVisibility(View.GONE);
} else {
subtitle.setVisibility(View.VISIBLE);
}
}
// Description
final TextView supportingText = findViewById(view, R.id.supportingText, TextView.class);
if (supportingText != null) {
supportingText.setText(getDescription());
supportingText.setTextColor(getDescriptionColor());
supportingText.setGravity(getDescriptionGravity());
}
// Image
final ImageView imageView = findViewById(view, R.id.image, ImageView.class);
if (imageView != null) {
if (getDrawable() != null) {
imageView.setImageDrawable(getDrawable());
} else {
final RequestCreator requestCreator = Picasso.with(getContext()).load(getImageUrl());
if (getOnImageConfigListenerListener() != null) {
getOnImageConfigListenerListener().onImageConfigure(requestCreator);
}
requestCreator.into(imageView);
}
}
// Divider
final View divider = findViewById(view, R.id.divider, View.class);
if (divider != null) {
divider.setVisibility(isDividerVisible() ? View.VISIBLE : View.INVISIBLE);
// according to the preferences
if (isDividerVisible()) {
// If the divider has to be from side to side, the margin will be 0
final ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) divider.getLayoutParams();
if (isFullWidthDivider()) {
params.setMargins(0, 0, 0, 0);
} else {
int dividerMarginPx = dpToPx(DIVIDER_MARGIN_DP);
// Set the margin
params.setMargins(dividerMarginPx, 0, dividerMarginPx, 0);
}
}
}
// Actions
for (final Map.Entry<Integer, Action> entry : mActionMapping.entrySet()) {
final View actionViewRaw = findViewById(view, entry.getKey(), View.class);
if (actionViewRaw != null) {
final Action action = entry.getValue();
action.setProvider(this);
action.onRender(actionViewRaw, card);
}
}
}
use of com.squareup.picasso.RequestCreator in project boxing by Bilibili.
the class BoxingPicassoLoader method displayRaw.
@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);
}
}
});
}
use of com.squareup.picasso.RequestCreator in project Klyph by jonathangerbaud.
the class ImageLoader method displayNoScaling.
public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) {
if (uri == null || uri.length() == 0)
uri = FAKE_URI;
Picasso picasso = Picasso.with(imageView.getContext());
RequestCreator requestCreator = picasso.load(uri);
if (stubImage != 0) {
requestCreator.placeholder(stubImage);
requestCreator.error(stubImage);
}
if (!(fadeIn && FADE_ENABLED))
requestCreator.noFade();
requestCreator.into(imageView, listener);
}
use of com.squareup.picasso.RequestCreator in project AndroidPicker by gzu-liyujiang.
the class ImageHelper method display.
@Override
public void display(String urlOrPath, ImageView view, int width, int height) {
LogUtils.verbose("Image>>>" + urlOrPath);
if (null == context) {
context = view.getContext();
}
RequestCreator creator = Picasso.with(context).load(urlOrPath);
creator.placeholder(PLACEHOLDER_LOADING);
creator.error(PLACEHOLDER_FAILURE);
creator.config(urlOrPath.endsWith(".png") ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
if (width > 0 && height > 0) {
creator.resize(width, height);
}
creator.into(view);
}
use of com.squareup.picasso.RequestCreator in project SeriesGuide by UweTrottmann.
the class FullscreenImageActivity method loadLargeImage.
private void loadLargeImage(boolean hasPreviewImage) {
String imagePath = getIntent().getStringExtra(EXTRA_IMAGE);
if (TextUtils.isEmpty(imagePath)) {
// set to null so picasso shows error drawable
imagePath = null;
}
RequestCreator requestCreator = ServiceUtils.loadWithPicasso(this, imagePath);
if (hasPreviewImage) {
// keep showing preview image if loading full image fails
requestCreator.noPlaceholder().into(photoView);
} else {
// no preview image? show error image instead if loading full image fails
requestCreator.error(R.drawable.ic_image_missing).into(photoView, new Callback() {
@Override
public void onSuccess() {
photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
@Override
public void onError() {
photoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
});
}
}
Aggregations