Search in sources :

Example 16 with GlideDrawable

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();
    }
}
Also used : GlideDrawableImageViewTarget(com.bumptech.glide.request.target.GlideDrawableImageViewTarget) BitmapFactory(android.graphics.BitmapFactory) File(java.io.File) PhotoViewAttacher(com.github.chrisbanes.photoview.PhotoViewAttacher) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 17 with GlideDrawable

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);
}
Also used : Target(com.bumptech.glide.request.target.Target) FutureTarget(com.bumptech.glide.request.FutureTarget) RequestManager(com.bumptech.glide.RequestManager) RequestListener(com.bumptech.glide.request.RequestListener) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 18 with GlideDrawable

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();
        });
    }
}
Also used : Rect(android.graphics.Rect) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView)

Example 19 with GlideDrawable

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();
    }
}
Also used : Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) GlideBitmapDrawable(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable) GlideBitmapDrawable(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GlideBitmapDrawable(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 20 with GlideDrawable

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);
}
Also used : Context(android.content.Context) BlurTransformation(jp.wasabeef.glide.transformations.BlurTransformation) Song(se.zinokader.spotiq.model.Song) CropTransformation(jp.wasabeef.glide.transformations.CropTransformation) ColorFilterTransformation(jp.wasabeef.glide.transformations.ColorFilterTransformation) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Aggregations

GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)21 View (android.view.View)9 RequestListener (com.bumptech.glide.request.RequestListener)9 Target (com.bumptech.glide.request.target.Target)9 ObjectAnimator (android.animation.ObjectAnimator)6 ValueAnimator (android.animation.ValueAnimator)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)5 TextView (android.widget.TextView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 ImageView (android.widget.ImageView)4 BlurTransformation (jp.wasabeef.glide.transformations.BlurTransformation)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)3 Drawable (android.graphics.drawable.Drawable)3 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)3 DribbbleTarget (com.looklook.xinghongfei.looklook.util.DribbbleTarget)3 ObservableColorMatrix (com.looklook.xinghongfei.looklook.util.ObservableColorMatrix)3 BadgedFourThreeImageView (com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView)3 Context (android.content.Context)2