Search in sources :

Example 11 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project LookLook by xinghongfei.

the class ZhihuAdapter method bindViewHolderNormal.

private void bindViewHolderNormal(final ZhihuViewHolder holder, final int position) {
    final ZhihuDailyItem zhihuDailyItem = zhihuDailyItems.get(holder.getAdapterPosition());
    if (DBUtils.getDB(mContext).isRead(Config.ZHIHU, zhihuDailyItem.getId(), 1))
        holder.textView.setTextColor(Color.GRAY);
    else
        holder.textView.setTextColor(Color.BLACK);
    holder.imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            goDescribeActivity(holder, zhihuDailyItem);
        }
    });
    holder.textView.setText(zhihuDailyItem.getTitle());
    holder.linearLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            goDescribeActivity(holder, zhihuDailyItem);
        }
    });
    Glide.with(mContext).load(zhihuDailyItems.get(position).getImages()[0]).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) {
            if (!zhihuDailyItem.hasFadedIn) {
                holder.imageView.setHasTransientState(true);
                final ObservableColorMatrix cm = new ObservableColorMatrix();
                final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
                animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
                    }
                });
                animator.setDuration(2000L);
                animator.setInterpolator(new AccelerateInterpolator());
                animator.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        holder.imageView.clearColorFilter();
                        holder.imageView.setHasTransientState(false);
                        animator.start();
                        zhihuDailyItem.hasFadedIn = true;
                    }
                });
            }
            return false;
        }
    }).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().override(widthPx, heighPx).into(new DribbbleTarget(holder.imageView, false));
}
Also used : DribbbleTarget(com.looklook.xinghongfei.looklook.util.DribbbleTarget) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ZhihuDailyItem(com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDailyItem) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) BadgedFourThreeImageView(com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) ObservableColorMatrix(com.looklook.xinghongfei.looklook.util.ObservableColorMatrix) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 12 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project CloudReader by youlookwhat.

the class SlideShadeViewActivity method setData.

/**
     * 加载titlebar背景
     */
private void setData() {
    if (subjectsBean != null) {
        // 高斯模糊背景 原来 参数:12,5  23,4
        Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 23, 4)).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) {
                binding.titleToolBar.setBackgroundColor(Color.TRANSPARENT);
                binding.ivTitleHeadBg.setImageAlpha(0);
                binding.ivTitleHeadBg.setVisibility(View.VISIBLE);
                return false;
            }
        }).into(binding.ivTitleHeadBg);
    }
}
Also used : BlurTransformation(jp.wasabeef.glide.transformations.BlurTransformation) Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 13 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project CloudReader by youlookwhat.

the class TestActivity method setData.

private void setData() {
    if (subjectsBean != null) {
        // 高斯模糊背景
        Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 12, 5)).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) {
                mToolbar.setBackgroundColor(Color.TRANSPARENT);
                binding.ivTitleBg.setImageAlpha(0);
                binding.ivTitleBg.setVisibility(View.VISIBLE);
                return false;
            }
        }).into(binding.ivTitleBg);
    }
}
Also used : BlurTransformation(jp.wasabeef.glide.transformations.BlurTransformation) Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 14 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project xabber-android by redsolution.

the class ChatMessageAdapter method setUpImage.

private void setUpImage(MessageItem messageItem, final Message messageHolder) {
    messageHolder.messageImage.setVisibility(View.GONE);
    if (!messageItem.isImage() || !SettingsManager.connectionLoadImages()) {
        return;
    }
    if (messageItem.getFilePath() != null) {
        boolean result = FileManager.loadImageFromFile(context, messageItem.getFilePath(), messageHolder.messageImage);
        if (result) {
            messageHolder.messageImage.setVisibility(View.VISIBLE);
            messageHolder.messageText.setVisibility(View.GONE);
        } else {
            final String uniqueId = messageItem.getUniqueId();
            final Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
            realm.executeTransactionAsync(new Realm.Transaction() {

                @Override
                public void execute(Realm realm) {
                    MessageItem first = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, uniqueId).findFirst();
                    if (first != null) {
                        first.setFilePath(null);
                    }
                }
            });
        }
    } else {
        final ViewGroup.LayoutParams layoutParams = messageHolder.messageImage.getLayoutParams();
        Integer imageWidth = messageItem.getImageWidth();
        Integer imageHeight = messageItem.getImageHeight();
        if (imageWidth != null && imageHeight != null) {
            FileManager.scaleImage(layoutParams, imageHeight, imageWidth);
            Glide.with(context).load(messageItem.getText()).listener(new RequestListener<String, GlideDrawable>() {

                @Override
                public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                    messageHolder.messageImage.setVisibility(View.GONE);
                    messageHolder.messageText.setVisibility(View.VISIBLE);
                    return true;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    return false;
                }
            }).into(messageHolder.messageImage);
            messageHolder.messageImage.setVisibility(View.VISIBLE);
            messageHolder.messageText.setVisibility(View.GONE);
        } else {
            final String uniqueId = messageItem.getUniqueId();
            Glide.with(context).load(messageItem.getText()).asBitmap().into(new SimpleTarget<Bitmap>() {

                @Override
                public void onResourceReady(final Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                    final int width = resource.getWidth();
                    final int height = resource.getHeight();
                    if (width <= 0 || height <= 0) {
                        messageHolder.messageImage.setVisibility(View.GONE);
                        messageHolder.messageText.setVisibility(View.VISIBLE);
                        return;
                    }
                    final Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
                    realm.executeTransactionAsync(new Realm.Transaction() {

                        @Override
                        public void execute(Realm realm) {
                            MessageItem first = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, uniqueId).findFirst();
                            if (first != null) {
                                first.setImageWidth(width);
                                first.setImageHeight(height);
                            }
                        }
                    });
                    FileManager.scaleImage(layoutParams, height, width);
                    messageHolder.messageImage.setImageBitmap(resource);
                    messageHolder.messageImage.setVisibility(View.VISIBLE);
                    messageHolder.messageText.setVisibility(View.GONE);
                }
            });
        }
    }
}
Also used : MessageItem(com.xabber.android.data.database.messagerealm.MessageItem) RequestListener(com.bumptech.glide.request.RequestListener) ViewGroup(android.view.ViewGroup) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) Target(com.bumptech.glide.request.target.Target) Bitmap(android.graphics.Bitmap) Realm(io.realm.Realm) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 15 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project sbt-android by scala-android.

the class FeedAdapter method bindDribbbleShotView.

private void bindDribbbleShotView(final Shot shot, final DribbbleShotHolder holder) {
    final BadgedFourThreeImageView iv = (BadgedFourThreeImageView) holder.itemView;
    Glide.with(host).load(shot.images.best()).listener(new RequestListener<String, GlideDrawable>() {

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            if (!shot.hasFadedIn) {
                iv.setHasTransientState(true);
                final ObservableColorMatrix cm = new ObservableColorMatrix();
                ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
                saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        // new CMCF as the matrix is immutable :(
                        if (iv.getDrawable() != null) {
                            iv.getDrawable().setColorFilter(new ColorMatrixColorFilter(cm));
                        }
                    }
                });
                saturation.setDuration(2000);
                saturation.setInterpolator(AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in));
                saturation.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        iv.setHasTransientState(false);
                    }
                });
                saturation.start();
                shot.hasFadedIn = true;
            }
            return false;
        }

        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            return false;
        }
    }).placeholder(R.color.background_dark).diskCacheStrategy(DiskCacheStrategy.ALL).into(new DribbbleTarget(iv, false));
    iv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            iv.setTransitionName(iv.getResources().getString(R.string.transition_shot));
            iv.setBackgroundColor(ContextCompat.getColor(host, R.color.background_light));
            Intent intent = new Intent();
            intent.setClass(host, DribbbleShot.class);
            intent.putExtra(DribbbleShot.EXTRA_SHOT, shot);
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(view, host.getString(R.string.transition_shot)), Pair.create(view, host.getString(R.string.transition_shot_background)));
            host.startActivity(intent, options.toBundle());
        }
    });
}
Also used : DribbbleTarget(io.plaidapp.util.glide.DribbbleTarget) RequestListener(com.bumptech.glide.request.RequestListener) ObjectAnimator(android.animation.ObjectAnimator) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) BadgedFourThreeImageView(io.plaidapp.ui.widget.BadgedFourThreeImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) BadgedFourThreeImageView(io.plaidapp.ui.widget.BadgedFourThreeImageView) Target(com.bumptech.glide.request.target.Target) DribbbleTarget(io.plaidapp.util.glide.DribbbleTarget) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) ObservableColorMatrix(io.plaidapp.util.ObservableColorMatrix) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) ActivityOptions(android.app.ActivityOptions)

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