Search in sources :

Example 1 with ImageLoader

use of com.stardust.autojs.core.ui.inflater.ImageLoader in project Auto.js by hyb1996.

the class App method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    sApp = this;
    AutoJs.initInstance(this);
    GlobalKeyObserver.init();
    Drawables.setDefaultImageLoader(new ImageLoader() {

        @Override
        public void loadInto(ImageView imageView, Uri uri) {
            Glide.with(App.this).load(uri).into(imageView);
        }

        @Override
        public void loadIntoBackground(View view, Uri uri) {
            Glide.with(App.this).load(uri).into(new SimpleTarget<Drawable>() {

                @Override
                public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
                    view.setBackground(resource);
                }
            });
        }

        @Override
        public Drawable load(View view, Uri uri) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void load(View view, Uri uri, DrawableCallback drawableCallback) {
            Glide.with(App.this).load(uri).into(new SimpleTarget<Drawable>() {

                @Override
                public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
                    drawableCallback.onLoaded(resource);
                }
            });
        }

        @Override
        public void load(View view, Uri uri, BitmapCallback bitmapCallback) {
            Glide.with(App.this).asBitmap().load(uri).into(new SimpleTarget<Bitmap>() {

                @Override
                public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
                    bitmapCallback.onLoaded(resource);
                }
            });
        }
    });
}
Also used : SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) Bitmap(android.graphics.Bitmap) Drawable(android.graphics.drawable.Drawable) Transition(com.bumptech.glide.request.transition.Transition) ImageView(android.widget.ImageView) ImageLoader(com.stardust.autojs.core.ui.inflater.ImageLoader) Uri(android.net.Uri) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 Uri (android.net.Uri)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 SimpleTarget (com.bumptech.glide.request.target.SimpleTarget)1 Transition (com.bumptech.glide.request.transition.Transition)1 ImageLoader (com.stardust.autojs.core.ui.inflater.ImageLoader)1