Merge "Avoid dividing 0 by 0 in StackScrollAlgorithm." into tm-qpr-dev am: 2ba952ac0c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20069093

Change-Id: I2e54221654a7b61e34a5c05ce6b2758a1f792842
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ioana Alexandru
2022-10-10 08:57:29 +00:00
committed by Automerger Merge Worker

View File

@@ -884,6 +884,9 @@ public class StackScrollAlgorithm {
childViewState.zTranslation = baseZ; childViewState.zTranslation = baseZ;
} else { } else {
float factor = (notificationEnd - shelfStart) / shelfHeight; float factor = (notificationEnd - shelfStart) / shelfHeight;
if (Float.isNaN(factor)) { // Avoid problems when the above is 0/0.
factor = 1.0f;
}
factor = Math.min(factor, 1.0f); factor = Math.min(factor, 1.0f);
childViewState.zTranslation = baseZ + factor * zDistanceBetweenElements; childViewState.zTranslation = baseZ + factor * zDistanceBetweenElements;
} }