Ensured that the gut's bounds update properly

Because we were using a transition to update the content
and the guts were using getHeight() to infer their
actualHeight, getHeight() was returning the start
value of the animation and only updated later when other
state changed. This is now fixed by returning the
height determined in the layout.

Bug: 157215227
Test: add guts with 3 line priority, switch between them, observe correct measuring
Change-Id: Icdecd022276e1e21b78991cb5de9f3f7972cb490
This commit is contained in:
Selim Cinek
2020-05-21 15:38:32 -07:00
parent 52e9487184
commit a5a4ee43eb
2 changed files with 20 additions and 2 deletions

View File

@@ -117,6 +117,7 @@ public class NotificationConversationInfo extends LinearLayout implements
@VisibleForTesting
boolean mSkipPost = false;
private int mActualHeight;
@Retention(SOURCE)
@IntDef({ACTION_DEFAULT, ACTION_HOME, ACTION_FAVORITE, ACTION_SNOOZE, ACTION_MUTE,
@@ -582,7 +583,15 @@ public class NotificationConversationInfo extends LinearLayout implements
@Override
public int getActualHeight() {
return getHeight();
// Because we're animating the bounds, getHeight will return the small height at the
// beginning of the animation. Instead we'd want it to already return the end value
return mActualHeight;
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
mActualHeight = getHeight();
}
@VisibleForTesting

View File

@@ -71,6 +71,7 @@ import java.util.Set;
*/
public class NotificationInfo extends LinearLayout implements NotificationGuts.GutsContent {
private static final String TAG = "InfoGuts";
private int mActualHeight;
@IntDef(prefix = { "ACTION_" }, value = {
ACTION_NONE,
@@ -583,7 +584,15 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
@Override
public int getActualHeight() {
return getHeight();
// Because we're animating the bounds, getHeight will return the small height at the
// beginning of the animation. Instead we'd want it to already return the end value
return mActualHeight;
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
mActualHeight = getHeight();
}
@VisibleForTesting