My Android Java code has a class that includes cancel
method:
private void hide(int aniDuration) { if (!isVisible) return; if (runnable != null) handler.removeCallbacks(runnable); isVisible = false; if (aniDuration > 0) { fadeInOut(false, aniDuration); } else { notifierLayout.setAlpha(0.0f); notifierLayout.setVisibility(View.GONE); } } private void hide() { hide(animateDuration); } @SuppressWarnings({"unused", "WeakerAccess"}) public void cancel() { hide(); } @SuppressWarnings({"unused", "WeakerAccess"}) public void cancel(int aniDuration) { hide(aniDuration); }
But since (so far) I call this cancel
method just once with the parameter aniDuration = 0
, the Android Studio debugger shows the following warning message:
Actual value of parameter "aniDuration" is always "0"
Besides of using @SuppressWarnings("all")
, how could I suppress this type of warning?
Annotation Type SuppressWarningsIndicates that the named compiler warnings should be suppressed in the annotated element (and in all program elements contained in the annotated element). Note that the set of warnings suppressed in a given element is a superset of the warnings suppressed in all containing elements.
Use of @SuppressWarnings is to suppress or ignore warnings coming from the compiler, i.e., the compiler will ignore warnings if any for that piece of code. 1. @SuppressWarnings("unchecked") public class Calculator { } - Here, it will ignore all unchecked warnings coming from that class.
You can suppress it with
JAVA:
@SuppressWarnings("SameParameterValue")
KOTLIN:
@Suppress("SameParameterValue")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With