Glide: Glide and RecyclerView blinking

Created on 19 Nov 2016  路  3Comments  路  Source: bumptech/glide

I create small app to show my problem.
You can see it here https://github.com/Anton111111/ExampleGlideBlink.
Main class: https://github.com/Anton111111/ExampleGlideBlink/blob/master/app/src/main/java/com/example/testglide/MainActivity.java

Main Layout:
https://github.com/Anton111111/ExampleGlideBlink/blob/master/app/src/main/res/layout/activity_main.xml

Item Layout:
https://github.com/Anton111111/ExampleGlideBlink/blob/master/app/src/main/res/layout/item.xml

When i call notifyItemChanged on RecyclerView adapter i need change only text (in my example it EditText with id R.id.progress) and image shown without changes. But it blink.

Have i ability to change text without blinking?

non-library question

Most helpful comment

Wizard and AndroidBeginner and danypata are very likely right. It is not Glide that's causing the blinking, but the RecyclerView. To prove it, put this line in your onBindViewHolder:

holder.itemView.setBackgroundColor(0xff000000 | (position * 0x611de));

and observe that the whole item is blinking, including the text view background. Notice also that the incremented counter is also cross-fading between numbers.

You can also see that Glide is not doing any animations if you put a .listener() on the load and print the isFromMemoryCache param. It'll always be true, which means that the Drawable set in the ImageView happened synchronously.

The blink's root cause is the .alpha(0) in android.support.v7.widget.DefaultItemAnimator#animateChangeImpl and the best thing you can do is to disable the animation if that's your wanted result:

ItemAnimator animator = rv.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
    ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}

However, I think a little nudge to the user that something happened is not such a bad thing.

All 3 comments

am having same issue

Wizard and AndroidBeginner and danypata are very likely right. It is not Glide that's causing the blinking, but the RecyclerView. To prove it, put this line in your onBindViewHolder:

holder.itemView.setBackgroundColor(0xff000000 | (position * 0x611de));

and observe that the whole item is blinking, including the text view background. Notice also that the incremented counter is also cross-fading between numbers.

You can also see that Glide is not doing any animations if you put a .listener() on the load and print the isFromMemoryCache param. It'll always be true, which means that the Drawable set in the ImageView happened synchronously.

The blink's root cause is the .alpha(0) in android.support.v7.widget.DefaultItemAnimator#animateChangeImpl and the best thing you can do is to disable the animation if that's your wanted result:

ItemAnimator animator = rv.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
    ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}

However, I think a little nudge to the user that something happened is not such a bad thing.

I'm having the same issue.
For cross-verify I put glide cmded in all my view holders and then flicker not happening. i even tried setSupportsChangeAnimations too its not working anywork around plz.

`

                    glide.load(feeds.getImage())
                                        .addListener(new RequestListener<Drawable>() {
                                            @Override
                                            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                                                getHandler().post(() -> eventImageShimmer.stopShimmer());
                                                Log.e("feed adapter", "onLoadFailed() called with: e = [" + e + "], model = [" + model + "], target = [" + target + "], isFirstResource = [" + isFirstResource + "]");
                                                return false;
                                            }

                    @Override
                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                        Log.d("eventImage", " onResourceReady()  called Thread[" + Thread.currentThread().getName() + "]");
                        bindImage(resource);
                        Log.e(TAG, "bind: image feed update.... local..................");
                        return false;
                    }
                }).submit();`
Was this page helpful?
0 / 5 - 0 ratings

Related issues

piedpiperlol picture piedpiperlol  路  3Comments

MrFuFuFu picture MrFuFuFu  路  3Comments

r4m1n picture r4m1n  路  3Comments

StefMa picture StefMa  路  3Comments

sergeyfitis picture sergeyfitis  路  3Comments