use of com.bumptech.glide.request.RequestOptions in project BaseProject by feer921.
the class ImageUtil method loadImage.
// public static void loadImage(Context context, String picUrl, int newWidth, int newHeight, Drawable holderDrawable,
// Drawable errorDrawable, ImageView targetIv
// , Callback callback) {
// RequestCreator loadRequest = loadImageRequest(context, picUrl,null,0);
//
// if (newWidth > 0 && newHeight > 0) {
// loadRequest.resize(newWidth, newHeight);
// loadRequest.centerCrop();
// }
// else{
// // loadRequest.fit();
// }
// if (holderDrawable != null) {
// loadRequest.placeholder(holderDrawable);
// }
// else{
// loadRequest.noPlaceholder();
// }
// if (errorDrawable != null) {
// loadRequest.error(errorDrawable);
// }
// loadRequest.noFade();
// loadRequest.into(targetIv, callback);
// }
public static void loadImage(Context context, String picUrl, int newWidth, int newHeight, Drawable holderDrawable, Drawable errorDrawable, ImageView targetIv, RequestListener callback) {
RequestBuilder requestBuilder = loadImageRequest(context, picUrl);
RequestOptions options = new RequestOptions();
if (newWidth > 0 && newHeight > 0) {
options.override(newWidth, newHeight).centerCrop();
} else {
// loadRequest.fit();
}
if (holderDrawable != null) {
options.placeholder(holderDrawable);
} else {
// loadRequest.noPlaceholder();
}
if (errorDrawable != null) {
options.error(errorDrawable);
}
options.dontAnimate();
if (callback != null) {
requestBuilder.listener(callback);
}
requestBuilder.apply(options).into(targetIv);
}
use of com.bumptech.glide.request.RequestOptions in project ARD by MobileApplicationsClub.
the class NavigationDrawerListener method onDataChange.
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
if (dataSnapshot.child(AHC.FDR_NAV_DRAWER_TITLE).exists()) {
final String navDrawerTitleText = dataSnapshot.child(AHC.FDR_NAV_DRAWER_TITLE).getValue(String.class);
if (!Objects.equals(navDrawerTitleText, MainActivity.navDrawerTitleText)) {
navDrawerTitle.setText(navDrawerTitleText);
MainActivity.navDrawerTitleText = navDrawerTitleText;
}
}
if (dataSnapshot.child(AHC.FDR_NAV_DRAWER_SUBTITLE).exists()) {
final String navDrawerSubtitleText = dataSnapshot.child(AHC.FDR_NAV_DRAWER_SUBTITLE).getValue(String.class);
if (!Objects.equals(navDrawerSubtitleText, MainActivity.navDrawerSubtitleText)) {
navDrawerSubtitle.setText(navDrawerSubtitleText);
MainActivity.navDrawerSubtitleText = navDrawerSubtitleText;
}
}
if (dataSnapshot.child(AHC.FDR_NAV_DRAWER_IMAGE_LIST).exists() && dataSnapshot.child(AHC.FDR_NAV_DRAWER_IMAGE_LIST).getChildrenCount() > 0) {
final ArrayList<String> navDrawerImageList = new ArrayList<>();
for (final DataSnapshot childSnapshot : dataSnapshot.child(AHC.FDR_NAV_DRAWER_IMAGE_LIST).getChildren()) {
navDrawerImageList.add(childSnapshot.getValue(String.class));
}
if (!Objects.equals(navDrawerImageList, MainActivity.navDrawerImageList)) {
final Random rand = new Random();
final String navDrawerImageURL = navDrawerImageList.get(rand.nextInt(navDrawerImageList.size()));
final RequestOptions navDrawerImageOptions = new RequestOptions().placeholder(context.getDrawable(R.drawable.nav_drawer_default_image));
Glide.with(context).load(navDrawerImageURL).transition(DrawableTransitionOptions.withCrossFade().crossFade(MainActivity.NAV_DRAWER_BACKGROUND_ANIM_DUR)).apply(navDrawerImageOptions).into(navDrawerImageView);
MainActivity.navDrawerImageURL = navDrawerImageURL;
MainActivity.navDrawerImageList = navDrawerImageList;
}
}
}
use of com.bumptech.glide.request.RequestOptions in project Simple-Dilbert by smarek.
the class WidgetProvider method updateAppWidget.
private static void updateAppWidget(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId) {
final DilbertPreferences prefs = new DilbertPreferences(context);
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
views.setOnClickPendingIntent(R.id.widget_previous, getPendingIntent(INTENT_PREVIOUS, context, appWidgetId));
views.setOnClickPendingIntent(R.id.widget_next, getPendingIntent(INTENT_NEXT, context, appWidgetId));
views.setOnClickPendingIntent(R.id.widget_latest, getPendingIntent(INTENT_LATEST, context, appWidgetId));
views.setOnClickPendingIntent(R.id.widget_random, getPendingIntent(INTENT_RANDOM, context, appWidgetId));
views.setOnClickPendingIntent(R.id.widget_image, getPendingIntent(INTENT_DISPLAY, context, appWidgetId));
views.setOnClickPendingIntent(R.id.widget_refresh, getPendingIntent(INTENT_REFRESH, context, appWidgetId));
views.setOnClickPendingIntent(R.id.widget_full_layout, getPendingIntent(INTENT_DISPLAY, context, appWidgetId));
final LocalDate currentDate = prefs.getDateForWidgetId(appWidgetId);
views.setViewVisibility(R.id.widget_next, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
views.setViewVisibility(R.id.widget_previous, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
views.setViewVisibility(R.id.widget_random, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
views.setViewVisibility(R.id.widget_latest, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
final String cachedUrl = prefs.getCachedUrl(currentDate);
final String cachedTitle = prefs.getCachedTitle(currentDate);
views.setViewVisibility(R.id.widget_progress, View.VISIBLE);
views.setTextViewText(R.id.widget_title, prefs.getDateForWidgetId(appWidgetId).toString(DilbertPreferences.NICE_DATE_FORMATTER));
if (prefs.isWidgetShowTitle() && cachedTitle != null && !cachedTitle.isEmpty()) {
views.setViewVisibility(R.id.widget_strip_title, View.VISIBLE);
views.setTextViewText(R.id.widget_strip_title, cachedTitle);
} else {
views.setViewVisibility(R.id.widget_strip_title, View.GONE);
}
appWidgetManager.updateAppWidget(appWidgetId, views);
if (cachedUrl == null) {
new GetStripUrl(new GetStripUrlInterface() {
@Override
public void imageLoadFailed(String url, Throwable reason) {
currentToast = Toast.makeText(context, "Image Loading failed", Toast.LENGTH_SHORT);
currentToast.show();
views.setImageViewResource(R.id.widget_image, R.drawable.cancel);
views.setViewVisibility(R.id.widget_progress, View.GONE);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
@Override
public void displayImage(String url, String title) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}, prefs, currentDate).execute();
} else {
Glide.with(context).asBitmap().load(cachedUrl).apply(new RequestOptions().dontAnimate()).listener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
updateAppWidget(context, appWidgetManager, appWidgetId);
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
views.setViewVisibility(R.id.widget_progress, View.GONE);
appWidgetManager.updateAppWidget(appWidgetId, views);
Glide.with(context).asBitmap().load(cachedUrl).apply(new RequestOptions().dontAnimate()).into(new AppWidgetTarget(context, R.id.widget_image, views, appWidgetId));
return false;
}
}).into(new AppWidgetTarget(context, R.id.widget_image, views, appWidgetId));
}
}
use of com.bumptech.glide.request.RequestOptions in project Camera-Roll-Android-App by kollerlukas.
the class GifViewHolder method loadImage.
@Override
public void loadImage(final ImageView imageView, final AlbumItem albumItem) {
// super.loadImage(imageView, albumItem);
RequestOptions options = new RequestOptions().error(R.drawable.error_placeholder).signature(albumItem.getGlideSignature());
Glide.with(imageView.getContext()).asGif().load(albumItem.getPath()).listener(new RequestListener<GifDrawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
if (!albumItem.hasFadedIn) {
fadeIn();
} else {
imageView.clearColorFilter();
}
resource.start();
return false;
}
}).apply(options).into(imageView);
}
use of com.bumptech.glide.request.RequestOptions in project MyNewCC98 by 6769.
the class PhotoViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo_view);
ButterKnife.bind(this);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
url = bundle.getString(URL_KEY);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
setTitle(getString(R.string.activity_photo_view_title));
try {
RequestOptions options = new RequestOptions().fitCenter().error(// 占位图片;
R.drawable.image_load_error);
Glide.with(this).load(url).apply(// 淡入淡出动画500ms
options).transition(withCrossFade()).into(activityPhotoview);
} catch (Exception e) {
loge(e, "Glide load custom failed");
}
}
Aggregations