diff options
Diffstat (limited to 'android/support/v4/widget')
17 files changed, 149 insertions, 99 deletions
diff --git a/android/support/v4/widget/AutoScrollHelper.java b/android/support/v4/widget/AutoScrollHelper.java index d0407be1..60d208d8 100644 --- a/android/support/v4/widget/AutoScrollHelper.java +++ b/android/support/v4/widget/AutoScrollHelper.java @@ -18,6 +18,7 @@ package android.support.v4.widget; import android.content.res.Resources; import android.os.SystemClock; +import android.support.annotation.NonNull; import android.support.v4.view.ViewCompat; import android.util.DisplayMetrics; import android.view.MotionEvent; @@ -205,7 +206,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * * @param target The view to automatically scroll. */ - public AutoScrollHelper(View target) { + public AutoScrollHelper(@NonNull View target) { mTarget = target; final DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); @@ -289,6 +290,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * {@link #NO_MAX} to leave the relative value unconstrained. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setMaximumVelocity(float horizontalMax, float verticalMax) { mMaximumVelocity[HORIZONTAL] = horizontalMax / 1000f; mMaximumVelocity[VERTICAL] = verticalMax / 1000f; @@ -307,6 +309,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * {@link #NO_MIN} to leave the relative value unconstrained. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setMinimumVelocity(float horizontalMin, float verticalMin) { mMinimumVelocity[HORIZONTAL] = horizontalMin / 1000f; mMinimumVelocity[VERTICAL] = verticalMin / 1000f; @@ -328,6 +331,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * ignore. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setRelativeVelocity(float horizontal, float vertical) { mRelativeVelocity[HORIZONTAL] = horizontal / 1000f; mRelativeVelocity[VERTICAL] = vertical / 1000f; @@ -349,6 +353,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * @param type The type of edge to use. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setEdgeType(int type) { mEdgeType = type; return this; @@ -368,6 +373,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * maximum value. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setRelativeEdges(float horizontal, float vertical) { mRelativeEdges[HORIZONTAL] = horizontal; mRelativeEdges[VERTICAL] = vertical; @@ -390,6 +396,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * value. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setMaximumEdges(float horizontalMax, float verticalMax) { mMaximumEdges[HORIZONTAL] = horizontalMax; mMaximumEdges[VERTICAL] = verticalMax; @@ -407,6 +414,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * @param delayMillis The activation delay in milliseconds. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setActivationDelay(int delayMillis) { mActivationDelay = delayMillis; return this; @@ -422,6 +430,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * @param durationMillis The ramp-up duration in milliseconds. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setRampUpDuration(int durationMillis) { mScroller.setRampUpDuration(durationMillis); return this; @@ -437,6 +446,7 @@ public abstract class AutoScrollHelper implements View.OnTouchListener { * @param durationMillis The ramp-down duration in milliseconds. * @return The scroll helper, which may used to chain setter calls. */ + @NonNull public AutoScrollHelper setRampDownDuration(int durationMillis) { mScroller.setRampDownDuration(durationMillis); return this; diff --git a/android/support/v4/widget/CircularProgressDrawable.java b/android/support/v4/widget/CircularProgressDrawable.java index ac295414..20556690 100644 --- a/android/support/v4/widget/CircularProgressDrawable.java +++ b/android/support/v4/widget/CircularProgressDrawable.java @@ -132,7 +132,7 @@ public class CircularProgressDrawable extends Drawable implements Animatable { /** * @param context application context */ - public CircularProgressDrawable(Context context) { + public CircularProgressDrawable(@NonNull Context context) { mResources = Preconditions.checkNotNull(context).getResources(); mRing = new Ring(); @@ -215,7 +215,7 @@ public class CircularProgressDrawable extends Drawable implements Animatable { * * @param strokeCap stroke cap */ - public void setStrokeCap(Paint.Cap strokeCap) { + public void setStrokeCap(@NonNull Paint.Cap strokeCap) { mRing.setStrokeCap(strokeCap); invalidateSelf(); } @@ -225,6 +225,7 @@ public class CircularProgressDrawable extends Drawable implements Animatable { * * @return stroke cap */ + @NonNull public Paint.Cap getStrokeCap() { return mRing.getStrokeCap(); } @@ -373,6 +374,7 @@ public class CircularProgressDrawable extends Drawable implements Animatable { * * @return list of ARGB colors */ + @NonNull public int[] getColorSchemeColors() { return mRing.getColors(); } @@ -383,7 +385,7 @@ public class CircularProgressDrawable extends Drawable implements Animatable { * * @param colors list of ARGB colors to be used in the spinner */ - public void setColorSchemeColors(int... colors) { + public void setColorSchemeColors(@NonNull int... colors) { mRing.setColors(colors); mRing.setColorIndex(0); invalidateSelf(); diff --git a/android/support/v4/widget/ContentLoadingProgressBar.java b/android/support/v4/widget/ContentLoadingProgressBar.java index 98b63a47..356c7b9e 100644 --- a/android/support/v4/widget/ContentLoadingProgressBar.java +++ b/android/support/v4/widget/ContentLoadingProgressBar.java @@ -17,6 +17,8 @@ package android.support.v4.widget; import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.View; import android.widget.ProgressBar; @@ -61,11 +63,11 @@ public class ContentLoadingProgressBar extends ProgressBar { } }; - public ContentLoadingProgressBar(Context context) { + public ContentLoadingProgressBar(@NonNull Context context) { this(context, null); } - public ContentLoadingProgressBar(Context context, AttributeSet attrs) { + public ContentLoadingProgressBar(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs, 0); } diff --git a/android/support/v4/widget/DrawerLayout.java b/android/support/v4/widget/DrawerLayout.java index c7b40e96..a73e1f10 100644 --- a/android/support/v4/widget/DrawerLayout.java +++ b/android/support/v4/widget/DrawerLayout.java @@ -248,7 +248,7 @@ public class DrawerLayout extends ViewGroup { * @param drawerView The child view that was moved * @param slideOffset The new offset of this drawer within its range, from 0-1 */ - void onDrawerSlide(View drawerView, float slideOffset); + void onDrawerSlide(@NonNull View drawerView, float slideOffset); /** * Called when a drawer has settled in a completely open state. @@ -256,14 +256,14 @@ public class DrawerLayout extends ViewGroup { * * @param drawerView Drawer view that is now open */ - void onDrawerOpened(View drawerView); + void onDrawerOpened(@NonNull View drawerView); /** * Called when a drawer has settled in a completely closed state. * * @param drawerView Drawer view that is now closed */ - void onDrawerClosed(View drawerView); + void onDrawerClosed(@NonNull View drawerView); /** * Called when the drawer motion state changes. The new state will @@ -296,15 +296,15 @@ public class DrawerLayout extends ViewGroup { } } - public DrawerLayout(Context context) { + public DrawerLayout(@NonNull Context context) { this(context, null); } - public DrawerLayout(Context context, AttributeSet attrs) { + public DrawerLayout(@NonNull Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } - public DrawerLayout(Context context, AttributeSet attrs, int defStyle) { + public DrawerLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); final float density = getResources().getDisplayMetrics().density; @@ -626,7 +626,7 @@ public class DrawerLayout extends ViewGroup { * @see #LOCK_MODE_LOCKED_CLOSED * @see #LOCK_MODE_LOCKED_OPEN */ - public void setDrawerLockMode(@LockMode int lockMode, View drawerView) { + public void setDrawerLockMode(@LockMode int lockMode, @NonNull View drawerView) { if (!isDrawerView(drawerView)) { throw new IllegalArgumentException("View " + drawerView + " is not a " + "drawer with appropriate layout_gravity"); @@ -700,7 +700,7 @@ public class DrawerLayout extends ViewGroup { * {@link #LOCK_MODE_LOCKED_OPEN}. */ @LockMode - public int getDrawerLockMode(View drawerView) { + public int getDrawerLockMode(@NonNull View drawerView) { if (!isDrawerView(drawerView)) { throw new IllegalArgumentException("View " + drawerView + " is not a drawer"); } @@ -718,7 +718,7 @@ public class DrawerLayout extends ViewGroup { * drawer to set the title for. * @param title The title for the drawer. */ - public void setDrawerTitle(@EdgeGravity int edgeGravity, CharSequence title) { + public void setDrawerTitle(@EdgeGravity int edgeGravity, @Nullable CharSequence title) { final int absGravity = GravityCompat.getAbsoluteGravity( edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGravity == Gravity.LEFT) { @@ -1276,7 +1276,7 @@ public class DrawerLayout extends ViewGroup { * * @param bg Background drawable to draw behind the status bar */ - public void setStatusBarBackground(Drawable bg) { + public void setStatusBarBackground(@Nullable Drawable bg) { mStatusBarBackground = bg; invalidate(); } @@ -1286,6 +1286,7 @@ public class DrawerLayout extends ViewGroup { * * @return The status bar background drawable, or null if none set */ + @Nullable public Drawable getStatusBarBackgroundDrawable() { return mStatusBarBackground; } @@ -1577,7 +1578,7 @@ public class DrawerLayout extends ViewGroup { * * @param drawerView Drawer view to open */ - public void openDrawer(View drawerView) { + public void openDrawer(@NonNull View drawerView) { openDrawer(drawerView, true); } @@ -1587,7 +1588,7 @@ public class DrawerLayout extends ViewGroup { * @param drawerView Drawer view to open * @param animate Whether opening of the drawer should be animated. */ - public void openDrawer(View drawerView, boolean animate) { + public void openDrawer(@NonNull View drawerView, boolean animate) { if (!isDrawerView(drawerView)) { throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer"); } @@ -1646,7 +1647,7 @@ public class DrawerLayout extends ViewGroup { * * @param drawerView Drawer view to close */ - public void closeDrawer(View drawerView) { + public void closeDrawer(@NonNull View drawerView) { closeDrawer(drawerView, true); } @@ -1656,7 +1657,7 @@ public class DrawerLayout extends ViewGroup { * @param drawerView Drawer view to close * @param animate Whether closing of the drawer should be animated. */ - public void closeDrawer(View drawerView, boolean animate) { + public void closeDrawer(@NonNull View drawerView, boolean animate) { if (!isDrawerView(drawerView)) { throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer"); } @@ -1718,7 +1719,7 @@ public class DrawerLayout extends ViewGroup { * @return true if the given drawer view is in an open state * @see #isDrawerVisible(android.view.View) */ - public boolean isDrawerOpen(View drawer) { + public boolean isDrawerOpen(@NonNull View drawer) { if (!isDrawerView(drawer)) { throw new IllegalArgumentException("View " + drawer + " is not a drawer"); } @@ -1751,7 +1752,7 @@ public class DrawerLayout extends ViewGroup { * @return true if the given drawer is visible on-screen * @see #isDrawerOpen(android.view.View) */ - public boolean isDrawerVisible(View drawer) { + public boolean isDrawerVisible(@NonNull View drawer) { if (!isDrawerView(drawer)) { throw new IllegalArgumentException("View " + drawer + " is not a drawer"); } @@ -2001,7 +2002,7 @@ public class DrawerLayout extends ViewGroup { @LockMode int lockModeStart; @LockMode int lockModeEnd; - public SavedState(Parcel in, ClassLoader loader) { + public SavedState(@NonNull Parcel in, @Nullable ClassLoader loader) { super(in, loader); openDrawerGravity = in.readInt(); lockModeLeft = in.readInt(); @@ -2010,7 +2011,7 @@ public class DrawerLayout extends ViewGroup { lockModeEnd = in.readInt(); } - public SavedState(Parcelable superState) { + public SavedState(@NonNull Parcelable superState) { super(superState); } @@ -2218,7 +2219,7 @@ public class DrawerLayout extends ViewGroup { boolean isPeeking; int openState; - public LayoutParams(Context c, AttributeSet attrs) { + public LayoutParams(@NonNull Context c, @Nullable AttributeSet attrs) { super(c, attrs); final TypedArray a = c.obtainStyledAttributes(attrs, LAYOUT_ATTRS); @@ -2235,16 +2236,16 @@ public class DrawerLayout extends ViewGroup { this.gravity = gravity; } - public LayoutParams(LayoutParams source) { + public LayoutParams(@NonNull LayoutParams source) { super(source); this.gravity = source.gravity; } - public LayoutParams(ViewGroup.LayoutParams source) { + public LayoutParams(@NonNull ViewGroup.LayoutParams source) { super(source); } - public LayoutParams(ViewGroup.MarginLayoutParams source) { + public LayoutParams(@NonNull ViewGroup.MarginLayoutParams source) { super(source); } } diff --git a/android/support/v4/widget/EdgeEffectCompat.java b/android/support/v4/widget/EdgeEffectCompat.java index 9293e60f..0d370a80 100644 --- a/android/support/v4/widget/EdgeEffectCompat.java +++ b/android/support/v4/widget/EdgeEffectCompat.java @@ -18,6 +18,7 @@ package android.support.v4.widget; import android.content.Context; import android.graphics.Canvas; import android.os.Build; +import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; import android.widget.EdgeEffect; @@ -170,7 +171,8 @@ public final class EdgeEffectCompat { * * @see {@link EdgeEffect#onPull(float, float)} */ - public static void onPull(EdgeEffect edgeEffect, float deltaDistance, float displacement) { + public static void onPull(@NonNull EdgeEffect edgeEffect, float deltaDistance, + float displacement) { IMPL.onPull(edgeEffect, deltaDistance, displacement); } diff --git a/android/support/v4/widget/ExploreByTouchHelper.java b/android/support/v4/widget/ExploreByTouchHelper.java index 8a29eff6..2b5ed0a1 100644 --- a/android/support/v4/widget/ExploreByTouchHelper.java +++ b/android/support/v4/widget/ExploreByTouchHelper.java @@ -129,7 +129,7 @@ public abstract class ExploreByTouchHelper extends AccessibilityDelegateCompat { * * @param host view whose virtual view hierarchy is exposed by this helper */ - public ExploreByTouchHelper(View host) { + public ExploreByTouchHelper(@NonNull View host) { if (host == null) { throw new IllegalArgumentException("View may not be null"); } @@ -1107,7 +1107,8 @@ public abstract class ExploreByTouchHelper extends AccessibilityDelegateCompat { * populate the event * @param event The event to populate */ - protected void onPopulateEventForVirtualView(int virtualViewId, AccessibilityEvent event) { + protected void onPopulateEventForVirtualView(int virtualViewId, + @NonNull AccessibilityEvent event) { // Default implementation is no-op. } @@ -1119,7 +1120,7 @@ public abstract class ExploreByTouchHelper extends AccessibilityDelegateCompat { * * @param event the event to populate with information about the host view */ - protected void onPopulateEventForHost(AccessibilityEvent event) { + protected void onPopulateEventForHost(@NonNull AccessibilityEvent event) { // Default implementation is no-op. } @@ -1187,7 +1188,7 @@ public abstract class ExploreByTouchHelper extends AccessibilityDelegateCompat { * @param node The node to populate */ protected abstract void onPopulateNodeForVirtualView( - int virtualViewId, AccessibilityNodeInfoCompat node); + int virtualViewId, @NonNull AccessibilityNodeInfoCompat node); /** * Populates an {@link AccessibilityNodeInfoCompat} with information @@ -1197,7 +1198,7 @@ public abstract class ExploreByTouchHelper extends AccessibilityDelegateCompat { * * @param node the node to populate with information about the host view */ - protected void onPopulateNodeForHost(AccessibilityNodeInfoCompat node) { + protected void onPopulateNodeForHost(@NonNull AccessibilityNodeInfoCompat node) { // Default implementation is no-op. } @@ -1225,7 +1226,7 @@ public abstract class ExploreByTouchHelper extends AccessibilityDelegateCompat { * @return true if the action was performed */ protected abstract boolean onPerformActionForVirtualView( - int virtualViewId, int action, Bundle arguments); + int virtualViewId, int action, @Nullable Bundle arguments); /** * Exposes a virtual view hierarchy to the accessibility framework. diff --git a/android/support/v4/widget/ImageViewCompat.java b/android/support/v4/widget/ImageViewCompat.java index acaaf636..b517de5f 100644 --- a/android/support/v4/widget/ImageViewCompat.java +++ b/android/support/v4/widget/ImageViewCompat.java @@ -20,6 +20,8 @@ import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.widget.ImageView; @@ -130,21 +132,24 @@ public class ImageViewCompat { /** * Return the tint applied to the image drawable, if specified. */ - public static ColorStateList getImageTintList(ImageView view) { + @Nullable + public static ColorStateList getImageTintList(@NonNull ImageView view) { return IMPL.getImageTintList(view); } /** * Applies a tint to the image drawable. */ - public static void setImageTintList(ImageView view, ColorStateList tintList) { + public static void setImageTintList(@NonNull ImageView view, + @Nullable ColorStateList tintList) { IMPL.setImageTintList(view, tintList); } /** * Return the blending mode used to apply the tint to the image drawable, if specified. */ - public static PorterDuff.Mode getImageTintMode(ImageView view) { + @Nullable + public static PorterDuff.Mode getImageTintMode(@NonNull ImageView view) { return IMPL.getImageTintMode(view); } @@ -153,7 +158,7 @@ public class ImageViewCompat { * {@link #setImageTintList(android.widget.ImageView, android.content.res.ColorStateList)} * to the image drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}. */ - public static void setImageTintMode(ImageView view, PorterDuff.Mode mode) { + public static void setImageTintMode(@NonNull ImageView view, @Nullable PorterDuff.Mode mode) { IMPL.setImageTintMode(view, mode); } diff --git a/android/support/v4/widget/ListPopupWindowCompat.java b/android/support/v4/widget/ListPopupWindowCompat.java index ab86e58b..45327331 100644 --- a/android/support/v4/widget/ListPopupWindowCompat.java +++ b/android/support/v4/widget/ListPopupWindowCompat.java @@ -17,6 +17,8 @@ package android.support.v4.widget; import android.os.Build; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.View; import android.view.View.OnTouchListener; import android.widget.ListPopupWindow; @@ -88,8 +90,9 @@ public final class ListPopupWindowCompat { * @return a touch listener that controls drag-to-open behavior, or {@code null} on * unsupported APIs */ + @Nullable public static OnTouchListener createDragToOpenListener( - ListPopupWindow listPopupWindow, View src) { + @NonNull ListPopupWindow listPopupWindow, @NonNull View src) { if (Build.VERSION.SDK_INT >= 19) { return listPopupWindow.createDragToOpenListener(src); } else { diff --git a/android/support/v4/widget/ListViewAutoScrollHelper.java b/android/support/v4/widget/ListViewAutoScrollHelper.java index 73d18cec..c373f27d 100644 --- a/android/support/v4/widget/ListViewAutoScrollHelper.java +++ b/android/support/v4/widget/ListViewAutoScrollHelper.java @@ -16,6 +16,7 @@ package android.support.v4.widget; +import android.support.annotation.NonNull; import android.view.View; import android.widget.ListView; @@ -26,7 +27,7 @@ import android.widget.ListView; public class ListViewAutoScrollHelper extends AutoScrollHelper { private final ListView mTarget; - public ListViewAutoScrollHelper(ListView target) { + public ListViewAutoScrollHelper(@NonNull ListView target) { super(target); mTarget = target; diff --git a/android/support/v4/widget/NestedScrollView.java b/android/support/v4/widget/NestedScrollView.java index 517686f3..73ff0848 100644 --- a/android/support/v4/widget/NestedScrollView.java +++ b/android/support/v4/widget/NestedScrollView.java @@ -26,6 +26,8 @@ import android.graphics.Rect; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.RestrictTo; import android.support.v4.view.AccessibilityDelegateCompat; import android.support.v4.view.InputDeviceCompat; @@ -181,15 +183,16 @@ public class NestedScrollView extends FrameLayout implements NestedScrollingPare private OnScrollChangeListener mOnScrollChangeListener; - public NestedScrollView(Context context) { + public NestedScrollView(@NonNull Context context) { this(context, null); } - public NestedScrollView(Context context, AttributeSet attrs) { + public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } - public NestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) { + public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attrs, + int defStyleAttr) { super(context, attrs, defStyleAttr); initScrollView(); @@ -441,7 +444,7 @@ public class NestedScrollView extends FrameLayout implements NestedScrollingPare * @see android.view.View#getScrollX() * @see android.view.View#getScrollY() */ - public void setOnScrollChangeListener(OnScrollChangeListener l) { + public void setOnScrollChangeListener(@Nullable OnScrollChangeListener l) { mOnScrollChangeListener = l; } @@ -552,7 +555,7 @@ public class NestedScrollView extends FrameLayout implements NestedScrollingPare * @param event The key event to execute. * @return Return true if the event was handled, else false. */ - public boolean executeKeyEvent(KeyEvent event) { + public boolean executeKeyEvent(@NonNull KeyEvent event) { mTempRect.setEmpty(); if (!canScroll()) { diff --git a/android/support/v4/widget/PopupMenuCompat.java b/android/support/v4/widget/PopupMenuCompat.java index 639a84ba..10c5ff3c 100644 --- a/android/support/v4/widget/PopupMenuCompat.java +++ b/android/support/v4/widget/PopupMenuCompat.java @@ -17,6 +17,8 @@ package android.support.v4.widget; import android.os.Build; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.View.OnTouchListener; import android.widget.PopupMenu; @@ -47,7 +49,8 @@ public final class PopupMenuCompat { * @return a touch listener that controls drag-to-open behavior, or {@code null} on * unsupported APIs */ - public static OnTouchListener getDragToOpenListener(Object popupMenu) { + @Nullable + public static OnTouchListener getDragToOpenListener(@NonNull Object popupMenu) { if (Build.VERSION.SDK_INT >= 19) { return ((PopupMenu) popupMenu).getDragToOpenListener(); } else { diff --git a/android/support/v4/widget/PopupWindowCompat.java b/android/support/v4/widget/PopupWindowCompat.java index d846b409..d9de3db6 100644 --- a/android/support/v4/widget/PopupWindowCompat.java +++ b/android/support/v4/widget/PopupWindowCompat.java @@ -17,6 +17,7 @@ package android.support.v4.widget; import android.os.Build; +import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; import android.support.v4.view.GravityCompat; import android.support.v4.view.ViewCompat; @@ -213,8 +214,8 @@ public final class PopupWindowCompat { * @param yoff A vertical offset from the anchor in pixels * @param gravity Alignment of the popup relative to the anchor */ - public static void showAsDropDown(PopupWindow popup, View anchor, int xoff, int yoff, - int gravity) { + public static void showAsDropDown(@NonNull PopupWindow popup, @NonNull View anchor, + int xoff, int yoff, int gravity) { IMPL.showAsDropDown(popup, anchor, xoff, yoff, gravity); } @@ -224,7 +225,7 @@ public final class PopupWindowCompat { * * @param overlapAnchor Whether the popup should overlap its anchor. */ - public static void setOverlapAnchor(PopupWindow popupWindow, boolean overlapAnchor) { + public static void setOverlapAnchor(@NonNull PopupWindow popupWindow, boolean overlapAnchor) { IMPL.setOverlapAnchor(popupWindow, overlapAnchor); } @@ -234,7 +235,7 @@ public final class PopupWindowCompat { * * @return Whether the popup should overlap its anchor. */ - public static boolean getOverlapAnchor(PopupWindow popupWindow) { + public static boolean getOverlapAnchor(@NonNull PopupWindow popupWindow) { return IMPL.getOverlapAnchor(popupWindow); } @@ -247,7 +248,7 @@ public final class PopupWindowCompat { * * @see android.view.WindowManager.LayoutParams#type */ - public static void setWindowLayoutType(PopupWindow popupWindow, int layoutType) { + public static void setWindowLayoutType(@NonNull PopupWindow popupWindow, int layoutType) { IMPL.setWindowLayoutType(popupWindow, layoutType); } @@ -256,7 +257,7 @@ public final class PopupWindowCompat { * * @see #setWindowLayoutType(PopupWindow popupWindow, int) */ - public static int getWindowLayoutType(PopupWindow popupWindow) { + public static int getWindowLayoutType(@NonNull PopupWindow popupWindow) { return IMPL.getWindowLayoutType(popupWindow); } } diff --git a/android/support/v4/widget/SlidingPaneLayout.java b/android/support/v4/widget/SlidingPaneLayout.java index 602df705..5676ccf8 100644 --- a/android/support/v4/widget/SlidingPaneLayout.java +++ b/android/support/v4/widget/SlidingPaneLayout.java @@ -30,6 +30,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.ColorInt; import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.support.v4.content.ContextCompat; import android.support.v4.view.AbsSavedState; @@ -213,20 +215,20 @@ public class SlidingPaneLayout extends ViewGroup { * @param panel The child view that was moved * @param slideOffset The new offset of this sliding pane within its range, from 0-1 */ - void onPanelSlide(View panel, float slideOffset); + void onPanelSlide(@NonNull View panel, float slideOffset); /** * Called when a sliding pane becomes slid completely open. The pane may or may not * be interactive at this point depending on how much of the pane is visible. * @param panel The child view that was slid to an open position, revealing other panes */ - void onPanelOpened(View panel); + void onPanelOpened(@NonNull View panel); /** * Called when a sliding pane becomes slid completely closed. The pane is now guaranteed * to be interactive. It may now obscure other views in the layout. * @param panel The child view that was slid to a closed position */ - void onPanelClosed(View panel); + void onPanelClosed(@NonNull View panel); } /** @@ -245,15 +247,15 @@ public class SlidingPaneLayout extends ViewGroup { } } - public SlidingPaneLayout(Context context) { + public SlidingPaneLayout(@NonNull Context context) { this(context, null); } - public SlidingPaneLayout(Context context, AttributeSet attrs) { + public SlidingPaneLayout(@NonNull Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } - public SlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) { + public SlidingPaneLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final float density = context.getResources().getDisplayMetrics().density; @@ -324,7 +326,7 @@ public class SlidingPaneLayout extends ViewGroup { return mCoveredFadeColor; } - public void setPanelSlideListener(PanelSlideListener listener) { + public void setPanelSlideListener(@Nullable PanelSlideListener listener) { mPanelSlideListener = listener; } @@ -1081,7 +1083,7 @@ public class SlidingPaneLayout extends ViewGroup { * * @param d drawable to use as a shadow */ - public void setShadowDrawableLeft(Drawable d) { + public void setShadowDrawableLeft(@Nullable Drawable d) { mShadowDrawableLeft = d; } @@ -1091,7 +1093,7 @@ public class SlidingPaneLayout extends ViewGroup { * * @param d drawable to use as a shadow */ - public void setShadowDrawableRight(Drawable d) { + public void setShadowDrawableRight(@Nullable Drawable d) { mShadowDrawableRight = d; } @@ -1410,20 +1412,20 @@ public class SlidingPaneLayout extends ViewGroup { super(width, height); } - public LayoutParams(android.view.ViewGroup.LayoutParams source) { + public LayoutParams(@NonNull android.view.ViewGroup.LayoutParams source) { super(source); } - public LayoutParams(MarginLayoutParams source) { + public LayoutParams(@NonNull MarginLayoutParams source) { super(source); } - public LayoutParams(LayoutParams source) { + public LayoutParams(@NonNull LayoutParams source) { super(source); this.weight = source.weight; } - public LayoutParams(Context c, AttributeSet attrs) { + public LayoutParams(@NonNull Context c, @Nullable AttributeSet attrs) { super(c, attrs); final TypedArray a = c.obtainStyledAttributes(attrs, ATTRS); diff --git a/android/support/v4/widget/Space.java b/android/support/v4/widget/Space.java index 77a2d2ee..7d37a72b 100644 --- a/android/support/v4/widget/Space.java +++ b/android/support/v4/widget/Space.java @@ -19,6 +19,8 @@ package android.support.v4.widget; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Canvas; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.View; @@ -28,18 +30,18 @@ import android.view.View; */ public class Space extends View { - public Space(Context context, AttributeSet attrs, int defStyle) { + public Space(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (getVisibility() == VISIBLE) { setVisibility(INVISIBLE); } } - public Space(Context context, AttributeSet attrs) { + public Space(@NonNull Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } - public Space(Context context) { + public Space(@NonNull Context context) { this(context, null); } diff --git a/android/support/v4/widget/SwipeRefreshLayout.java b/android/support/v4/widget/SwipeRefreshLayout.java index d36ae225..ca04e46a 100644 --- a/android/support/v4/widget/SwipeRefreshLayout.java +++ b/android/support/v4/widget/SwipeRefreshLayout.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v4.content.ContextCompat; @@ -316,7 +317,7 @@ public class SwipeRefreshLayout extends ViewGroup implements NestedScrollingPare * * @param context */ - public SwipeRefreshLayout(Context context) { + public SwipeRefreshLayout(@NonNull Context context) { this(context, null); } @@ -326,7 +327,7 @@ public class SwipeRefreshLayout extends ViewGroup implements NestedScrollingPare * @param context * @param attrs */ - public SwipeRefreshLayout(Context context, AttributeSet attrs) { + public SwipeRefreshLayout(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); @@ -341,7 +342,7 @@ public class SwipeRefreshLayout extends ViewGroup implements NestedScrollingPare mCircleDiameter = (int) (CIRCLE_DIAMETER * metrics.density); createProgressView(); - ViewCompat.setChildrenDrawingOrderEnabled(this, true); + setChildrenDrawingOrderEnabled(true); // the absolute offset has to take into account that the circle starts at an offset mSpinnerOffsetEnd = (int) (DEFAULT_CIRCLE_TARGET * metrics.density); mTotalDragDistance = mSpinnerOffsetEnd; @@ -387,7 +388,7 @@ public class SwipeRefreshLayout extends ViewGroup implements NestedScrollingPare * Set the listener to be notified when a refresh is triggered via the swipe * gesture. */ - public void setOnRefreshListener(OnRefreshListener listener) { + public void setOnRefreshListener(@Nullable OnRefreshListener listener) { mListener = listener; } @@ -1189,6 +1190,6 @@ public class SwipeRefreshLayout extends ViewGroup implements NestedScrollingPare * * @return Whether it is possible for the child view of parent layout to scroll up. */ - boolean canChildScrollUp(SwipeRefreshLayout parent, @Nullable View child); + boolean canChildScrollUp(@NonNull SwipeRefreshLayout parent, @Nullable View child); } } diff --git a/android/support/v4/widget/TextViewCompat.java b/android/support/v4/widget/TextViewCompat.java index 8d9e4ab0..dc87a38b 100644 --- a/android/support/v4/widget/TextViewCompat.java +++ b/android/support/v4/widget/TextViewCompat.java @@ -479,6 +479,7 @@ public final class TextViewCompat { /** * Returns drawables for the start, top, end, and bottom borders from the given text view. */ + @NonNull public static Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView) { return IMPL.getCompoundDrawablesRelative(textView); } @@ -493,7 +494,8 @@ public final class TextViewCompat { * * @attr name android:autoSizeTextType */ - public static void setAutoSizeTextTypeWithDefaults(TextView textView, int autoSizeTextType) { + public static void setAutoSizeTextTypeWithDefaults(@NonNull TextView textView, + int autoSizeTextType) { IMPL.setAutoSizeTextTypeWithDefaults(textView, autoSizeTextType); } @@ -519,7 +521,7 @@ public final class TextViewCompat { * @attr name android:autoSizeStepGranularity */ public static void setAutoSizeTextTypeUniformWithConfiguration( - TextView textView, + @NonNull TextView textView, int autoSizeMinTextSize, int autoSizeMaxTextSize, int autoSizeStepGranularity, @@ -542,7 +544,7 @@ public final class TextViewCompat { * @attr name android:autoSizeTextType * @attr name android:autoSizePresetSizes */ - public static void setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, + public static void setAutoSizeTextTypeUniformWithPresetSizes(@NonNull TextView textView, @NonNull int[] presetSizes, int unit) throws IllegalArgumentException { IMPL.setAutoSizeTextTypeUniformWithPresetSizes(textView, presetSizes, unit); } @@ -556,7 +558,7 @@ public final class TextViewCompat { * * @attr name android:autoSizeTextType */ - public static int getAutoSizeTextType(TextView textView) { + public static int getAutoSizeTextType(@NonNull TextView textView) { return IMPL.getAutoSizeTextType(textView); } @@ -565,7 +567,7 @@ public final class TextViewCompat { * * @attr name android:autoSizeStepGranularity */ - public static int getAutoSizeStepGranularity(TextView textView) { + public static int getAutoSizeStepGranularity(@NonNull TextView textView) { return IMPL.getAutoSizeStepGranularity(textView); } @@ -575,7 +577,7 @@ public final class TextViewCompat { * * @attr name android:autoSizeMinTextSize */ - public static int getAutoSizeMinTextSize(TextView textView) { + public static int getAutoSizeMinTextSize(@NonNull TextView textView) { return IMPL.getAutoSizeMinTextSize(textView); } @@ -585,7 +587,7 @@ public final class TextViewCompat { * * @attr name android:autoSizeMaxTextSize */ - public static int getAutoSizeMaxTextSize(TextView textView) { + public static int getAutoSizeMaxTextSize(@NonNull TextView textView) { return IMPL.getAutoSizeMaxTextSize(textView); } @@ -594,7 +596,8 @@ public final class TextViewCompat { * * @attr name android:autoSizePresetSizes */ - public static int[] getAutoSizeTextAvailableSizes(TextView textView) { + @NonNull + public static int[] getAutoSizeTextAvailableSizes(@NonNull TextView textView) { return IMPL.getAutoSizeTextAvailableSizes(textView); } } diff --git a/android/support/v4/widget/ViewDragHelper.java b/android/support/v4/widget/ViewDragHelper.java index c222c175..09c6f663 100644 --- a/android/support/v4/widget/ViewDragHelper.java +++ b/android/support/v4/widget/ViewDragHelper.java @@ -18,6 +18,8 @@ package android.support.v4.widget; import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.view.ViewCompat; import android.util.Log; import android.view.MotionEvent; @@ -167,7 +169,9 @@ public class ViewDragHelper { * @param dx Change in X position from the last call * @param dy Change in Y position from the last call */ - public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {} + public void onViewPositionChanged(@NonNull View changedView, int left, int top, int dx, + int dy) { + } /** * Called when a child view is captured for dragging or settling. The ID of the pointer @@ -178,7 +182,7 @@ public class ViewDragHelper { * @param capturedChild Child view that was captured * @param activePointerId Pointer id tracking the child capture */ - public void onViewCaptured(View capturedChild, int activePointerId) {} + public void onViewCaptured(@NonNull View capturedChild, int activePointerId) {} /** * Called when the child view is no longer being actively dragged. @@ -198,7 +202,7 @@ public class ViewDragHelper { * @param xvel X velocity of the pointer as it left the screen in pixels per second. * @param yvel Y velocity of the pointer as it left the screen in pixels per second. */ - public void onViewReleased(View releasedChild, float xvel, float yvel) {} + public void onViewReleased(@NonNull View releasedChild, float xvel, float yvel) {} /** * Called when one of the subscribed edges in the parent view has been touched @@ -256,7 +260,7 @@ public class ViewDragHelper { * @param child Child view to check * @return range of horizontal motion in pixels */ - public int getViewHorizontalDragRange(View child) { + public int getViewHorizontalDragRange(@NonNull View child) { return 0; } @@ -267,7 +271,7 @@ public class ViewDragHelper { * @param child Child view to check * @return range of vertical motion in pixels */ - public int getViewVerticalDragRange(View child) { + public int getViewVerticalDragRange(@NonNull View child) { return 0; } @@ -287,7 +291,7 @@ public class ViewDragHelper { * @param pointerId ID of the pointer attempting the capture * @return true if capture should be allowed, false otherwise */ - public abstract boolean tryCaptureView(View child, int pointerId); + public abstract boolean tryCaptureView(@NonNull View child, int pointerId); /** * Restrict the motion of the dragged child view along the horizontal axis. @@ -300,7 +304,7 @@ public class ViewDragHelper { * @param dx Proposed change in position for left * @return The new clamped position for left */ - public int clampViewPositionHorizontal(View child, int left, int dx) { + public int clampViewPositionHorizontal(@NonNull View child, int left, int dx) { return 0; } @@ -315,7 +319,7 @@ public class ViewDragHelper { * @param dy Proposed change in position for top * @return The new clamped position for top */ - public int clampViewPositionVertical(View child, int top, int dy) { + public int clampViewPositionVertical(@NonNull View child, int top, int dy) { return 0; } } @@ -345,7 +349,7 @@ public class ViewDragHelper { * @param cb Callback to provide information and receive events * @return a new ViewDragHelper instance */ - public static ViewDragHelper create(ViewGroup forParent, Callback cb) { + public static ViewDragHelper create(@NonNull ViewGroup forParent, @NonNull Callback cb) { return new ViewDragHelper(forParent.getContext(), forParent, cb); } @@ -358,7 +362,8 @@ public class ViewDragHelper { * @param cb Callback to provide information and receive events * @return a new ViewDragHelper instance */ - public static ViewDragHelper create(ViewGroup forParent, float sensitivity, Callback cb) { + public static ViewDragHelper create(@NonNull ViewGroup forParent, float sensitivity, + @NonNull Callback cb) { final ViewDragHelper helper = create(forParent, cb); helper.mTouchSlop = (int) (helper.mTouchSlop * (1 / sensitivity)); return helper; @@ -372,7 +377,8 @@ public class ViewDragHelper { * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ - private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) { + private ViewDragHelper(@NonNull Context context, @NonNull ViewGroup forParent, + @NonNull Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } @@ -458,7 +464,7 @@ public class ViewDragHelper { * @param childView Child view to capture * @param activePointerId ID of the pointer that is dragging the captured child view */ - public void captureChildView(View childView, int activePointerId) { + public void captureChildView(@NonNull View childView, int activePointerId) { if (childView.getParent() != mParentView) { throw new IllegalArgumentException("captureChildView: parameter must be a descendant " + "of the ViewDragHelper's tracked parent view (" + mParentView + ")"); @@ -473,6 +479,7 @@ public class ViewDragHelper { /** * @return The currently captured view, or null if no view has been captured. */ + @Nullable public View getCapturedView() { return mCapturedView; } @@ -537,7 +544,7 @@ public class ViewDragHelper { * @param finalTop Final top position of child * @return true if animation should continue through {@link #continueSettling(boolean)} calls */ - public boolean smoothSlideViewTo(View child, int finalLeft, int finalTop) { + public boolean smoothSlideViewTo(@NonNull View child, int finalLeft, int finalTop) { mCapturedView = child; mActivePointerId = INVALID_POINTER; @@ -918,7 +925,7 @@ public class ViewDragHelper { * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ - protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { + protected boolean canScroll(@NonNull View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); @@ -948,7 +955,7 @@ public class ViewDragHelper { * @param ev MotionEvent provided to onInterceptTouchEvent * @return true if the parent view should return true from onInterceptTouchEvent */ - public boolean shouldInterceptTouchEvent(MotionEvent ev) { + public boolean shouldInterceptTouchEvent(@NonNull MotionEvent ev) { final int action = ev.getActionMasked(); final int actionIndex = ev.getActionIndex(); @@ -1082,7 +1089,7 @@ public class ViewDragHelper { * * @param ev The touch event received by the parent view */ - public void processTouchEvent(MotionEvent ev) { + public void processTouchEvent(@NonNull MotionEvent ev) { final int action = ev.getActionMasked(); final int actionIndex = ev.getActionIndex(); @@ -1453,7 +1460,7 @@ public class ViewDragHelper { * @param y Y position to test in the parent's coordinate system * @return true if the supplied view is under the given point, false otherwise */ - public boolean isViewUnder(View view, int x, int y) { + public boolean isViewUnder(@Nullable View view, int x, int y) { if (view == null) { return false; } @@ -1471,6 +1478,7 @@ public class ViewDragHelper { * @param y Y position to test in the parent's coordinate system * @return The topmost child view under (x, y) or null if none found. */ + @Nullable public View findTopChildUnder(int x, int y) { final int childCount = mParentView.getChildCount(); for (int i = childCount - 1; i >= 0; i--) { |