Skip to content

Instantly share code, notes, and snippets.

@AdamMc331
Last active December 19, 2019 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamMc331/b3708fca7b77d2992c2e2400bda0a6f9 to your computer and use it in GitHub Desktop.
Save AdamMc331/b3708fca7b77d2992c2e2400bda0a6f9 to your computer and use it in GitHub Desktop.
Lifting code from RecyclerView to share
// This is from Android's RecyclerView.Java file
/**
* Note: this Runnable is only ever posted if:
* 1) We've been through first layout
* 2) We know we have a fixed size (mHasFixedSize)
* 3) We're attached
*/
final Runnable mUpdateChildViewsRunnable = new Runnable() {
@Override
public void run() {
if (!mFirstLayoutComplete || isLayoutRequested()) {
// a layout request will happen, we should not do layout here.
return;
}
if (!mIsAttached) {
requestLayout();
// if we are not attached yet, mark us as requiring layout and skip
return;
}
if (mLayoutSuppressed) {
mLayoutWasDefered = true;
return; //we'll process updates when ice age ends.
}
consumePendingUpdateOperations();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment