vendredi 15 juillet 2016

RecyclerView isn't attached and postOnAnimation isn't called

In the method triggerUpdateProcessor of RecyclerView, the line ViewCompat.postOnAnimation(RecyclerView.this, mUpdateChildViewsRunnable); isn't being executed because the attribute mIsAttached is false, not triggering the animations. This is happening while changing orientation on the device with a DialogFragment open (more about the use case here).

The code I am referring in RecyclerView is:

void triggerUpdateProcessor() {
            if (mPostUpdatesOnAnimation && mHasFixedSize && mIsAttached) {
                ViewCompat.postOnAnimation(RecyclerView.this, mUpdateChildViewsRunnable);
            } else {
                mAdapterUpdateDuringMeasure = true;
                requestLayout();
            }
        }

Why is mIsAttached being set to false?


Edit

If the RecyclerView is contained inside a Fragment the problem doesn't happen.

Aucun commentaire:

Enregistrer un commentaire