lucasr / twoway-view

[DEPRECATED] RecyclerView made simple
5.23k stars 1.02k forks source link

Some weird with recyclerView.Adapter and UIL #159

Open ppamorim opened 9 years ago

ppamorim commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

Yes, with 21.0.1.

http://pastebin.com/wvfTq7KV

ghost commented 9 years ago

@ppamorim Thanks for enter your code, I'm analysing it :+1:

ghost commented 9 years ago

@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 commented 9 years ago

@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 commented 9 years ago

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

ghost commented 9 years ago

I will love it :smile:. Please, could you send me the apk via email? My email is hjcf@cin.ufpe.br.

ppamorim commented 9 years ago

Sent

ppamorim commented 9 years ago

Not working yet...

ppamorim commented 9 years ago

@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 commented 9 years ago

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

NOT! IGNORE IT.

vashisthg commented 9 years ago

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 commented 9 years ago

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 https://github.com/lucasr/twoway-view/pull/167 to fix it

boylenssen commented 9 years ago

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

soodabhay commented 9 years ago

any one solved this issue? facing the same problem!

ppamorim commented 9 years ago

Even with this problem? WHY?!

vovkab commented 9 years ago

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

vovkab commented 9 years ago

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 commented 9 years ago

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 commented 8 years ago

@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 commented 8 years ago

Thank you @christian

hnyoumfk commented 8 years ago

@iamvijayakumar It works!!! THANKS!