本文整理汇总了Java中com.bumptech.glide.request.RequestOptions类的典型用法代码示例。如果您正苦于以下问题:Java RequestOptions类的具体用法?Java RequestOptions怎么用?Java RequestOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestOptions类属于com.bumptech.glide.request包,在下文中一共展示了RequestOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
image = (Image) getIntent().getSerializableExtra(EXTRA_IMAGE);
if (image == null) {
finish();
} else {
TouchImageView imageView = findViewById(R.id.activity_image_image);
Glide.with(this)
.load(image.getUrl())
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
.into(imageView);
setTitle(image.getName());
}
}
示例2: setupGlideOptions
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void setupGlideOptions() {
options = new RequestOptions();
if (isShapeCircle) {
if (Defaults.CIRCLE_RADIUS > 0) {
options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));
} else {
options.circleCrop();
}
}
options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT);
options.placeholder(placeholder_image);
options.priority(Priority.HIGH);
}
示例3: onViewCreated
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ImageView wallpaper = view.findViewById(R.id.img_wallpaper);
ImageView icon = view.findViewById(R.id.img_icon);
final ApplicationItem applicationItem = (ApplicationItem) getArguments().getSerializable(KEY_APP_ITEM);
Glide.with(getContext()).load(applicationItem.getIconUrl()).apply(new RequestOptions().centerCrop()).into(icon);
Glide.with(getContext()).load(applicationItem.getWallpaperUrl()).apply(new RequestOptions().centerCrop()).into(wallpaper);
TextView txtName = view.findViewById(R.id.txt_name);
txtName.setText(applicationItem.getName());
view.findViewById(R.id.root_view).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String applicationId = applicationItem.getApplicationId();
FirebaseAnalytics.getInstance(getActivity()).logEvent(applicationId, new Bundle());
StoreUtil.gotoPlayStore(getActivity(), applicationId);
}
});
}
示例4: showImage
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
public static void showImage(Activity activity, ImageView imageView, String image,
Drawable placeholder, boolean anim) {
RequestOptions requestOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL);
RequestBuilder<Drawable> builder = Glide.with(activity)
.load(image);
if (placeholder != null) {
requestOptions.placeholder(placeholder); //设置占位图片
}
if (!anim) {
requestOptions.dontAnimate();
}
builder.apply(requestOptions);
builder.into(imageView);
}
示例5: load_withColorDrawable_fixedSize_requiredUnitTransform_returnsOriginalDrawable
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
/**
* Transformations that do nothing can simply return the original Bitmap.
*/
@Test
public void load_withColorDrawable_fixedSize_requiredUnitTransform_returnsOriginalDrawable()
throws ExecutionException, InterruptedException {
Drawable colorDrawable = new ColorDrawable(Color.RED);
Drawable result = Glide.with(context)
.load(colorDrawable)
.apply(new RequestOptions()
.centerCrop())
.submit(100, 100)
.get();
assertThat(result).isInstanceOf(ColorDrawable.class);
assertThat(((ColorDrawable) result).getColor()).isEqualTo(Color.RED);
}
示例6: updateMovieDetails
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
private void updateMovieDetails(MovieOverviewModel movie){
//Update player poster
Glide.with(getBaseContext())
.load("https://image.tmdb.org/t/p/w640/" + movie.getPosterPath())
.thumbnail(1)
.transition(withCrossFade())
.apply(new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.ALL)
)
.into(playerPoster);
//Movie backdrop poster
Glide.with(getBaseContext()).load(
"https://image.tmdb.org/t/p/w1300_and_h730_bestv2/" + movie.getBackdropPath())
.thumbnail(1)
.transition(withCrossFade())
.apply(new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.ALL)
)
.into(backdrop);
//Player titles
getSupportActionBar().setTitle(movie.getTitle());
}
示例7: into
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
/**
* Sets the {@link ImageView} the resource will be loaded into, cancels any existing loads into
* the view, and frees any resources Glide may have previously loaded into the view so they may be
* reused.
*
* @see RequestManager#clear(Target)
*
* @param view The view to cancel previous loads for and load the new resource into.
* @return The
* {@link com.bumptech.glide.request.target.Target} used to wrap the given {@link ImageView}.
*/
public ViewTarget<ImageView, TranscodeType> into(ImageView view) {
Util.assertMainThread();
Preconditions.checkNotNull(view);
RequestOptions requestOptions = this.requestOptions;
if (!requestOptions.isTransformationSet()
&& requestOptions.isTransformationAllowed()
&& view.getScaleType() != null) {
// Clone in this method so that if we use this RequestBuilder to load into a View and then
// into a different target, we don't retain the transformation applied based on the previous
// View's scale type.
switch (view.getScaleType()) {
case CENTER_CROP:
requestOptions = requestOptions.clone().optionalCenterCrop();
break;
case CENTER_INSIDE:
requestOptions = requestOptions.clone().optionalCenterInside();
break;
case FIT_CENTER:
case FIT_START:
case FIT_END:
requestOptions = requestOptions.clone().optionalFitCenter();
break;
case FIT_XY:
requestOptions = requestOptions.clone().optionalCenterInside();
break;
case CENTER:
case MATRIX:
default:
// Do nothing.
}
}
return into(
glideContext.buildImageViewTarget(view, transcodeClass),
/*targetListener=*/ null,
requestOptions);
}
示例8: obtainRequest
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
private Request obtainRequest(
Target<TranscodeType> target,
RequestListener<TranscodeType> targetListener,
RequestOptions requestOptions,
RequestCoordinator requestCoordinator,
TransitionOptions<?, ? super TranscodeType> transitionOptions,
Priority priority,
int overrideWidth,
int overrideHeight) {
return SingleRequest.obtain(
context,
glideContext,
model,
transcodeClass,
requestOptions,
overrideWidth,
overrideHeight,
priority,
target,
targetListener,
requestListener,
requestCoordinator,
glideContext.getEngine(),
transitionOptions.getTransitionFactory());
}
示例9: testLoadColorDrawable_withNonUnitBitmapTransformation_returnsBitmapDrawable
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
@Test
public void testLoadColorDrawable_withNonUnitBitmapTransformation_returnsBitmapDrawable() {
ColorDrawable colorDrawable = new ColorDrawable(Color.RED);
requestManager
.load(colorDrawable)
.apply(new RequestOptions()
.override(100, 100)
.circleCrop())
.into(target);
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
verify(target).onResourceReady(argumentCaptor.capture(), isA(Transition.class));
Object result = argumentCaptor.getValue();
assertThat(result).isInstanceOf(BitmapDrawable.class);
Bitmap bitmap = ((BitmapDrawable) result).getBitmap();
assertThat(bitmap.getWidth()).isEqualTo(100);
assertThat(bitmap.getHeight()).isEqualTo(100);
}
示例10: onBindViewHolder
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
@Override
public void onBindViewHolder(GenericRecyclerViewViewHolder holder, int position) {
final Image image = imageList.get(position);
Glide.with(holder.getView("imageView").getContext())
.load(image.getUrl())
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
.into(holder.getView("imageView", ImageView.class));
holder.getView("imageName", TextView.class).setText(image.getName());
holder.getView("imageView").setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onImageClickedListener.onImageClicked(image, v);
}
});
}
示例11: applyDefault
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
public GlideLoader applyDefault(int placeholderId, int errorId) {
mRequestOptions = new RequestOptions()
.centerCrop()
.priority(Priority.HIGH)
.diskCacheStrategy(DiskCacheStrategy.ALL);
if(placeholderId != 0) {
mRequestOptions.placeholder(placeholderId);
}
if(errorId != 0) {
mRequestOptions.error(errorId);
}
return this;
}
示例12: instantiateItem
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
if (meizis == null) {
return null;
}
if (mViews == null) {
mViews = new PhotoView[meizis.size()];
for (int i = 0; i < 4; i++) {
mViews[i] = new PhotoView(container.getContext());
mViews[i].setTransitionName(meizis.get(position).get_id());
mViews[i].setBackgroundColor(Color.BLACK);
}
}
if (mViews[position] == null) {
mViews[position] = mViews[position % 4];
}
container.addView(mViews[position], ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
Log.e("TAG", "addView: " + position);
RequestOptions options = new RequestOptions()
.format(DecodeFormat.PREFER_ARGB_8888)
.diskCacheStrategy(DiskCacheStrategy.DATA);
Glide.with(GalleryActivity.this)
.load(meizis.get(position).getUrl())
.apply(options)
.listener(new CallbackListener(mViews[position], position))
.into(mViews[position]);
return mViews[position];
}
示例13: GlideContext
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
public GlideContext(Context context, Registry registry,
ImageViewTargetFactory imageViewTargetFactory, RequestOptions defaultRequestOptions,
Engine engine, ComponentCallbacks2 componentCallbacks, int logLevel) {
super(context.getApplicationContext());
this.registry = registry;
this.imageViewTargetFactory = imageViewTargetFactory;
this.defaultRequestOptions = defaultRequestOptions;
this.engine = engine;
this.componentCallbacks = componentCallbacks;
this.logLevel = logLevel;
mainHandler = new Handler(Looper.getMainLooper());
}
示例14: getRequestOptions
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
private static RequestOptions getRequestOptions() {
RequestOptions requestOptions = new RequestOptions()
.centerCrop() // 填充方式
.priority(Priority.HIGH) //优先级
.diskCacheStrategy(DiskCacheStrategy.ALL); //缓存策略
return requestOptions;
}
示例15: loadImageViewLodingSize
import com.bumptech.glide.request.RequestOptions; //导入依赖的package包/类
public static void loadImageViewLodingSize(Context mContext, String path, int width, int height, ImageView mImageView, int lodingImage, int errorImageView) {
RequestOptions options = new RequestOptions();
final RequestOptions requestOptions = options
.override(width, height)
.placeholder(lodingImage)
.error(errorImageView);
Glide.with(mContext).load(path).apply(options).into(mImageView);
}