Search in sources :

Example 6 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project Palm300Heroes by nicolite.

the class ShowImageAdapter method instantiateItem.

@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    final PhotoView imageView = new PhotoView(context);
    final PhotoViewAttacher attacher = new PhotoViewAttacher(imageView);
    Glide.with(context).load(images.get(position)).placeholder(R.drawable.img_loading).error(R.drawable.img_error).skipMemoryCache(true).crossFade().centerCrop().into(new SimpleTarget<GlideDrawable>() {

        @Override
        public void onLoadStarted(Drawable placeholder) {
            super.onLoadStarted(placeholder);
            imageView.setImageDrawable(placeholder);
            attacher.update();
        }

        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
            imageView.setImageDrawable(resource);
            attacher.update();
        }

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            super.onLoadFailed(e, errorDrawable);
            imageView.setImageDrawable(errorDrawable);
            attacher.update();
        }
    });
    container.addView(imageView);
    return imageView;
}
Also used : PhotoView(com.github.chrisbanes.photoview.PhotoView) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) Drawable(android.graphics.drawable.Drawable) PhotoViewAttacher(com.github.chrisbanes.photoview.PhotoViewAttacher) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) NonNull(android.support.annotation.NonNull)

Example 7 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project AgileDev by LZ9.

the class GlideActivity method setListeners.

@Override
protected void setListeners() {
    super.setListeners();
    // 自定义通知栏
    findViewById(R.id.custom_notification_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            RemoteViews remoteViews = getRemoteViews(getContext());
            Notification notification = new NotificationCompat.Builder(getContext()).setSmallIcon(R.drawable.ic_launcher).setContent(remoteViews).setPriority(NotificationCompat.PRIORITY_MIN).build();
            NotificationManager mNotificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(1235, notification);
            NotificationTarget notificationTarget = new NotificationTarget(getContext(), remoteViews, R.id.remoteview_icon, notification, 1235);
            ImageLoader.create(getContext()).load(UriUtils.parseResId(R.drawable.ic_launcher)).joinGlide().asBitmapInto(notificationTarget);
        }

        private RemoteViews getRemoteViews(Context context) {
            final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.view_remote_notification);
            remoteViews.setImageViewResource(R.id.remoteview_icon, R.drawable.ic_launcher);
            remoteViews.setTextViewText(R.id.remoteview_title, "耿鬼");
            remoteViews.setTextViewText(R.id.remoteview_msg, "鬼斯-鬼斯通-耿鬼");
            return remoteViews;
        }
    });
    // 原生通知栏
    findViewById(R.id.notification_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Notification notification = new NotificationCompat.Builder(getContext()).setSmallIcon(R.drawable.ic_launcher).setColor(Color.YELLOW).setContentTitle("胡地").setContentText("凯西-勇吉拉-胡地").setPriority(NotificationCompat.PRIORITY_MIN).build();
            NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.notify(1234, notification);
        }
    });
    // 本地图片
    findViewById(R.id.local_image_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load(R.drawable.ic_large_img).joinGlide().setRequestListener(new RequestListener<Object, GlideDrawable>() {

                @Override
                public boolean onException(Exception e, Object model, Target<GlideDrawable> target, boolean isFirstResource) {
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, Object model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    int imgW = resource.getIntrinsicWidth();
                    int imgH = resource.getIntrinsicHeight();
                    ViewGroup.LayoutParams layoutParams = mImageView.getLayoutParams();
                    layoutParams.width = ScreenUtils.getScreenWidth(getContext());
                    layoutParams.height = imgH;
                    mImageView.setLayoutParams(layoutParams);
                    return false;
                }
            }).into(mImageView);
        }
    });
    // 网络图片
    findViewById(R.id.url_image_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").joinGlide().setFitCenter().setRequestListener(new RequestListener<Object, GlideDrawable>() {

                @Override
                public boolean onException(Exception e, Object model, Target<GlideDrawable> target, boolean isFirstResource) {
                    ToastUtils.showShort(getContext(), model.toString());
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, Object model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    ToastUtils.showShort(getContext(), model.toString());
                    return false;
                }
            }).into(mImageView);
        }
    });
    // 网络gif
    findViewById(R.id.url_gif_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://image2.sina.com.cn/gm/ol/cross/tujian/446034.gif").joinGlide().setFitCenter().into(mImageView);
        }
    });
    // 动画显示
    findViewById(R.id.anim_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").joinGlide().setAnim(new ViewPropertyAnimation.Animator() {

                @Override
                public void animate(View view) {
                    view.setAlpha(0.7f);
                    ObjectAnimator fadeAnim = ObjectAnimator.ofFloat(view, "alpha", 0.7f, 1f);
                    fadeAnim.setDuration(1500);
                    fadeAnim.start();
                }
            }).setFitCenter().into(mImageView);
        }
    });
    // 毛玻璃
    findViewById(R.id.url_blur).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").useBlur().setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().setFitCenter().into(mImageView);
        }
    });
    // 覆盖颜色
    findViewById(R.id.url_filter_color).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().setFitCenter().setFilterColor(ContextCompat.getColor(getContext(), R.color.color_60ea413c)).useFilterColor().into(mImageView);
        }
    });
    // 圆角
    findViewById(R.id.url_rounded_corners).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).useRoundCorner().setRoundCorner(10f).joinGlide().setFitCenter().into(mImageView);
        }
    });
    // 灰度化
    findViewById(R.id.url_grayscale).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().setFitCenter().useGrayscale().into(mImageView);
        }
    });
    // 圆形
    findViewById(R.id.url_crop_circle).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).useCircle().joinGlide().setFitCenter().into(mImageView);
        }
    });
    // 正方形
    findViewById(R.id.url_crop_square).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().setFitCenter().useCropSquare().into(mImageView);
        }
    });
    // 圆形/毛玻璃
    findViewById(R.id.url_circle_blur).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").useBlur().useCircle().setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().setFitCenter().into(mImageView);
        }
    });
    // 圆角/灰度化
    findViewById(R.id.url_rounded_corners_grayscale).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").useRoundCorner().setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().useGrayscale().setFitCenter().into(mImageView);
        }
    });
    // 圆形/灰度化/毛玻璃
    findViewById(R.id.url_circle_grayscale_blur).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").useCircle().useBlur().setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().useGrayscale().setFitCenter().into(mImageView);
        }
    });
    // 蒙板效果
    findViewById(R.id.url_mask).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load("http://i0.hdslb.com/group1/M00/44/5B/oYYBAFbRLIuARLeSAAJAaSQWy9s392.jpg").setImageSize(DensityUtils.dp2px(getContext(), 100), // 如果不设置宽高会导致图片拉伸
            DensityUtils.dp2px(getContext(), 100)).joinGlide().useMask().setFitCenter().into(mImageView);
        }
    });
    // 本地webp
    findViewById(R.id.local_webp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load(R.drawable.ic_webp).joinGlide().setFitCenter().into(mImageView);
        }
    });
    // 本地gif
    findViewById(R.id.local_gif).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageLoader.create(getContext()).load(R.drawable.ic_gif).joinGlide().setFitCenter().into(mImageView);
        }
    });
    // 本地视频
    findViewById(R.id.local_video).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String filePath = FileManager.getDownloadFolderPath() + "20170422.mp4";
            File file = new File(filePath);
            if (!file.exists()) {
                ToastUtils.showShort(getContext(), "文件不存在");
                return;
            }
            ImageLoader.create(getContext()).load(Uri.fromFile(file)).joinGlide().setVideo().into(mImageView);
        }
    });
}
Also used : Context(android.content.Context) NotificationManager(android.app.NotificationManager) ObjectAnimator(android.animation.ObjectAnimator) NotificationTarget(com.bumptech.glide.request.target.NotificationTarget) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) Notification(android.app.Notification) RemoteViews(android.widget.RemoteViews) ObjectAnimator(android.animation.ObjectAnimator) NotificationCompat(android.support.v4.app.NotificationCompat) File(java.io.File) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 8 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project Signal-Android by WhisperSystems.

the class ZoomingImageView method setImageViewUri.

private void setImageViewUri(MasterSecret masterSecret, Uri uri) {
    subsamplingImageView.setVisibility(View.GONE);
    imageView.setVisibility(View.VISIBLE);
    Glide.with(getContext()).load(new DecryptableUri(masterSecret, uri)).diskCacheStrategy(DiskCacheStrategy.NONE).dontTransform().dontAnimate().into(new GlideDrawableImageViewTarget(imageView) {

        @Override
        protected void setResource(GlideDrawable resource) {
            super.setResource(resource);
            imageViewAttacher.update();
        }
    });
}
Also used : GlideDrawableImageViewTarget(com.bumptech.glide.request.target.GlideDrawableImageViewTarget) DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 9 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project Douya by DreaminginCodeZH.

the class GalleryAdapter method instantiateItem.

@Override
public View instantiateItem(ViewGroup container, int position) {
    View layout = ViewUtils.inflate(R.layout.gallery_item, container);
    PhotoView imageView = ButterKnife.findById(layout, R.id.image);
    final TextView errorText = ButterKnife.findById(layout, R.id.error);
    final ProgressBar progressBar = ButterKnife.findById(layout, R.id.progress);
    imageView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            if (mOnTapListener != null) {
                mOnTapListener.onTap();
            }
        }
    });
    ImageUtils.loadImage(imageView, mImageList.get(position), new RequestListener<String, GlideDrawable>() {

        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            (e != null ? e : new NullPointerException()).printStackTrace();
            int errorRes = e != null && e.getCause() instanceof TimeoutError ? R.string.gallery_load_timeout : R.string.gallery_load_error;
            errorText.setText(errorRes);
            ViewUtils.crossfade(progressBar, errorText);
            return false;
        }

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            ViewUtils.fadeOut(progressBar);
            return false;
        }
    });
    container.addView(layout);
    return layout;
}
Also used : TimeoutError(com.android.volley.TimeoutError) PhotoView(uk.co.senab.photoview.PhotoView) TextView(android.widget.TextView) View(android.view.View) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) PhotoView(uk.co.senab.photoview.PhotoView) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 10 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project Notes by Elder-Wu.

the class GlideFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_glide, container, false);
    ImageView imageView = (ImageView) rootView.findViewById(R.id.image);
    Glide.with(getContext()).load("http://pic.qiantucdn.com/58pic/18/31/50/70T58PIC4Xi_1024.jpg").diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).crossFade().into(imageView);
    final ImageView imageView2 = (ImageView) rootView.findViewById(R.id.image2);
    imageView2.postDelayed(new Runnable() {

        @Override
        public void run() {
            Glide.with(getContext()).load((String) null).transform(new RoundTransform(getContext(), imageView2.getMeasuredWidth(), 10)).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).fallback(new ColorDrawable(Color.GREEN)).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) {
                    Logger.d(model);
                    return false;
                }
            }).into(new SimpleTarget<GlideDrawable>() {

                @Override
                public void onResourceReady(final GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                    Observable.timer(5, TimeUnit.SECONDS).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {

                        @Override
                        public void call(Long aLong) {
                            imageView2.setImageDrawable(new ColorDrawable(Color.DKGRAY));
                        }
                    });
                }
            });
        }
    }, 2000);
    return rootView;
}
Also used : GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) ImageView(android.widget.ImageView) View(android.view.View) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) ColorDrawable(android.graphics.drawable.ColorDrawable) ImageView(android.widget.ImageView) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) Nullable(android.support.annotation.Nullable)

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