Skip to content

Commit 9d9909a

Browse files
cketchamwcshi
authored andcommitted
Add @nonnull and @nullable annotations
PiperOrigin-RevId: 264624045
1 parent 83c2239 commit 9d9909a

7 files changed

Lines changed: 43 additions & 28 deletions

lib/java/com/google/android/material/circularreveal/CircularRevealCompat.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.animation.ObjectAnimator;
2323
import android.os.Build.VERSION;
2424
import android.os.Build.VERSION_CODES;
25+
import androidx.annotation.NonNull;
2526
import android.view.View;
2627
import android.view.ViewAnimationUtils;
2728
import com.google.android.material.circularreveal.CircularRevealWidget.CircularRevealEvaluator;
@@ -50,8 +51,9 @@ private CircularRevealCompat() {}
5051
* CircularRevealCompat#createCircularRevealListener(CircularRevealWidget)} and add the returned
5152
* AnimatorListener to this Animator or preferably to the overall AnimatorSet.
5253
*/
54+
@NonNull
5355
public static Animator createCircularReveal(
54-
CircularRevealWidget view, float centerX, float centerY, float endRadius) {
56+
@NonNull CircularRevealWidget view, float centerX, float centerY, float endRadius) {
5557
Animator revealInfoAnimator =
5658
ObjectAnimator.ofObject(
5759
view,
@@ -89,6 +91,7 @@ public static Animator createCircularReveal(
8991
* CircularRevealCompat#createCircularRevealListener(CircularRevealWidget)} and add the returned
9092
* AnimatorListener to this Animator or preferably to the overall AnimatorSet.
9193
*/
94+
@NonNull
9295
public static Animator createCircularReveal(
9396
CircularRevealWidget view, float centerX, float centerY, float startRadius, float endRadius) {
9497
Animator revealInfoAnimator =
@@ -114,7 +117,9 @@ public static Animator createCircularReveal(
114117
* Creates an AnimatorListener to be applied to either the Animator returned from {@link
115118
* #createCircularReveal} or preferably to the overall AnimatorSet.
116119
*/
117-
public static AnimatorListener createCircularRevealListener(final CircularRevealWidget view) {
120+
@NonNull
121+
public static AnimatorListener createCircularRevealListener(
122+
@NonNull final CircularRevealWidget view) {
118123
return new AnimatorListenerAdapter() {
119124
@Override
120125
public void onAnimationStart(Animator animation) {

lib/java/com/google/android/material/circularreveal/CircularRevealFrameLayout.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@
2020
import android.graphics.Canvas;
2121
import android.graphics.drawable.Drawable;
2222
import androidx.annotation.ColorInt;
23+
import androidx.annotation.NonNull;
2324
import androidx.annotation.Nullable;
2425
import android.util.AttributeSet;
2526
import android.widget.FrameLayout;
2627

2728
/** A CircularRevealWidget wrapper for {@link FrameLayout}. */
2829
public class CircularRevealFrameLayout extends FrameLayout implements CircularRevealWidget {
2930

30-
private final CircularRevealHelper helper;
31+
@NonNull private final CircularRevealHelper helper;
3132

32-
public CircularRevealFrameLayout(Context context) {
33+
public CircularRevealFrameLayout(@NonNull Context context) {
3334
this(context, null);
3435
}
3536

36-
public CircularRevealFrameLayout(Context context, AttributeSet attrs) {
37+
public CircularRevealFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
3738
super(context, attrs);
3839
helper = new CircularRevealHelper(this);
3940
}
@@ -82,7 +83,7 @@ public void setCircularRevealOverlayDrawable(@Nullable Drawable drawable) {
8283

8384
@SuppressLint("MissingSuperCall")
8485
@Override
85-
public void draw(Canvas canvas) {
86+
public void draw(@NonNull Canvas canvas) {
8687
if (helper != null) {
8788
helper.draw(canvas);
8889
} else {

lib/java/com/google/android/material/circularreveal/CircularRevealGridLayout.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
import android.graphics.Canvas;
2020
import android.graphics.drawable.Drawable;
2121
import androidx.annotation.ColorInt;
22+
import androidx.annotation.NonNull;
2223
import androidx.annotation.Nullable;
2324
import android.util.AttributeSet;
2425
import android.widget.GridLayout;
2526

2627
/** A CircularRevealWidget wrapper for {@link GridLayout}. */
2728
public class CircularRevealGridLayout extends GridLayout implements CircularRevealWidget {
2829

29-
private final CircularRevealHelper helper;
30+
@NonNull private final CircularRevealHelper helper;
3031

3132
public CircularRevealGridLayout(Context context) {
3233
this(context, null);
@@ -80,7 +81,7 @@ public void setCircularRevealOverlayDrawable(@Nullable Drawable drawable) {
8081
}
8182

8283
@Override
83-
public void draw(Canvas canvas) {
84+
public void draw(@NonNull Canvas canvas) {
8485
if (helper != null) {
8586
helper.draw(canvas);
8687
} else {

lib/java/com/google/android/material/circularreveal/CircularRevealHelper.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import android.os.Build.VERSION_CODES;
3434
import androidx.annotation.ColorInt;
3535
import androidx.annotation.IntDef;
36+
import androidx.annotation.NonNull;
3637
import androidx.annotation.Nullable;
3738
import android.view.View;
3839
import com.google.android.material.circularreveal.CircularRevealWidget.RevealInfo;
@@ -100,10 +101,10 @@ public interface Delegate {
100101
@Strategy public static final int STRATEGY;
101102

102103
private final Delegate delegate;
103-
private final View view;
104-
private final Path revealPath;
105-
private final Paint revealPaint;
106-
private final Paint scrimPaint;
104+
@NonNull private final View view;
105+
@NonNull private final Path revealPath;
106+
@NonNull private final Paint revealPaint;
107+
@NonNull private final Paint scrimPaint;
107108
/**
108109
* The circular reveal representation which affects how the current frame will be drawn.
109110
*
@@ -249,12 +250,12 @@ private void invalidateRevealInfo() {
249250
view.invalidate();
250251
}
251252

252-
private float getDistanceToFurthestCorner(RevealInfo revealInfo) {
253+
private float getDistanceToFurthestCorner(@NonNull RevealInfo revealInfo) {
253254
return MathUtils.distanceToFurthestCorner(
254255
revealInfo.centerX, revealInfo.centerY, 0, 0, view.getWidth(), view.getHeight());
255256
}
256257

257-
public void draw(Canvas canvas) {
258+
public void draw(@NonNull Canvas canvas) {
258259
if (DEBUG) {
259260
drawDebugMode(canvas);
260261
return;
@@ -299,7 +300,7 @@ public void draw(Canvas canvas) {
299300
drawOverlayDrawable(canvas);
300301
}
301302

302-
private void drawOverlayDrawable(Canvas canvas) {
303+
private void drawOverlayDrawable(@NonNull Canvas canvas) {
303304
if (shouldDrawOverlayDrawable()) {
304305
Rect bounds = overlayDrawable.getBounds();
305306
float translationX = revealInfo.centerX - bounds.width() / 2f;
@@ -332,7 +333,7 @@ private boolean shouldDrawOverlayDrawable() {
332333
return !buildingCircularRevealCache && overlayDrawable != null && revealInfo != null;
333334
}
334335

335-
private void drawDebugMode(Canvas canvas) {
336+
private void drawDebugMode(@NonNull Canvas canvas) {
336337
delegate.actualDraw(canvas);
337338
if (shouldDrawScrim()) {
338339
canvas.drawCircle(revealInfo.centerX, revealInfo.centerY, revealInfo.radius, scrimPaint);
@@ -347,7 +348,7 @@ private void drawDebugMode(Canvas canvas) {
347348
drawOverlayDrawable(canvas);
348349
}
349350

350-
private void drawDebugCircle(Canvas canvas, int color, float width) {
351+
private void drawDebugCircle(@NonNull Canvas canvas, int color, float width) {
351352
debugPaint.setColor(color);
352353
debugPaint.setStrokeWidth(width);
353354
canvas.drawCircle(

lib/java/com/google/android/material/circularreveal/CircularRevealLinearLayout.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
import android.graphics.Canvas;
2020
import android.graphics.drawable.Drawable;
2121
import androidx.annotation.ColorInt;
22+
import androidx.annotation.NonNull;
2223
import androidx.annotation.Nullable;
2324
import android.util.AttributeSet;
2425
import android.widget.LinearLayout;
2526

2627
/** A CircularRevealWidget wrapper for {@link LinearLayout}. */
2728
public class CircularRevealLinearLayout extends LinearLayout implements CircularRevealWidget {
2829

29-
private final CircularRevealHelper helper;
30+
@NonNull private final CircularRevealHelper helper;
3031

3132
public CircularRevealLinearLayout(Context context) {
3233
this(context, null);
@@ -80,7 +81,7 @@ public void setCircularRevealOverlayDrawable(@Nullable Drawable drawable) {
8081
}
8182

8283
@Override
83-
public void draw(Canvas canvas) {
84+
public void draw(@NonNull Canvas canvas) {
8485
if (helper != null) {
8586
helper.draw(canvas);
8687
} else {

lib/java/com/google/android/material/circularreveal/CircularRevealRelativeLayout.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
import android.graphics.Canvas;
2020
import android.graphics.drawable.Drawable;
2121
import androidx.annotation.ColorInt;
22+
import androidx.annotation.NonNull;
2223
import androidx.annotation.Nullable;
2324
import android.util.AttributeSet;
2425
import android.widget.RelativeLayout;
2526

2627
/** A CircularRevealWidget wrapper for {@link RelativeLayout}. */
2728
public class CircularRevealRelativeLayout extends RelativeLayout implements CircularRevealWidget {
2829

29-
private final CircularRevealHelper helper;
30+
@NonNull private final CircularRevealHelper helper;
3031

3132
public CircularRevealRelativeLayout(Context context) {
3233
this(context, null);
@@ -80,7 +81,7 @@ public void setCircularRevealOverlayDrawable(@Nullable Drawable drawable) {
8081
}
8182

8283
@Override
83-
public void draw(Canvas canvas) {
84+
public void draw(@NonNull Canvas canvas) {
8485
if (helper != null) {
8586
helper.draw(canvas);
8687
} else {

lib/java/com/google/android/material/circularreveal/CircularRevealWidget.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.graphics.Canvas;
2020
import android.graphics.drawable.Drawable;
2121
import androidx.annotation.ColorInt;
22+
import androidx.annotation.NonNull;
2223
import androidx.annotation.Nullable;
2324
import android.util.Property;
2425
import android.view.View;
@@ -148,7 +149,7 @@ public RevealInfo(float centerX, float centerY, float radius) {
148149
this.radius = radius;
149150
}
150151

151-
public RevealInfo(RevealInfo other) {
152+
public RevealInfo(@NonNull RevealInfo other) {
152153
this(other.centerX, other.centerY, other.radius);
153154
}
154155

@@ -158,7 +159,7 @@ public void set(float centerX, float centerY, float radius) {
158159
this.radius = radius;
159160
}
160161

161-
public void set(RevealInfo other) {
162+
public void set(@NonNull RevealInfo other) {
162163
set(other.centerX, other.centerY, other.radius);
163164
}
164165

@@ -184,13 +185,14 @@ private CircularRevealProperty(String name) {
184185
super(RevealInfo.class, name);
185186
}
186187

188+
@Nullable
187189
@Override
188-
public RevealInfo get(CircularRevealWidget object) {
190+
public RevealInfo get(@NonNull CircularRevealWidget object) {
189191
return object.getRevealInfo();
190192
}
191193

192194
@Override
193-
public void set(CircularRevealWidget object, RevealInfo value) {
195+
public void set(@NonNull CircularRevealWidget object, @Nullable RevealInfo value) {
194196
object.setRevealInfo(value);
195197
}
196198
}
@@ -207,8 +209,10 @@ class CircularRevealEvaluator implements TypeEvaluator<RevealInfo> {
207209
public static final TypeEvaluator<RevealInfo> CIRCULAR_REVEAL = new CircularRevealEvaluator();
208210
private final RevealInfo revealInfo = new RevealInfo();
209211

212+
@NonNull
210213
@Override
211-
public RevealInfo evaluate(float fraction, RevealInfo startValue, RevealInfo endValue) {
214+
public RevealInfo evaluate(
215+
float fraction, @NonNull RevealInfo startValue, @NonNull RevealInfo endValue) {
212216
revealInfo.set(
213217
MathUtils.lerp(startValue.centerX, endValue.centerX, fraction),
214218
MathUtils.lerp(startValue.centerY, endValue.centerY, fraction),
@@ -230,13 +234,14 @@ private CircularRevealScrimColorProperty(String name) {
230234
super(Integer.class, name);
231235
}
232236

237+
@NonNull
233238
@Override
234-
public Integer get(CircularRevealWidget object) {
239+
public Integer get(@NonNull CircularRevealWidget object) {
235240
return object.getCircularRevealScrimColor();
236241
}
237242

238243
@Override
239-
public void set(CircularRevealWidget object, Integer value) {
244+
public void set(@NonNull CircularRevealWidget object, @NonNull Integer value) {
240245
object.setCircularRevealScrimColor(value);
241246
}
242247
}

0 commit comments

Comments
 (0)