K
K
korsander2015-04-22 15:39:46
Android
korsander, 2015-04-22 15:39:46

How to use RecyclerView to redraw visible elements on a timer?

The bottom line is this: There is a RecyclerView in each element of the list there is a ProgressBar and it is necessary to update the progress in it on a timer. ListView has an invalidateViews() method which solved the update issue. How to update visible items in RecyclerView? The adapter's notifyDataSetChanged() method is not suitable - just a redraw is needed, and notifyItemChanged(position) - causes items to flash on update.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Olenev, 2015-04-22
@korsander

Maybe try to store links to your ProgressBar and call invalidate on the timer? Moreover, you don’t need to redraw everything else ..
Or, as an option, go over all the children of the RecyclerView and call them invalidate
We must not forget ListView is such a monster thing that could do everything itself, and in RecyclerView a lot was left to you ..
If you look at the ListView source :

/**
     * Causes all the views to be rebuilt and redrawn.
     */
    public void invalidateViews() {
        mDataChanged = true;
        rememberSyncState();
        requestLayout();
        invalidate();
    }

You may notice that the data will be rebuilt one way or another ..
Then what exactly is the problem with notifyDataSetChanged() you have?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question