Skip to content

Commit

Permalink
Ignore waitForLayout if we have fixed layout parameters.
Browse files Browse the repository at this point in the history
Progress towards bumptech#2431.
  • Loading branch information
sjudd committed Sep 26, 2017
1 parent cbc7001 commit 8ddeff2
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,6 @@ private int getTargetWidth() {
}

private int getTargetDimen(int viewSize, int paramSize, int paddingSize) {
if (waitForLayout && view.isLayoutRequested()) {
return PENDING_SIZE;
}

// We consider the View state as valid if the View has non-null layout params and a non-zero
// layout params width and height. This is imperfect. We're making an assumption that View
// parents will obey their child's layout parameters, which isn't always the case.
Expand All @@ -319,6 +315,13 @@ private int getTargetDimen(int viewSize, int paramSize, int paddingSize) {
return adjustedParamSize;
}

// Since we always prefer layout parameters with fixed sizes, even if waitForLayout is true,
// we might as well ignore it and just return the layout parameters above if we have them.
// Otherwise we should wait for a layout pass before checking the View's dimensions.
if (waitForLayout && view.isLayoutRequested()) {
return PENDING_SIZE;
}

// We also consider the View state valid if the View has a non-zero width and height. This
// means that the View has gone through at least one layout pass. It does not mean the Views
// width and height are from the current layout pass. For example, if a View is re-used in
Expand Down

0 comments on commit 8ddeff2

Please sign in to comment.