summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nader Jawad <njawad@google.com> 2021-04-13 01:29:31 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-04-13 01:29:31 +0000
commit93ea53bbe2850ed1e06723b0cfdc34aa7d83a851 (patch)
tree475dd12fb9911f3e1a3080668b29216a00ffc2a1
parentd914330cfc7b85675b77347a462580c81f1af03e (diff)
parent0a458ab55ad77dba54dcc321f76ef79c1eeeb503 (diff)
Merge "Fixed issue with invalid stretch params" into sc-dev
-rw-r--r--core/java/android/widget/EdgeEffect.java14
1 files changed, 4 insertions, 10 deletions
diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java
index ae426d2c897f..50fca043d4e0 100644
--- a/core/java/android/widget/EdgeEffect.java
+++ b/core/java/android/widget/EdgeEffect.java
@@ -626,20 +626,14 @@ public class EdgeEffect {
// assume rotations of increments of 90 degrees
float x = mTmpPoints[10] - mTmpPoints[8];
float width = right - left;
- float vecX = 0f;
- if (width > 0) {
- vecX = dampStretchVector(Math.max(-1f, Math.min(1f, x / width)));
- }
+ float vecX = dampStretchVector(Math.max(-1f, Math.min(1f, x / width)));
float y = mTmpPoints[11] - mTmpPoints[9];
float height = bottom - top;
- float vecY = 0f;
- if (height > 0) {
- vecY = dampStretchVector(Math.max(-1f, Math.min(1f, y / height)));
- }
+ float vecY = dampStretchVector(Math.max(-1f, Math.min(1f, y / height)));
- boolean hasStretchVectors = Float.compare(vecX, 0) != 0 || Float.compare(vecY, 0) != 0;
- if (right > left && bottom > top && mWidth > 0 && mHeight > 0 && hasStretchVectors) {
+ boolean hasValidVectors = Float.isFinite(vecX) && Float.isFinite(vecY);
+ if (right > left && bottom > top && mWidth > 0 && mHeight > 0 && hasValidVectors) {
renderNode.stretch(
left,
top,