Search in sources :

Example 11 with RequestOptions

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

the class DrawableTransformationTest method load_withColorDrawable_sizeOriginal_optionalTransform_returnsColorDrawable.

@Test
public void load_withColorDrawable_sizeOriginal_optionalTransform_returnsColorDrawable() throws ExecutionException, InterruptedException {
    Drawable colorDrawable = new ColorDrawable(Color.RED);
    Drawable result = Glide.with(context).load(colorDrawable).apply(new RequestOptions().optionalCenterCrop()).submit().get();
    assertThat(result).isInstanceOf(ColorDrawable.class);
    assertThat(((ColorDrawable) result).getColor()).isEqualTo(Color.RED);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) RequestOptions(com.bumptech.glide.request.RequestOptions) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Test(org.junit.Test)

Example 12 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project MyBaseApplication by BanShouWeng.

the class GlideUtils method loadImageViewLoding.

// 设置加载中以及加载失败图片
public static void loadImageViewLoding(Context mContext, String path, ImageView mImageView, int lodingImage, int errorImageView) {
    RequestOptions options = new RequestOptions().centerCrop().placeholder(lodingImage).error(errorImageView);
    Glide.with(mContext).load(path).apply(options).into(mImageView);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 13 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project MyBaseApplication by BanShouWeng.

the class GlideUtils method loadImageViewSize.

// 加载指定大小
public static void loadImageViewSize(Context mContext, String path, int width, int height, ImageView mImageView) {
    RequestOptions options = new RequestOptions().centerCrop().override(width, height);
    Glide.with(mContext).load(path).apply(options).into(mImageView);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 14 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project MyBaseApplication by BanShouWeng.

the class GlideUtils method loadImageViewCrop.

/**
 * api提供了比如:centerCrop()、fitCenter()等
 */
// 设置动态转换
public static void loadImageViewCrop(Context mContext, String path, ImageView mImageView) {
    RequestOptions options = new RequestOptions().centerCrop();
    Glide.with(mContext).load(path).apply(options).into(mImageView);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 15 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project Habba18 by chiragsastry1996.

the class FeedAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
    final Feed feed = feedList.get(position);
    holder.nameTextView.setText(feed.getName());
    holder.ageTextView.setText(feed.getCaption());
    if (feed.getImage().contains("http://acharyahabba.in/habba18/admin/feeds")) {
        holder.relativeLayout.setVisibility(View.GONE);
        holder.playButton.setVisibility(View.GONE);
        Glide.with(mContext).load(feed.getImage()).apply(new RequestOptions().placeholder(R.drawable.loader)).into(holder.imageView);
    } else {
        Glide.with(mContext).load("https://img.youtube.com/vi/" + feed.getImage() + "/0.jpg").into(holder.imageView);
        System.out.println("youtube " + "https://img.youtube.com/vi/" + feed.getImage() + "/0.jpg");
        holder.relativeLayout.setVisibility(View.VISIBLE);
        holder.playButton.setVisibility(View.VISIBLE);
        holder.playButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle args = new Bundle();
                args.putString("url", feed.getImage());
                args.putString("name", feed.getName());
                args.putString("caption", feed.getCaption());
                YoutubeFragment youtube = new YoutubeFragment();
                youtube.setArguments(args);
                ((AppCompatActivity) mContext).getSupportFragmentManager().beginTransaction().add(R.id.frameContainer, youtube).addToBackStack(null).commit();
            }
        });
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

RequestOptions (com.bumptech.glide.request.RequestOptions)104 ImageView (android.widget.ImageView)23 Drawable (android.graphics.drawable.Drawable)18 View (android.view.View)18 TextView (android.widget.TextView)13 Bitmap (android.graphics.Bitmap)11 File (java.io.File)10 BitmapDrawable (android.graphics.drawable.BitmapDrawable)9 ColorDrawable (android.graphics.drawable.ColorDrawable)7 Uri (android.net.Uri)7 DataSource (com.bumptech.glide.load.DataSource)6 GlideException (com.bumptech.glide.load.engine.GlideException)6 Context (android.content.Context)5 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)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