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


Java Glide.with方法代码示例

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


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

示例1: onBindViewHolder

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ChannelCard holder, int position) {
    ChannelModel channel=channels.get(position);
    holder.aid=channel.anchor.id;
    holder.chid=channel.id;
    RequestManager glide=Glide.with(holder.anchorIcon.getContext());
    glide.load(channel.icon).into(holder.channelIcon);
    glide.load(channel.anchor.user.icon).into(holder.anchorIcon);
    holder.brief.setText(channel.brief);
    holder.classify.setText(channel.classify);
    holder.onLineListenor.setText(String.valueOf(channel.listenorNum));
    holder.menu.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

        }
    });
}
 
开发者ID:toonine,项目名称:BalaFM,代码行数:19,代码来源:OrderChannelActivity.java

示例2: onCreate

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  paths = new ArrayList<>();

  Bundle bundle = getArguments();

  if (bundle != null) {
    String[] pathArr = bundle.getStringArray(ARG_PATH);
    paths.clear();
    if (pathArr != null) {

      paths = new ArrayList<>(Arrays.asList(pathArr));
    }

    hasAnim         = bundle.getBoolean(ARG_HAS_ANIM);
    currentItem     = bundle.getInt(ARG_CURRENT_ITEM);
    thumbnailTop    = bundle.getInt(ARG_THUMBNAIL_TOP);
    thumbnailLeft   = bundle.getInt(ARG_THUMBNAIL_LEFT);
    thumbnailWidth  = bundle.getInt(ARG_THUMBNAIL_WIDTH);
    thumbnailHeight = bundle.getInt(ARG_THUMBNAIL_HEIGHT);
  }

  mPagerAdapter = new PhotoPagerAdapter(Glide.with(this), paths);
}
 
开发者ID:malijie,项目名称:PhotoPicker-master,代码行数:26,代码来源:ImagePagerFragment.java

示例3: onCreate

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

    setSupportActionBar(findViewById(R.id.toolbar));

    bucketsAdapter = new BucketsAdapter(
            this, Glide.with(this), this);

    final RecyclerView bucketsView = findViewById(R.id.buckets);
    bucketsView.setLayoutManager(new GridLayoutManager(this, 2));
    bucketsView.setAdapter(bucketsAdapter);

    if (ActivityCompat.checkSelfPermission(this, WRITE_EXTERNAL_STORAGE) == PERMISSION_GRANTED) {
        granted = true;
    } else {
        ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE);
    }
}
 
开发者ID:oxoooo,项目名称:nomedia,代码行数:21,代码来源:MainActivity.java

示例4: onCreate

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setRetainInstance(true);

  mGlideRequestManager = Glide.with(this);

  directories = new ArrayList<>();
  originalPhotos = getArguments().getStringArrayList(EXTRA_ORIGIN);

  column = getArguments().getInt(EXTRA_COLUMN, DEFAULT_COLUMN_NUMBER);
  boolean showCamera = getArguments().getBoolean(EXTRA_CAMERA, true);
  boolean previewEnable = getArguments().getBoolean(EXTRA_PREVIEW_ENABLED, true);

  photoGridAdapter = new PhotoGridAdapter(mContext, mGlideRequestManager, directories, originalPhotos, column);
  photoGridAdapter.setShowCamera(showCamera);
  photoGridAdapter.setPreviewEnable(previewEnable);

  Bundle mediaStoreArgs = new Bundle();

  boolean showGif = getArguments().getBoolean(EXTRA_GIF);
  mediaStoreArgs.putBoolean(EXTRA_SHOW_GIF, showGif);
  MediaStoreHelper.getPhotoDirs(getActivity(), mediaStoreArgs,
      new MediaStoreHelper.PhotosResultCallback() {
        @Override public void onResultCallback(List<PhotoDirectory> dirs) {
          directories.clear();
          directories.addAll(dirs);
          photoGridAdapter.notifyDataSetChanged();
          listAdapter.notifyDataSetChanged();
          adjustHeight();
        }
      });

  captureManager = new ImageCaptureManager(getActivity());
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:36,代码来源:PhotoPickerFragment.java

示例5: RecyclerViewPreloader

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
/**
 * Helper constructor that accepts an {@link Activity}.
 */
public RecyclerViewPreloader(Activity activity,
    PreloadModelProvider<T> preloadModelProvider,
    PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload) {
  this(Glide.with(activity), preloadModelProvider, preloadDimensionProvider, maxPreload);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:RecyclerViewPreloader.java

示例6: loadImage

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
/**
 * 根据GlideImageConfig中的配置进行加载图片
 *
 * @param ctx    context
 * @param config 图片加载
 */
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    if (ctx == null) throw new IllegalStateException("Context is required");
    if (config == null) throw new IllegalStateException("GlideImageConfig is required");
    if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
    if (config.getImageView() == null) throw new IllegalStateException("imageview is required");


    RequestManager manager;

    manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
 
开发者ID:Wan7451,项目名称:mvparms,代码行数:52,代码来源:GlideImageLoaderStrategy.java

示例7: load

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Override
public void load(Context context, GlideImageConfig config) {
    this.check(context, config);

    RequestManager manager = Glide.with(context);

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .crossFade()// 默认显示淡入淡出动画
            ;

    // 缓存策略
    switch (config.getCacheStrategy()) {
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    // 改变图形的形状
    if (config.getTransformation() != null) {
        requestBuilder.transform(config.getTransformation());
    }

    // 设置占位符
    if (config.getPlaceholder() != 0) {
        requestBuilder.placeholder(config.getPlaceholder());
    }

    // 设置错误的图片
    if (config.getError() != 0) {
        requestBuilder.error(config.getError());
    }

    requestBuilder.into(config.getImageView());
}
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:45,代码来源:GlideImageLoader.java

示例8: TeamActiveAdapter

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
public TeamActiveAdapter(Context cxt) {
    this.context = cxt;
    mManager = Glide.with(context);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:5,代码来源:TeamActiveAdapter.java

示例9: providesRequestManager

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Provides
@Singleton
RequestManager providesRequestManager(Fragment fragment) {
    return Glide.with(fragment);
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:6,代码来源:LibsModule.java

示例10: GlideUtils

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
private GlideUtils(Fragment fragment) {
    mGlide = Glide.with(fragment);
}
 
开发者ID:iAcn,项目名称:MBEStyle,代码行数:4,代码来源:GlideUtils.java

示例11: UploadRecyclerAdapter

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
public UploadRecyclerAdapter(@NonNull Context context) {
    photoList = new UploadPhotoList(this);
    glide = Glide.with(context);
}
 
开发者ID:jsaund,项目名称:RxUploader,代码行数:5,代码来源:UploadRecyclerAdapter.java

示例12: with

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
/**
 * @see Glide#with(Activity)
 */
public static GlideRequests with(Activity activity) {
  return (GlideRequests) Glide.with(activity);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:GlideApp.java

示例13: loadImage

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    RequestManager manager;
    if (ctx instanceof Activity)//如果是activity则可以使用Activity的生命周期
        manager = Glide.with((Activity) ctx);
    else
        manager = Glide.with(ctx);

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:42,代码来源:GlideImageLoaderStrategy.java

示例14: loadImage

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Override
    public void loadImage(Context ctx, GlideImageConfig config) {
        if (ctx == null) throw new IllegalStateException("Context is required");
        if (config == null) throw new IllegalStateException("GlideImageConfig is required");
        //这里不抛异常空的就显示默认图片
//        if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
        if (config.getImageView() == null) throw new IllegalStateException("imageview is required");


        RequestManager manager;

        manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

        DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
                .centerCrop();

        if (config.fitCenter()) {
            requestBuilder.fitCenter();
        }

        if (config.dontAnimation()) {
            requestBuilder.dontAnimate();
        } else {
            requestBuilder.crossFade();
        }

        switch (config.getCacheStrategy()) {//缓存策略
            case 0:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
                break;
            case 1:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
                break;
            case 2:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
                break;
            case 3:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
                break;
        }

        if (config.getTransformation() != null) {//glide用它来改变图形的形状
            requestBuilder.transform(config.getTransformation());
        }

        //设置占位符
        if (config.getPlaceholder() != null) {
            requestBuilder.placeholder(config.getPlaceholder());
        } else if (config.getPlaceholderResId() != 0) {
            requestBuilder.placeholder(config.getPlaceholderResId());
        }

        if (config.getErrorPic() != 0)//设置错误的图片
            requestBuilder.error(config.getErrorPic());

        requestBuilder.skipMemoryCache(config.skipMemoryCache());

        requestBuilder.into(config.getImageView());
    }
 
开发者ID:BaoBaoJianqiang,项目名称:CustomListView,代码行数:60,代码来源:GlideImageLoaderStrategy.java

示例15: onCreateView

import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Override
public View onCreateView(
    @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  Bundle args = Preconditions.checkNotNull(getArguments());
  photoSize = args.getInt(IMAGE_SIZE_KEY);
  thumbnail = args.getBoolean(THUMBNAIL_KEY);

  fullRequest = GlideApp.with(this)
      .asDrawable()
      .centerCrop();

  thumbnailRequest = GlideApp.with(this)
      .asDrawable()
      .centerCrop()
      .override(Api.SQUARE_THUMB_SIZE);

  preloadRequest =
      thumbnail ? thumbnailRequest.clone().priority(Priority.HIGH) : fullRequest;

  final View result = inflater.inflate(R.layout.flickr_photo_grid, container, false);

  final int gridMargin = getResources().getDimensionPixelOffset(R.dimen.grid_margin);
  int spanCount = getResources().getDisplayMetrics().widthPixels / (photoSize + (2 * gridMargin));
  grid = (RecyclerView) result.findViewById(R.id.flickr_photo_grid);
  layoutManager = new GridLayoutManager(getActivity(), spanCount);
  grid.setLayoutManager(layoutManager);

  grid.addItemDecoration(new RecyclerView.ItemDecoration() {
    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
        RecyclerView.State state) {
      outRect.set(gridMargin, gridMargin, gridMargin, gridMargin);
    }
  });
  grid.setRecyclerListener(new RecyclerView.RecyclerListener() {
    @Override
    public void onViewRecycled(RecyclerView.ViewHolder holder) {
      PhotoViewHolder photoViewHolder = (PhotoViewHolder) holder;
      GlideApp.with(FlickrPhotoGrid.this).clear(photoViewHolder.imageView);
    }
  });

  int heightCount = getResources().getDisplayMetrics().heightPixels / photoSize;
  grid.getRecycledViewPool().setMaxRecycledViews(0, spanCount * heightCount * 2);
  grid.setItemViewCacheSize(0);
  adapter = new PhotoAdapter();
  grid.setAdapter(adapter);

  FixedPreloadSizeProvider<Photo> preloadSizeProvider =
      new FixedPreloadSizeProvider<>(photoSize, photoSize);
  RecyclerViewPreloader<Photo> preloader = new RecyclerViewPreloader<>(Glide.with(this), adapter,
      preloadSizeProvider, args.getInt(PRELOAD_KEY));
  grid.addOnScrollListener(preloader);

  if (currentPhotos != null) {
    adapter.setPhotos(currentPhotos);
  }

  if (savedInstanceState != null) {
    int index = savedInstanceState.getInt(STATE_POSITION_INDEX);
    grid.scrollToPosition(index);
  }

  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:66,代码来源:FlickrPhotoGrid.java


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