use of com.bumptech.glide.request.RequestOptions in project Habba18 by chiragsastry1996.
the class HomeFragment method setUpViews.
private void setUpViews() {
MainActivity parentActivity = (MainActivity) getActivity();
try {
FirebaseMessaging.getInstance().subscribeToTopic("news");
String token = FirebaseInstanceId.getInstance().getToken();
Log.d("token", token);
registerToken(token);
} catch (Exception e) {
System.out.println("Token Error");
}
left = (Button) parentView.findViewById(R.id.left);
right = (Button) parentView.findViewById(R.id.right);
left.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
resideMenu.openMenu(ResideMenu.DIRECTION_LEFT);
}
});
right.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
resideMenu.openMenu(ResideMenu.DIRECTION_RIGHT);
}
});
carouselView = (CarouselView) parentView.findViewById(R.id.carouselView);
carouselView.setPageCount(sampleImages.length);
carouselView.setImageListener(new ImageListener() {
@Override
public void setImageForPosition(int position, ImageView imageView) {
Glide.with(getContext()).load(sampleImages[position]).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.drawable.slider1)).into(imageView);
}
});
imageView1 = (ImageView) parentView.findViewById(R.id.imageView11);
try {
final pl.droidsonroids.gif.GifDrawable gifFromResource = new pl.droidsonroids.gif.GifDrawable(getResources(), R.drawable.landing);
imageView1.setImageDrawable(gifFromResource);
} catch (IOException e) {
e.printStackTrace();
}
imageView1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// do nothing
}
});
}
use of com.bumptech.glide.request.RequestOptions in project ring-client-android by savoirfairelinux.
the class CallFragment method updateContactBubble.
@Override
public void updateContactBubble(@NonNull final CallContact contact) {
String username = contact.getRingUsername();
String displayName = contact.getDisplayName();
String ringId = contact.getIds().get(0);
Drawable contactPicture = AvatarFactory.getAvatar(getActivity(), contact.getPhoto(), username, ringId);
Log.d(TAG, "updateContactBubble: username=" + username + ", ringId=" + ringId);
RequestOptions glideOptions = AvatarFactory.getGlideOptions(true, false);
getActivity().runOnUiThread(() -> {
boolean hasProfileName = displayName != null && !displayName.contentEquals(username);
if (hasProfileName) {
contactBubbleNumTxt.setVisibility(View.VISIBLE);
contactBubbleTxt.setText(displayName);
contactBubbleNumTxt.setText(username);
} else {
contactBubbleNumTxt.setVisibility(View.GONE);
contactBubbleTxt.setText(username);
}
if (firstUpdate) {
firstUpdate = false;
Glide.with(getActivity()).load(contactPicture).apply(glideOptions).into(contactBubbleView);
}
});
}
use of com.bumptech.glide.request.RequestOptions in project Zom-Android by zom.
the class GalleryMediaViewHolder method setThumbnail.
/**
* @param contentResolver
* @param mediaUri
*/
private void setThumbnail(ContentResolver contentResolver, Uri mediaUri) {
RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.drawable.ic_photo_library_white_36dp);
if (SecureMediaStore.isVfsUri(mediaUri)) {
try {
info.guardianproject.iocipher.File fileMedia = new info.guardianproject.iocipher.File(mediaUri.getPath());
if (fileMedia.exists()) {
Log.d("Gallery", "VFS loading: " + mediaUri.toString());
Glide.with(context).asBitmap().load(new info.guardianproject.iocipher.FileInputStream(fileMedia)).apply(options).into(mMediaThumbnail);
} else {
Log.d("Gallery", "VFS file not found: " + mediaUri.toString());
Glide.with(context).asBitmap().load(R.drawable.broken_image_large).apply(options).into(mMediaThumbnail);
}
} catch (Exception e) {
Log.e(ImApp.LOG_TAG, "unable to load thumbnail: " + e.getMessage());
}
} else if (mediaUri.getScheme() != null && mediaUri.getScheme().equals("asset")) {
String assetPath = "file:///android_asset/" + mediaUri.getPath().substring(1);
Glide.with(context).asBitmap().load(assetPath).apply(options).into(mMediaThumbnail);
} else {
Glide.with(context).asBitmap().load(mediaUri).apply(options).into(mMediaThumbnail);
}
}
use of com.bumptech.glide.request.RequestOptions in project TicktockMusic by Lauzy.
the class GlideImageLoaderStrategy method display.
@Override
public void display(Context context, ImageConfig imageConfig) {
RequestOptions options = getOptions(context, imageConfig);
Object url = getPath(imageConfig);
if (!imageConfig.isAsBitmap()) {
RequestBuilder<Drawable> requestBuilder = Glide.with(context).load(url).apply(options);
if (!imageConfig.isRound() && imageConfig.getDuration() != 0) {
requestBuilder = requestBuilder.transition(new DrawableTransitionOptions().crossFade(imageConfig.getDuration()));
}
requestBuilder.into(imageConfig.getImageView());
} else {
RequestBuilder<Bitmap> requestBuilder = Glide.with(context).asBitmap().load(url).apply(options);
if (!imageConfig.isRound() && imageConfig.getDuration() != 0) {
requestBuilder = requestBuilder.transition(new BitmapTransitionOptions().crossFade(imageConfig.getDuration()));
}
requestBuilder.into(imageConfig.getTarget());
}
}
use of com.bumptech.glide.request.RequestOptions in project TicktockMusic by Lauzy.
the class GlideImageLoaderStrategy method getOptions.
/**
* Glide 配置
*
* @param context context
* @param imageConfig 配置
* @return Glide配置
*/
private RequestOptions getOptions(Context context, ImageConfig imageConfig) {
RequestOptions options = new RequestOptions().placeholder(imageConfig.getDefaultRes()).error(imageConfig.getErrorRes());
if (imageConfig.isRound()) {
if (imageConfig.getCornerSize() == 0) {
options.transform(new GlideCornerTransformation(context));
} else {
options.transform(new GlideCornerTransformation(context, imageConfig.getCornerSize()));
}
}
// 默认无缓存
DiskCacheStrategy strategy = DiskCacheStrategy.RESOURCE;
switch(imageConfig.getCacheStrategy()) {
case ImageConfig.CACHE_NONE:
strategy = DiskCacheStrategy.NONE;
break;
case ImageConfig.CACHE_ALL:
strategy = DiskCacheStrategy.ALL;
break;
case // 加载后缓存
ImageConfig.CACHE_RESULT:
strategy = DiskCacheStrategy.RESOURCE;
break;
case // 源数据缓存
ImageConfig.CACHE_SOURCE:
strategy = DiskCacheStrategy.DATA;
break;
case ImageConfig.CACHE_AUTO:
strategy = DiskCacheStrategy.AUTOMATIC;
break;
}
options.diskCacheStrategy(strategy);
options.skipMemoryCache(imageConfig.isSkipMemoryCache());
return options;
}
Aggregations