Search in sources :

Example 11 with RequestCreator

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);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) CardView(android.support.v7.widget.CardView) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RequestCreator(com.squareup.picasso.RequestCreator) TextView(android.widget.TextView) ImageView(android.widget.ImageView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with RequestCreator

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);
            }
        }
    });
}
Also used : Callback(com.squareup.picasso.Callback) IBoxingCallback(com.bilibili.boxing.loader.IBoxingCallback) RequestCreator(com.squareup.picasso.RequestCreator)

Example 13 with RequestCreator

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);
}
Also used : Picasso(com.squareup.picasso.Picasso) RequestCreator(com.squareup.picasso.RequestCreator)

Example 14 with RequestCreator

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);
}
Also used : RequestCreator(com.squareup.picasso.RequestCreator)

Example 15 with RequestCreator

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);
            }
        });
    }
}
Also used : Callback(com.squareup.picasso.Callback) RequestCreator(com.squareup.picasso.RequestCreator)

Aggregations

RequestCreator (com.squareup.picasso.RequestCreator)24 Picasso (com.squareup.picasso.Picasso)10 View (android.view.View)8 ImageView (android.widget.ImageView)8 TextView (android.widget.TextView)6 Bitmap (android.graphics.Bitmap)5 Drawable (android.graphics.drawable.Drawable)5 Target (com.squareup.picasso.Target)5 Callback (com.squareup.picasso.Callback)4 File (java.io.File)4 Intent (android.content.Intent)3 Uri (android.net.Uri)3 VafContext (com.tmall.wireless.vaf.framework.VafContext)3 IImageLoaderAdapter (com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.IImageLoaderAdapter)3 NonNull (android.support.annotation.NonNull)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ViewGroup (android.view.ViewGroup)2 Listener (com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.Listener)2 ImageBase (com.tmall.wireless.vaf.virtualview.view.image.ImageBase)2 ArrayList (java.util.ArrayList)2