簡體   English   中英

抑制警告〜參數X的實際值始終為Y.

[英]Suppress warning ~ Actual value of parameter X is always 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調試器會顯示以下警告消息:

參數“aniDuration”的實際值始終為“0”

在此輸入圖像描述

除了使用@SuppressWarnings("all") ,我怎么能抑制這種類型的警告呢?

你可以用它來壓制它

@SuppressWarnings("SameParameterValue")

文件>設置>編輯器>檢查>查找:“實際方法參數是相同的常量”取消選中並重新啟動android studio

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM