diff options
| -rw-r--r-- | core/java/android/view/View.java | 11 | ||||
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b5b0baa00e80..2a7b92d0bb3a 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -24,6 +24,7 @@ import android.annotation.DrawableRes; import android.annotation.FloatRange; import android.annotation.IdRes; import android.annotation.IntDef; +import android.annotation.IntRange; import android.annotation.LayoutRes; import android.annotation.NonNull; import android.annotation.Nullable; @@ -21563,6 +21564,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private static final int MODE_SHIFT = 30; private static final int MODE_MASK = 0x3 << MODE_SHIFT; + /** @hide */ + @IntDef({UNSPECIFIED, EXACTLY, AT_MOST}) + @Retention(RetentionPolicy.SOURCE) + public @interface MeasureSpecMode {} + /** * Measure specification mode: The parent has not imposed any constraint * on the child. It can be whatever size it wants. @@ -21603,7 +21609,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @param mode the mode of the measure specification * @return the measure specification based on size and mode */ - public static int makeMeasureSpec(int size, int mode) { + public static int makeMeasureSpec(@IntRange(from = 0, to = (1 << MeasureSpec.MODE_SHIFT) - 1) int size, + @MeasureSpecMode int mode) { if (sUseBrokenMakeMeasureSpec) { return size + mode; } else { @@ -21632,7 +21639,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@link android.view.View.MeasureSpec#AT_MOST} or * {@link android.view.View.MeasureSpec#EXACTLY} */ + @MeasureSpecMode public static int getMode(int measureSpec) { + //noinspection ResourceType return (measureSpec & MODE_MASK); } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index e86b71edfde1..27e2ea37e748 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -6090,6 +6090,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } break; } + //noinspection ResourceType return MeasureSpec.makeMeasureSpec(resultSize, resultMode); } |