Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Some weird with recyclerView.Adapter and UIL #159

Open
ppamorim opened this issue Nov 3, 2014 · 22 comments
Open

Some weird with recyclerView.Adapter and UIL #159

ppamorim opened this issue Nov 3, 2014 · 22 comments

Comments

@ppamorim
Copy link

ppamorim commented Nov 3, 2014

Hello , my list is very bizarre . If you disable image loader (UIL) , the list flowing normal. Ever turn , the list is moving alone and flicking . Does anyone have any idea what it might be?

Sample: https://drive.google.com/file/d/0BwCQLXhzKWGUd2Y0YjF0dWZ3dkE/view?usp=sharing

@ghost
Copy link

ghost commented Nov 3, 2014

Please provide a piece of the code used in your RecyclerView.Adapter for analysis. Have you tested Universal-Image-Loader directly with RecyclerView 21.0.1?

@ppamorim
Copy link
Author

ppamorim commented Nov 3, 2014

Yes, with 21.0.1.

http://pastebin.com/wvfTq7KV

@ghost
Copy link

ghost commented Nov 3, 2014

@ppamorim Thanks for enter your code, I'm analysing it 👍

@ghost
Copy link

ghost commented Nov 3, 2014

@ppamorim Have you enabled caching in Universal Image Loader? It is not enabled by default according the documentation, if caching is disabled, when the images reach the memory cache threshold that is relatively small, new threads will be spawned generating new workloads and flickering in RecyclerView at each time that bindViewHolder is hit.

Please, look at this https://github.com/nostra13/Android-Universal-Image-Loader/wiki/Useful-Info for how enable caching using Universal Image Loader.

If it doesn't yet work well, I will need to create a small sample for analyse "Thread Windows" in Eclipse, looking for the Thread generating frequency.

@ghost
Copy link

ghost commented Nov 3, 2014

@ppamorim If it doesn't yet work again, we'll have to pause the loading of images when scrolling the RecyclerView and an its items come out of the screen. When the item come back to the screen, we resuming the loading.

@ppamorim
Copy link
Author

ppamorim commented Nov 4, 2014

@HoracioFilho send me your Google Plus or Facebook account. I'll send the APK to show what's happening.

@ghost
Copy link

ghost commented Nov 4, 2014

I will love it 😄. Please, could you send me the apk via email? My email is [email protected].

@ppamorim
Copy link
Author

ppamorim commented Nov 4, 2014

Sent

@ppamorim
Copy link
Author

ppamorim commented Nov 5, 2014

Not working yet...

@ppamorim
Copy link
Author

ppamorim commented Nov 5, 2014

@HoracioFilho @lucasr
ENG:
From what I observed the problem seems to be related to the loading of items. The same problem occurs with AdView.
It seems that the list moves when finished loading/update of image/banner, would it?

PT-BR:
Pelo que observei o problema parece ser referente ao carregamento dos itens. Ocorre o mesmo problema com o AdView.
Parece que a lista se move quando termina o carregamento/atualização da imagem/banner, seria isso?

@ppamorim
Copy link
Author

ppamorim commented Nov 5, 2014

Detected : The problem only occurs with the UIL(and bug all views), with Picasso ImageLoader work perfectly without any bug.

NOT! IGNORE IT.

@vashisthg
Copy link

We get this same problem with Picasso.

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        DemoEntity demoEntity = demoList.get(position);
        holder.textView.setText(demoEntity.text);
        long time = System.currentTimeMillis();
        loadImage(holder, demoEntity);
        Log.d("LOGTAG", "time to load image:" + (System.currentTimeMillis() - time));
    }

    private void loadImage(final ViewHolder holder, DemoEntity demoEntity) {

        Picasso.with(holder.imageView.getContext())
                .load(demoEntity.imageDrawable)
               .transform(transformation)
                .into(holder.imageView);
    }

The time to load images is at most 15 milliseconds

@0legg
Copy link

0legg commented Nov 14, 2014

I've dig into library and found out that ImageView image loading causes onLayoutChildren to be called. This method has bug in it, which leads us to scroll to beginning of first visible item nearly every time.

You can try #167 to fix it

@boylenssen
Copy link

I also see that setting the imageview asynchronously, via Picasso or via a post(Runnable) gives this issue...

@soodabhay
Copy link

any one solved this issue?
facing the same problem!

@ppamorim
Copy link
Author

ppamorim commented Feb 5, 2015

Even with this problem? WHY?!

@vovkab
Copy link

vovkab commented May 19, 2015

I'm using regular RecyclerView/LayoutManager with Glide, also seeing this issue. Feels like it is RecyclerView bug and not image loader.

@vovkab
Copy link

vovkab commented May 20, 2015

I looked a little bit into this issue, looks like when you refresh data RecyclerView will get you a new ViewHolder, while old ListView/GridView and other AbsListView, reused exactly the same holder, making flickers "invisible".

@iamvijayakumar
Copy link

issues was fixed when change one line of code. and tried with Picasso no flicker

Open layout folder of library.
Browse the package org.lucasr.twowayview.widget
Open BaseLayoutManager class
Jump to Line no. 362
You will found code as

if (anchorItemPosition > 0 && (refreshingLanes || !restoringLanes))
{

replace this line by this one

if (anchorItemPosition > 0 && refreshingLanes && !restoringLanes) {

@christian160984
Copy link

@iamvijayakumar workaround is right for me. I don't know if it has any side effect o not, but thank you. It's awesome.

@iamvijayakumar
Copy link

Thank you @christian

@hnyoumfk
Copy link

@iamvijayakumar It works!!! THANKS!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants