{"record":{"id":"7d9e6a7761c2ea31","repo":"material-components/material-components-android","slug":"the-component-s-visibility-must-be-one-of-visible","errorCode":null,"errorMessage":"The component's visibility must be one of VISIBLE, INVISIBLE, and GONE defined in View.","messagePattern":"The component's visibility must be one of VISIBLE, INVISIBLE, and GONE defined in View\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/progressindicator/BaseProgressIndicator.java","lineNumber":958,"sourceCode":"    } else {\n      // Calls ProgressBar setProgress(int) to update the progress value and level. We don't rely on\n      // it to draw or animate the indicator.\n      super.setProgress(progress);\n      // Fast forward to the final state of the determinate animation.\n      if (getProgressDrawable() != null && !animated) {\n        getProgressDrawable().jumpToCurrentState();\n      }\n    }\n  }\n\n  /**\n   * Sets the visibility which the component will be after hide animation finishes.\n   *\n   * @param visibility New component's visibility after the hide animation finishes.\n   */\n  public void setVisibilityAfterHide(int visibility) {\n    if (visibility != View.VISIBLE && visibility != View.INVISIBLE && visibility != View.GONE) {\n      throw new IllegalArgumentException(\n          \"The component's visibility must be one of VISIBLE, INVISIBLE, and GONE defined in\"\n              + \" View.\");\n    }\n    visibilityAfterHide = visibility;\n  }\n\n  private final OnAnimationEndListener hideAfterMaxProgressListener =\n      (animation, canceled, value, velocity) -> {\n        if (getProgressDrawable() != null\n            && getProgressDrawable().getLevel() == MAX_DRAWABLE_LEVEL) {\n          hide();\n        }\n      };\n\n  public void setHideAfterMaxProgress(boolean hideAfterMaxProgress) {\n    if (getProgressDrawable() == null) {\n      return;\n    }","sourceCodeStart":940,"sourceCodeEnd":976,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/progressindicator/BaseProgressIndicator.java#L940-L976","documentation":"setVisibilityAfterHide(int) only accepts View.VISIBLE, View.INVISIBLE, or View.GONE; any other int (including 0-adjacent typos or custom constants) throws IllegalArgumentException. The value determines the indicator's view visibility after the hide animation completes, and arbitrary values have no meaning to View.","triggerScenarios":"Calling setVisibilityAfterHide(someInt) where someInt is not one of the three View visibility constants; e.g. passing View.SCREEN_STATE_OFF, a resource id, or a raw number.","commonSituations":"Data-binding expressions feeding an arbitrary int; refactoring that passes visibility from another source (WindowManager flags) unchecked.","solutions":["Pass only View.VISIBLE, View.INVISIBLE, or View.GONE","Validate/sanitize external int input against the three constants before calling","Prefer relying on the default behavior (GONE) when hide-visibility customization is not needed"],"exampleFix":"// before\nindicator.setVisibilityAfterHide(if (hidden) 1 else 2)\n// after\nindicator.setVisibilityAfterHide(if (hidden) View.GONE else View.VISIBLE)","handlingStrategy":"validation","validationCode":"fun isValidVisibility(v: Int): Boolean =\n    v == View.VISIBLE || v == View.INVISIBLE || v == View.GONE","typeGuard":null,"tryCatchPattern":"catch (e: IllegalArgumentException) { Log.e(TAG, \"Invalid visibility constant; defaulting to GONE\", e); indicator.setVisibilityAfterHide(View.GONE) }","preventionTips":["Always pass View constants, never raw ints","Sanitize data-bound visibility values before the call","Rely on the default (GONE) when customization is unnecessary"],"tags":["android","material-components","progressindicator","visibility","validation"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}