java Suppress warning~参数X的实际值始终为Y
我的Android Java代码有一个包含cancel
方法的类:
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);
}
但由于(到目前为止)我只使用参数aniDuration = 0
调用了此cancel
方法一次,因此Android Studio调试器显示以下警告消息:
Actual value of parameter "aniDuration" is always "0"
除了使用@SuppressWarnings("all")
之外,我如何抑制这种类型的警告
# 1 楼答案
您可以使用
# 2 楼答案
文件>;设置>;编辑>;检查>;查找:“实际方法参数为同一常数” 取消选中并重新启动android studio