Search in sources :

Example 36 with RequestOptions

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

the class RequestBuilderTest method getNullModelRequest.

private RequestBuilder<Object> getNullModelRequest() {
    when(glideContext.buildImageViewTarget(isA(ImageView.class), isA(Class.class))).thenReturn(mock(ViewTarget.class));
    when(glideContext.getDefaultRequestOptions()).thenReturn(new RequestOptions());
    when(requestManager.getDefaultRequestOptions()).thenReturn(new RequestOptions());
    when(requestManager.getDefaultTransitionOptions(any(Class.class))).thenReturn(new GenericTransitionOptions<>());
    return new RequestBuilder<>(glide, requestManager, Object.class, context).load((Object) null);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) ImageView(android.widget.ImageView) ViewTarget(com.bumptech.glide.request.target.ViewTarget)

Example 37 with RequestOptions

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

the class GlideContextTest method setUp.

@Before
public void setUp() {
    Application app = RuntimeEnvironment.application;
    transitionOptions = new HashMap<>();
    context = new GlideContext(app, new LruArrayPool(), new Registry(), new ImageViewTargetFactory(), new RequestOptions(), transitionOptions, mock(Engine.class), Log.DEBUG);
}
Also used : LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) ImageViewTargetFactory(com.bumptech.glide.request.target.ImageViewTargetFactory) RequestOptions(com.bumptech.glide.request.RequestOptions) Application(android.app.Application) Before(org.junit.Before)

Example 38 with RequestOptions

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

the class MainActivity method showContact.

private void showContact(long id) {
    GlideRequests glideRequests = GlideApp.with(this);
    RequestOptions originalSize = new RequestOptions().override(Target.SIZE_ORIGINAL);
    Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
    glideRequests.load(contactUri).apply(originalSize).into(imageViewContact);
    Uri lookupUri = Contacts.getLookupUri(getContentResolver(), contactUri);
    glideRequests.load(lookupUri).apply(originalSize).into(imageViewLookup);
    Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
    glideRequests.load(photoUri).apply(originalSize).into(imageViewPhoto);
    Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
    glideRequests.load(displayPhotoUri).apply(originalSize).into(imageViewDisplayPhoto);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Uri(android.net.Uri)

Example 39 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project BGARefreshLayout-Android by bingoogolapple.

the class StaggeredRecyclerViewAdapter method fillData.

@Override
public void fillData(BGAViewHolderHelper viewHolderHelper, int position, StaggeredModel model) {
    viewHolderHelper.setText(R.id.tv_item_staggered_desc, model.desc);
    // 这里不知道当前图片的尺寸,加载成功后会乱跳
    Glide.with(mContext).load(model.icon).apply(new RequestOptions().placeholder(R.mipmap.staggered_holder).error(R.mipmap.staggered_holder).dontAnimate()).into((ImageView) viewHolderHelper.getView(R.id.iv_item_staggered_icon));
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 40 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project BGARefreshLayout-Android by bingoogolapple.

the class DataEngine method getCustomHeaderView.

public static View getCustomHeaderView(final Context context) {
    View headerView = View.inflate(context, R.layout.view_custom_header, null);
    final BGABanner banner = headerView.findViewById(R.id.banner);
    banner.setAdapter(new BGABanner.Adapter<ImageView, String>() {

        @Override
        public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
            Glide.with(itemView.getContext()).load(model).apply(new RequestOptions().placeholder(R.mipmap.holder).error(R.mipmap.holder).dontAnimate().centerCrop()).into(itemView);
        }
    });
    banner.setDelegate(new BGABanner.Delegate<ImageView, String>() {

        @Override
        public void onBannerItemClick(BGABanner banner, ImageView imageView, String model, int position) {
            Toast.makeText(banner.getContext(), "点击了第" + (position + 1) + "页", Toast.LENGTH_SHORT).show();
        }
    });
    App.getInstance().getEngine().getBannerModel().enqueue(new Callback<BannerModel>() {

        @Override
        public void onResponse(Call<BannerModel> call, Response<BannerModel> response) {
            BannerModel bannerModel = response.body();
            if (bannerModel == null) {
                return;
            }
            banner.setData(R.layout.view_image, bannerModel.imgs, bannerModel.tips);
        }

        @Override
        public void onFailure(Call<BannerModel> call, Throwable t) {
        }
    });
    return headerView;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) ImageView(android.widget.ImageView) View(android.view.View) ImageView(android.widget.ImageView) BannerModel(cn.bingoogolapple.refreshlayout.demo.model.BannerModel) BGABanner(cn.bingoogolapple.bgabanner.BGABanner)

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