diff options
| author | Christopher Lane <lanechr@google.com> | 2014-10-31 22:01:35 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-10-31 22:01:35 +0000 |
| commit | be36ebc28dd1f86da521401266fd03ca0b59825c (patch) | |
| tree | 6f565205ded7f61a6ce2825b91b357eb8ec622a3 | |
| parent | fa21e75734878a9718f85c7d3f28c5946f15d01d (diff) | |
| parent | 9f357ae9f038b97e4426bf3707ca94624cdf5d75 (diff) | |
| download | frameworks_base-be36ebc28dd1f86da521401266fd03ca0b59825c.zip frameworks_base-be36ebc28dd1f86da521401266fd03ca0b59825c.tar.gz frameworks_base-be36ebc28dd1f86da521401266fd03ca0b59825c.tar.bz2 | |
Merge "Add convenience method for getting the complex unit type" into lmp-mr1-dev
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/util/TypedValue.java | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 69a2f3c..4445e3f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -32157,6 +32157,7 @@ package android.util { method public static int complexToDimensionPixelSize(int, android.util.DisplayMetrics); method public static float complexToFloat(int); method public static float complexToFraction(int, float, float); + method public int getComplexUnit(); method public float getDimension(android.util.DisplayMetrics); method public final float getFloat(); method public float getFraction(float, float); diff --git a/core/java/android/util/TypedValue.java b/core/java/android/util/TypedValue.java index d42ed03..74d4245 100644 --- a/core/java/android/util/TypedValue.java +++ b/core/java/android/util/TypedValue.java @@ -312,6 +312,18 @@ public class TypedValue { } /** + * Return the complex unit type for this value. For example, a dimen type + * with value 12sp will return {@link #COMPLEX_UNIT_SP}. Only use for values + * whose type is {@link #TYPE_DIMENSION}. + * + * @return The complex unit type. + */ + public int getComplexUnit() + { + return COMPLEX_UNIT_MASK & (data>>TypedValue.COMPLEX_UNIT_SHIFT); + } + + /** * Converts an unpacked complex data value holding a dimension to its final floating * point value. The two parameters <var>unit</var> and <var>value</var> * are as in {@link #TYPE_DIMENSION}. |
