当前位置: 首页>>代码示例>>Java>>正文


Java DrawableRequestBuilder类代码示例

本文整理汇总了Java中com.bumptech.glide.DrawableRequestBuilder的典型用法代码示例。如果您正苦于以下问题:Java DrawableRequestBuilder类的具体用法?Java DrawableRequestBuilder怎么用?Java DrawableRequestBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DrawableRequestBuilder类属于com.bumptech.glide包,在下文中一共展示了DrawableRequestBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDrawableRequestBuilder

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
/**
 * DrawableRequestBuilder 的通行配置
 * @param ctx 上下文
 * @param img ImageLoader封装器
 * @param typeRequest url or resource
 * @param <T> String or Integer
 * @return DrawableRequestBuilder<T>
 */
private <T> DrawableRequestBuilder<T> getDrawableRequestBuilder(Context ctx, ImageLoader img, DrawableTypeRequest<T> typeRequest) {
    DrawableRequestBuilder<T> builder = typeRequest
            .placeholder(img.placeHolder)
            .error(img.errorHolder)
            .diskCacheStrategy(DiskCacheStrategy.ALL);

    // transform image type
    int transType = img.transType;
    if (transType == LoaderConfig.TRANS_CIRCLE) {
        builder = builder.transform(new GlideCircleTransform(ctx));
    } else if (transType == LoaderConfig.TRANS_ROUND) {
        builder = builder.transform(new GlideRoundTransform(ctx));
    }

    // SCALE type
    if (img.scaleType == LoaderConfig.SCALE_CENTER_CROP) {
        builder = builder.centerCrop();
    } else if (img.scaleType == LoaderConfig.SCALE_FIT_CENTER) {
        builder = builder.fitCenter();
    }
    return builder;
}
 
开发者ID:BlueYangDroid,项目名称:MvpPlus,代码行数:31,代码来源:GlideImageLoaderStrategy.java

示例2: setImage

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
@BindingAdapter(value = {"imageUrl", "defaultImg", "radius"}, requireAll = false)
public static void setImage(ImageView imageView, String imageUrl, Drawable defaultImg, int radius) {
    DrawableRequestBuilder drawableTypeRequest = Glide.with(imageView.getContext()).load(imageUrl).crossFade();
    if (defaultImg != null) {
        drawableTypeRequest.placeholder(defaultImg).error(defaultImg);
    } else {
        drawableTypeRequest.placeholder(R.drawable.bg_defautl_imageview).error(R.drawable.bg_defautl_imageview);
    }
    if (radius > 0) {
        drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()),
                new RoundedCornersTransformation(imageView.getContext(), PixelUtil.dp2px(radius), 0));
    } else {
        drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()));
    }
    drawableTypeRequest.into(imageView);
}
 
开发者ID:chenzj-king,项目名称:RetrofitSample,代码行数:17,代码来源:DataBindingAdapter.java

示例3: instantiateItem

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
@Override
public Object instantiateItem(final ViewGroup container, int position) {
    final PhotoView view = new PhotoView(ImageBrowserActivity.this);
    view.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ImageFile file = mList.get(position);
    RequestManager requestManager = Glide.with(ImageBrowserActivity.this);
    DrawableRequestBuilder requestBuilder;
    if (file.getEditCount() > 0) {
        requestBuilder = requestManager.load(file.getEditedPath())
                .signature(new StringSignature(file.getEditCount() + ""));
    } else {
        requestBuilder = requestManager.load(file.getPath());
    }
    requestBuilder
            .crossFade()
            .placeholder(R.mipmap.ic_place_holder).into(view);
    container.addView(view);
    return view;
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:20,代码来源:ImageBrowserActivity.java

示例4: loadImage

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
@BindingAdapter({"imageAddress"})
public static void loadImage(final ImageView imageView, final String imageAddress) {

	if (imageAddress != null && imageAddress.startsWith("https://s3.amazonaws.com/bikedeboa/")) {

		Context context = imageView.getContext();
		// Hopefully the thumbnail is already disk cached and no requests are made
		DrawableRequestBuilder<String> thumbnailRequest = Glide
				.with(context)
				.load(imageAddress.replace("images/", "images/thumbs/"))
				.diskCacheStrategy(DiskCacheStrategy.ALL)
				.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
				.transform(new BlurTransformation(context));

		Glide.with(context)
				.load(imageAddress)
				.thumbnail(thumbnailRequest)
				.crossFade()
				.diskCacheStrategy(DiskCacheStrategy.SOURCE)
				.priority(Priority.HIGH)
				.into(imageView);
	}
}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:24,代码来源:BindingAdapters.java

示例5: loadingImageWithRoundTransform

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
/**
 * Using Glide to load image with round transform
 *
 * @param context          {@link Context}
 * @param imageView        {@link ImageView}
 * @param imagePath        {@link String}
 * @param isRoundTransform {@link Boolean}
 */
public static void loadingImageWithRoundTransform(final Context context,
                                                  final ImageView imageView,
                                                  final String imagePath,
                                                  final boolean isRoundTransform) {

    DrawableRequestBuilder<String> request = Glide.with(context)
            .load(imagePath)
            .placeholder(R.drawable.image_placeholder);

    if (isRoundTransform) {
        RoundedCornersTransformation transformation = new RoundedCornersTransformation(context,
                50, 0, RoundedCornersTransformation.CornerType.ALL);

        request.bitmapTransform(transformation);
    }

    request.into(imageView);
}
 
开发者ID:RubitOrganization,项目名称:Rubit,代码行数:27,代码来源:ImageUtils.java

示例6: onBindViewHolder

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    GankBean gankBean = mData.get(position);
    holder.tvHomeGankTitle.setText(gankBean.desc);
    holder.tvHomeGankAuthor.setText(gankBean.who);
    holder.tvHomeGankDate.setText(DateUtils.formatDateDetailDay(DateUtils.parseStringToDate(gankBean.publishedAt)));

    if (gankBean.images != null && !gankBean.images.isEmpty()) {
        holder.ivHomeGankImg.setVisibility(View.VISIBLE);
        DrawableRequestBuilder<String> requestBuilder = Glide.with(mContext)
                .load(gankBean.images.get(0)+"?imageView2/0/w/400")
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .error(R.color.accent)
                .crossFade();
        requestBuilder.into(holder.ivHomeGankImg);
    }else {
        holder.ivHomeGankImg.setVisibility(View.GONE);
    }
}
 
开发者ID:dalingge,项目名称:GankGirl,代码行数:20,代码来源:GankAdapter.java

示例7: loadAvatar

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
public static void loadAvatar(Context context, ImageView view,
                              @Nullable User user, @NotNull String url, int index,
                              @Nullable OnLoadImageListener<User> l) {
    DrawableRequestBuilder<Integer> thumbnailRequest = Glide.with(context)
            .load(R.drawable.default_avatar)
            .override(128, 128)
            .transform(new CircleTransformation(context))
            .diskCacheStrategy(DiskCacheStrategy.SOURCE);
    DrawableRequestBuilder<String> request = Glide.with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .override(128, 128)
            .transform(new CircleTransformation(context))
            .thumbnail(thumbnailRequest);
    if (l != null) {
        request.listener(new UserSaturationListener(context, view, user, index, l));
    }
    request.into(view);
}
 
开发者ID:WangDaYeeeeee,项目名称:Mysplash,代码行数:20,代码来源:ImageHelper.java

示例8: load

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
public void load(final DrawableRequestBuilder request) {
    if (getWidth() > 0 && getHeight() > 0) {
        request.dontAnimate().into(new SimpleTarget<GlideDrawable>(getWidth(), getHeight()) {
            @Override
            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                transition(resource);
            }
        });
    } else {
        getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                load(request);
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
}
 
开发者ID:TheAndroidMaster,项目名称:Pasta-for-Spotify,代码行数:19,代码来源:CustomImageView.java

示例9: onBindViewHolder

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
@Override
public void onBindViewHolder(GiphyViewHolder holder, int position) {
  GiphyImage image = images.get(position);

  holder.modelReady = false;
  holder.image      = image;
  holder.thumbnail.setAspectRatio(image.getGifAspectRatio());
  holder.gifProgress.setVisibility(View.GONE);

  DrawableRequestBuilder<String> thumbnailRequest = Glide.with(context)
                                                         .load(image.getStillUrl());

  if (Util.isLowMemory(context)) {
    Glide.with(context)
         .load(image.getStillUrl())
         .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context)))
         .diskCacheStrategy(DiskCacheStrategy.ALL)
         .into(holder.thumbnail);

    holder.setModelReady();
  } else {
    Glide.with(context)
         .load(image.getGifUrl())
         .thumbnail(thumbnailRequest)
         .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context)))
         .diskCacheStrategy(DiskCacheStrategy.ALL)
         .listener(holder)
         .into(holder.thumbnail);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:31,代码来源:GiphyAdapter.java

示例10: buildThumbnailGlideRequest

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
private GenericRequestBuilder buildThumbnailGlideRequest(@NonNull Slide slide, @NonNull MasterSecret masterSecret) {
  @SuppressWarnings("ConstantConditions")
  DrawableRequestBuilder<DecryptableUri> builder = Glide.with(getContext())
                                                        .load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
                                                        .diskCacheStrategy(DiskCacheStrategy.NONE)
                                                        .crossFade()
                                                        .transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint));

  if (slide.isInProgress()) return builder;
  else                      return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:ThumbnailView.java

示例11: build

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
public DrawableRequestBuilder<GlideDrawable> build() {
    //noinspection unchecked
    return createBaseRequest(requestManager, song, ignoreMediaStore)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(song));
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:9,代码来源:SongGlideRequest.java

示例12: onBindViewHolder

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
    ImageThumbnailHolder viewHolder = (ImageThumbnailHolder) holder;

    ImageFile file = mSelectedThumbnailList.get(position);

    RequestManager requestManager = Glide.with(ImageBrowserActivity.this);
    DrawableRequestBuilder requestBuilder;
    if (file.getEditCount() > 0) {
        requestBuilder = requestManager.load(file.getEditedPath())
                .signature(new StringSignature(file.getEditCount() + ""));
    } else {
        requestBuilder = requestManager.load(file.getPath());
    }
    requestBuilder.centerCrop()
            .crossFade()
            .placeholder(R.mipmap.ic_place_holder).into(viewHolder.imageView);

    if (mList.get(mCurrentIndex).getId() == file.getId()) {
        viewHolder.ivBlock.setVisibility(View.VISIBLE);
    } else {
        viewHolder.ivBlock.setVisibility(View.GONE);
    }
    if (mIsPreview) {
        viewHolder.shadow.setVisibility(file.isSelected() ? View.GONE : View.VISIBLE);
    }
    viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mViewPager.setCurrentItem(Integer.valueOf(mSelectedPosition.get(position)), false);
            mRecyclerView.scrollToPosition(position);
        }
    });
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:35,代码来源:ImageBrowserActivity.java

示例13: loadImage

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
/**
 * Uses Glide to load image into an ImageView
 *
 * @param weakRef the {@link WeakReference} of a given subclass of {@link Context}
 * @param params  the {@link GlideTaskParams}
 */
public static <CTX extends Context, T extends ImageView> void loadImage(@NonNull WeakReference<CTX> weakRef,
                                                                        @NonNull GlideTaskParams<T> params) {

    if (!AbstractWeakReferenceUtils.isAlive(weakRef)) {
        return;
    }

    DrawableRequestBuilder<String> requestBuilder = Glide.with(weakRef.get()).load(params.getPath())
            .diskCacheStrategy(DiskCacheStrategy.ALL);

    load(applyDimens(requestBuilder, params), params);
}
 
开发者ID:Tenor-Inc,项目名称:tenor-android-core,代码行数:19,代码来源:ImageLoader.java

示例14: onCreate

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_expand_image);

	ActionBar actionBar = getSupportActionBar();
	actionBar.hide();

	Bundle extras = getIntent().getExtras();
	int rackId = 0;
	if (extras != null) {
		rackId = extras.getInt(RACK_ID);
	} else {
		// Something's not right, finish this activity
		this.finish();
	}

	DetailViewModel detailViewModel = new DetailViewModel(rackId, this);
	PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);

	// Request cached thumbnail
	DrawableRequestBuilder<String> thumbnailRequest = Glide
			.with(this)
			.load(detailViewModel.getImage().replace("images/", "images/thumbs/"))
			.diskCacheStrategy(DiskCacheStrategy.ALL)
			.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
			.transform(new BlurTransformation(this));

	Glide.with(this)
			.load(detailViewModel.getImage())
			.thumbnail(thumbnailRequest)
			.crossFade()
			.diskCacheStrategy(DiskCacheStrategy.SOURCE)
			.priority(Priority.HIGH)
			.into(photoView);

}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:38,代码来源:ExpandImageActivity.java

示例15: build

import com.bumptech.glide.DrawableRequestBuilder; //导入依赖的package包/类
public DrawableRequestBuilder<GlideDrawable> build() {
    //noinspection unchecked
    return createBaseRequest(requestManager, artist, noCustomImage, forceDownload)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(artist));
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:11,代码来源:ArtistGlideRequest.java


注:本文中的com.bumptech.glide.DrawableRequestBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。