本文整理汇总了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) {
}
});
}
示例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);
}
示例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);
}
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例8: TeamActiveAdapter
import com.bumptech.glide.Glide; //导入方法依赖的package包/类
public TeamActiveAdapter(Context cxt) {
this.context = cxt;
mManager = Glide.with(context);
}
示例9: providesRequestManager
import com.bumptech.glide.Glide; //导入方法依赖的package包/类
@Provides
@Singleton
RequestManager providesRequestManager(Fragment fragment) {
return Glide.with(fragment);
}
示例10: GlideUtils
import com.bumptech.glide.Glide; //导入方法依赖的package包/类
private GlideUtils(Fragment fragment) {
mGlide = Glide.with(fragment);
}
示例11: UploadRecyclerAdapter
import com.bumptech.glide.Glide; //导入方法依赖的package包/类
public UploadRecyclerAdapter(@NonNull Context context) {
photoList = new UploadPhotoList(this);
glide = Glide.with(context);
}
示例12: with
import com.bumptech.glide.Glide; //导入方法依赖的package包/类
/**
* @see Glide#with(Activity)
*/
public static GlideRequests with(Activity activity) {
return (GlideRequests) Glide.with(activity);
}
示例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());
}
示例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());
}
示例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;
}