TL;DR: Can Android's @SuppressWarnings("deprecation")
, or similar, be applied to a single statement, rather than an entire method?
I have a method myMethod
that uses deprecated method ImageView.setAlpha()
:
public void myMethod(ImageView icon) { icon.setAlpha(0xFF); }
To avoid use of the deprecated method in Jelly Bean and subsequent releases, whilst providing backward compatibility, method myMethod
can be rewritten as follows:
public void myMethod(ImageView icon) {
if (android.os.Build.VERSION.SDK_INT
>= android.os.Build.VERSION_CODES.JELLY_BEAN)
icon.setImageAlpha(0xFF);
else
icon.setAlpha(0xFF);
}
Moreover, command line warnings generated by Gradle/Lint can be suppressed by prepending method myMethod
with @SuppressWarnings("deprecation")
. But, that suppresses all deprecated warnings generated by method myMethod
, rather than just the single warning generated by statement icon.setAlpha(0xFF)
.
Can I suppress the single deprecation warning generated by statement icon.setAlpha(0xFF)
, rather than suppressing all deprecation warnings generated by method myMethod
?