summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhoford <hoford@google.com>2018-03-14 12:23:06 -0700
committerhoford <hoford@google.com>2018-03-14 16:17:30 -0700
commit53536ce526bc0eeaa57c8bc6126b09fba0a22342 (patch)
tree4bccc2004d78f93ec95d51341acf6dcc4ffb9cfc
parent62068c5bf36a6fe65e8497d11eb0df4dd55047eb (diff)
downloadsherpa-53536ce526bc0eeaa57c8bc6126b09fba0a22342.tar.gz
ignore 0.0 settings in pivot
Test: N/A bug:74055506 Change-Id: I7b060c9d67ee386c4ca4dd05008f7ccb92e1932d
-rw-r--r--constraintlayout/src/main/java/android/support/constraint/ConstraintSet.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/constraintlayout/src/main/java/android/support/constraint/ConstraintSet.java b/constraintlayout/src/main/java/android/support/constraint/ConstraintSet.java
index 00aa2ca..0920ba1 100644
--- a/constraintlayout/src/main/java/android/support/constraint/ConstraintSet.java
+++ b/constraintlayout/src/main/java/android/support/constraint/ConstraintSet.java
@@ -683,6 +683,9 @@ public class ConstraintSet {
ConstraintLayout.LayoutParams param = (ConstraintLayout.LayoutParams) view.getLayoutParams();
int id = view.getId();
+ if (id == -1) {
+ throw new RuntimeException("All children of ConstraintLayout must have ids to use ConstraintSet");
+ }
if (!mConstraints.containsKey(id)) {
mConstraints.put(id, new Constraint());
}
@@ -696,8 +699,15 @@ public class ConstraintSet {
constraint.rotationY = view.getRotationY();
constraint.scaleX = view.getScaleX();
constraint.scaleY = view.getScaleY();
- constraint.transformPivotX = view.getPivotX();
- constraint.transformPivotY = view.getPivotY();
+
+ float pivotX = view.getPivotX(); // we assume it is not set if set to 0.0
+ float pivotY = view.getPivotY(); // we assume it is not set if set to 0.0
+
+ if (pivotX != 0.0 || pivotY != 0.0) {
+ constraint.transformPivotX = pivotX;
+ constraint.transformPivotY = pivotY;
+ }
+
constraint.translationX = view.getTranslationX();
constraint.translationY = view.getTranslationY();
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
@@ -723,6 +733,9 @@ public class ConstraintSet {
Constraints.LayoutParams param = (Constraints.LayoutParams) view.getLayoutParams();
int id = view.getId();
+ if (id == -1) {
+ throw new RuntimeException("All children of ConstraintLayout must have ids to use ConstraintSet");
+ }
if (!mConstraints.containsKey(id)) {
mConstraints.put(id, new Constraint());
}
@@ -755,6 +768,9 @@ public class ConstraintSet {
for (int i = 0; i < count; i++) {
View view = constraintLayout.getChildAt(i);
int id = view.getId();
+ if (id == -1) {
+ throw new RuntimeException("All children of ConstraintLayout must have ids to use ConstraintSet");
+ }
if (mConstraints.containsKey(id)) {
used.remove(id);
Constraint constraint = mConstraints.get(id);
@@ -1557,6 +1573,8 @@ public class ConstraintSet {
/**
* Set X location of the pivot point around which the view will rotate and scale.
+ * use Float.NaN to clear the pivot value.
+ * Note: once an actual View has had its pivot set it cannot be cleared.
*
* @param viewId ID of view to adjust the transforms pivot point about X
* @param transformPivotX X location of the pivot point.
@@ -1567,6 +1585,8 @@ public class ConstraintSet {
/**
* Set Y location of the pivot point around which the view will rotate and scale.
+ * use Float.NaN to clear the pivot value.
+ * Note: once an actual View has had its pivot set it cannot be cleared.
*
* @param viewId ID of view to adjust the transforms pivot point about Y
* @param transformPivotY Y location of the pivot point.
@@ -1577,6 +1597,8 @@ public class ConstraintSet {
/**
* Set X,Y location of the pivot point around which the view will rotate and scale.
+ * use Float.NaN to clear the pivot value.
+ * Note: once an actual View has had its pivot set it cannot be cleared.
*
* @param viewId ID of view to adjust the transforms pivot point
* @param transformPivotX X location of the pivot point.