Search in sources :

Example 61 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project Now by XunMengWinter.

the class GankAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    MyViewHolder myViewHolder = (MyViewHolder) holder;
    Gank gank = mList.get(position);
    myViewHolder.mNameTv.setText(gank.desc);
    myViewHolder.mUrlTv.setText(gank.url);
    if (gank.images != null && !gank.images.isEmpty()) {
        myViewHolder.mImageIv.setVisibility(View.VISIBLE);
        final String imageUrl = gank.images.get(0);
        RequestOptions requestOptions = new RequestOptions();
        int imageWidth = context.getResources().getDimensionPixelSize(R.dimen.width_gank_image);
        requestOptions.override(imageWidth);
        Glide.with(context).load(imageUrl).apply(requestOptions).into(myViewHolder.mImageIv);
    // Logger.e("gank item load image failed:" + imageUrl);
    // DraweeController controller = Fresco.newDraweeControllerBuilder()
    // .setUri(imageUrl)
    // .setAutoPlayAnimations(true)
    // .build();
    // myViewHolder.mImageIv.setController(controller);
    } else {
        myViewHolder.mImageIv.setVisibility(View.GONE);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Gank(top.wefor.now.data.model.entity.Gank)

Example 62 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project Now by XunMengWinter.

the class GankDailyActivity method showLastGankImage.

private void showLastGankImage() {
    String imageUrl = mPreferencesHelper.getLastGankBanner();
    if (imageUrl == null || imageUrl.isEmpty()) {
        return;
    }
    Glide.with(GankDailyActivity.this).load(imageUrl).apply(new RequestOptions().centerCrop()).into(mBannerSdv);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 63 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project CustomViews by AndroidStudy233.

the class GlideUtils method loadHeadImg.

public static void loadHeadImg(Context context, String imageUrl, ImageView targetIv) {
    RequestOptions requestOptions = new RequestOptions();
    requestOptions.error(R.drawable.pic_head_deauft);
    requestOptions.placeholder(R.drawable.pic_head_deauft);
    requestOptions.circleCrop();
    Glide.with(context).load(imageUrl).apply(requestOptions).into(targetIv);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 64 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project drift-sdk-android by Driftt.

the class UserPopulationHelper method populateTextAndImageFromUser.

public static void populateTextAndImageFromUser(Context context, User user, @Nullable TextView textView, ImageView imageView) {
    Uri uriToLoad = null;
    Boolean ignoreUri = false;
    if (user != null) {
        if (textView != null) {
            textView.setText(user.name);
        }
        if (user.bot) {
            ignoreUri = true;
            Drawable placeholderDrawable = AppCompatResources.getDrawable(context, R.drawable.robot);
            Drawable backgroundDrawable = AppCompatResources.getDrawable(context, R.drawable.drift_sdk_bot_background);
            DrawableCompat.setTint(backgroundDrawable, ColorHelper.getBackgroundColor());
            Drawable[] layers = new Drawable[2];
            layers[0] = backgroundDrawable;
            layers[1] = placeholderDrawable;
            LayerDrawable layerDrawable = new LayerDrawable(layers);
            imageView.setImageDrawable(layerDrawable);
        } else if (user.avatarUrl != null) {
            uriToLoad = Uri.parse(user.avatarUrl);
        }
    } else {
        // Unknown User
        if (textView != null) {
            textView.setText("Unknown User");
        }
    }
    if (!ignoreUri) {
        RequestOptions requestOptions = new RequestOptions().circleCrop().placeholder(R.drawable.placeholder);
        Glide.with(context).load(uriToLoad).apply(requestOptions).into(imageView);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) Uri(android.net.Uri)

Example 65 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project MyNewCC98 by 6769.

the class MainActivity method setupUserLogo.

private void setupUserLogo() {
    UserInfo userInfo = UserConfig.getUserInfo();
    if (userInfo != null) {
        userNameLabel.setText(userInfo.getName());
        // userIntroLabel.setText(userInfo.getIntroduction());
        String userpic = userInfo.getPortraitUrl();
        try {
            RequestOptions options = new RequestOptions().centerCrop().dontAnimate();
            Glide.with(this).load(userpic).apply(options).into(userLogo);
        } catch (Exception e) {
            loge(e, "Glide load userpic failed");
        }
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) UserInfo(win.pipi.api.data.UserInfo)

Aggregations

RequestOptions (com.bumptech.glide.request.RequestOptions)96 ImageView (android.widget.ImageView)23 View (android.view.View)18 Drawable (android.graphics.drawable.Drawable)16 TextView (android.widget.TextView)13 Bitmap (android.graphics.Bitmap)9 BitmapDrawable (android.graphics.drawable.BitmapDrawable)8 File (java.io.File)8 Uri (android.net.Uri)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 Context (android.content.Context)5 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 DataSource (com.bumptech.glide.load.DataSource)5 GlideException (com.bumptech.glide.load.engine.GlideException)5 FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)5 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)5 Test (org.junit.Test)5 Activity (android.app.Activity)3 LayoutInflater (android.view.LayoutInflater)3