當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。