use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project Pix-Art-Messenger by kriztan.
the class ShowFullscreenMessageActivity method DisplayImage.
private void DisplayImage(final File file) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(new File(file.getPath()).getAbsolutePath(), options);
height = options.outHeight;
width = options.outWidth;
rotation = getRotation(Uri.parse("file://" + file.getAbsolutePath()));
Log.d(Config.LOGTAG, "Image height: " + height + ", width: " + width + ", rotation: " + rotation);
if (useAutoRotateScreen()) {
rotateScreen(width, height, rotation);
}
final PhotoViewAttacher mAttacher = new PhotoViewAttacher(mImage);
mImage.setVisibility(View.VISIBLE);
try {
Glide.with(this).load(file).dontAnimate().into(new GlideDrawableImageViewTarget(mImage) {
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
super.onResourceReady(resource, animation);
mAttacher.update();
}
});
} catch (Exception e) {
Toast.makeText(this, getString(R.string.error_file_corrupt), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project AndroidStudy by tinggengyan.
the class GlideMainActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_imageview);
prescale_iamgeview = (ImageView) findViewById(R.id.prescale_iamgeview);
RequestManager requestManager = Glide.with(this);
requestManager.load(Constants.IMAGES[0]).placeholder(R.drawable.accept).diskCacheStrategy(DiskCacheStrategy.NONE).override(100, 100).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).into(prescale_iamgeview);
requestManager.load(Constants.IMAGES[1]).diskCacheStrategy(DiskCacheStrategy.SOURCE).preload();
downloadImage(prescale_iamgeview);
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project FastHub by k0shk0sh.
the class GlideDrawableTarget method onResourceReady.
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
if (container != null && container.get() != null) {
TextView textView = container.get();
textView.post(() -> {
float width;
float height;
if (resource.getIntrinsicWidth() >= this.width) {
float downScale = (float) resource.getIntrinsicWidth() / this.width;
width = (float) (resource.getIntrinsicWidth() / downScale / 1.3);
height = (float) (resource.getIntrinsicHeight() / downScale / 1.3);
} else {
float multiplier = (float) this.width / resource.getIntrinsicWidth();
width = (float) resource.getIntrinsicWidth() * multiplier;
height = (float) resource.getIntrinsicHeight() * multiplier;
}
Rect rect = new Rect(0, 0, Math.round(width), Math.round(height));
resource.setBounds(rect);
urlDrawable.setBounds(rect);
urlDrawable.setDrawable(resource);
if (resource.isAnimated()) {
urlDrawable.setCallback((Drawable.Callback) textView.getTag(R.id.drawable_callback));
resource.setLoopCount(GlideDrawable.LOOP_FOREVER);
resource.start();
}
textView.setText(textView.getText());
textView.invalidate();
});
}
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project LuaViewSDK by alibaba.
the class GlideImageProvider method preload.
@Override
public void preload(final Context context, String url, final DrawableLoadCallback callback) {
if (callback != null) {
Glide.with(context).load(url).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
if (callback != null) {
callback.onLoadResult(null);
}
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (callback != null) {
Drawable r = resource instanceof GlideBitmapDrawable ? new BitmapDrawable(context.getResources(), ((GlideBitmapDrawable) resource).getBitmap()) : resource;
callback.onLoadResult(r);
}
return false;
}
}).preload();
} else {
Glide.with(context).load(url).preload();
}
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project SpotiQ by ZinoKader.
the class TracklistRecyclerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(SongHolder songHolder, int position) {
Song song = songs.get(position);
Context context = songHolder.itemView.getContext();
String artistsName = ArtistMapper.joinArtistNames(song.getArtists());
String runTimeText = String.format(Locale.getDefault(), "%d minutes, %d seconds", TimeUnit.MILLISECONDS.toMinutes(song.getDurationMs()), TimeUnit.MILLISECONDS.toSeconds(song.getDurationMs()) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(song.getDurationMs())));
songHolder.cropTransformation = new CropTransformation(context, ApplicationConstants.DEFAULT_TRACKLIST_CROP_WIDTH, ApplicationConstants.DEFAULT_TRACKLIST_CROP_HEIGHT, CropTransformation.CropType.CENTER);
songHolder.blurTransformation = new BlurTransformation(context, ApplicationConstants.DEFAULT_TRACKLIST_BLUR_RADIUS);
songHolder.colorFilterTransformation = new ColorFilterTransformation(context, R.color.colorPrimary);
Glide.with(songHolder.itemView.getContext()).load(song.getAlbumArtUrl()).fitCenter().placeholder(R.drawable.image_album_placeholder).bitmapTransform(songHolder.blurTransformation, songHolder.cropTransformation, songHolder.colorFilterTransformation).into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable drawable, GlideAnimation<? super GlideDrawable> glideAnimation) {
songHolder.cardViewRoot.setBackground(drawable);
}
});
Glide.with(context).load(song.getAlbumArtUrl()).placeholder(R.drawable.image_album_placeholder).fitCenter().into(songHolder.albumArt);
songHolder.songName.setText(song.getName());
songHolder.artistsName.setText(artistsName);
songHolder.runTime.setText(runTimeText);
songHolder.albumName.setText(song.getAlbum().name);
}
Aggregations