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


Java RequestOptions类代码示例

本文整理汇总了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());
    }
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:26,代码来源:ImageActivity.java

示例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);
}
 
开发者ID:prashantsaini1,项目名称:titanium-android-imagepicker,代码行数:18,代码来源:ImageViewerActivity.java

示例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);
        }
    });
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:22,代码来源:ApplicationFragment.java

示例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);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:19,代码来源:G.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DrawableTransformationTest.java

示例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());
}
 
开发者ID:tgbMedia,项目名称:Android-app,代码行数:25,代码来源:VideoPlayerActivity.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:50,代码来源:RequestBuilder.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RequestBuilder.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:GlideTest.java

示例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);
        }
    });
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:19,代码来源:ImageAdapter.java

示例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;
}
 
开发者ID:DyncKathline,项目名称:LiveGiftLayout,代码行数:14,代码来源:GlideLoader.java

示例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];
}
 
开发者ID:YMlion,项目名称:leisure-glance,代码行数:30,代码来源:GalleryActivity.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:GlideContext.java

示例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;
}
 
开发者ID:AriesHoo,项目名称:TitleBarView,代码行数:8,代码来源:GlideManager.java

示例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);
    }
 
开发者ID:zhangYanGitHub,项目名称:model_master,代码行数:10,代码来源:GlideUtil.java


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