{"record":{"id":"64c68ca8df22e77b","repo":"umano/AndroidSlidingUpPanel","slug":"panel-state-cannot-be-null-or-dragging","errorCode":null,"errorMessage":"Panel state cannot be null or DRAGGING.","messagePattern":"Panel state cannot be null or DRAGGING\\.","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java","lineNumber":1108,"sourceCode":"    public PanelState getPanelState() {\n        return mSlideState;\n    }\n\n    /**\n     * Change panel state to the given state with\n     *\n     * @param state - new panel state\n     */\n    public void setPanelState(PanelState state) {\n\n        // Abort any running animation, to allow state change\n        if(mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING){\n            Log.d(TAG, \"View is settling. Aborting animation.\");\n            mDragHelper.abort();\n        }\n\n        if (state == null || state == PanelState.DRAGGING) {\n            throw new IllegalArgumentException(\"Panel state cannot be null or DRAGGING.\");\n        }\n        if (!isEnabled()\n                || (!mFirstLayout && mSlideableView == null)\n                || state == mSlideState\n                || mSlideState == PanelState.DRAGGING) return;\n\n        if (mFirstLayout) {\n            setPanelStateInternal(state);\n        } else {\n            if (mSlideState == PanelState.HIDDEN) {\n                mSlideableView.setVisibility(View.VISIBLE);\n                requestLayout();\n            }\n            switch (state) {\n                case ANCHORED:\n                    smoothSlideTo(mAnchorPoint, 0);\n                    break;\n                case COLLAPSED:","sourceCodeStart":1090,"sourceCodeEnd":1126,"githubUrl":"https://github.com/umano/AndroidSlidingUpPanel/blob/45a460435b07e764138a700328836cafc1ed5c42/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java#L1090-L1126","documentation":"setPanelState() validates the requested PanelState and throws IllegalArgumentException if it is null or PanelState.DRAGGING. DRAGGING is an internal transient state driven by touch input, not a state callers may set programmatically.","triggerScenarios":"Calling setPanelState(null), calling it with PanelState.DRAGGING, or passing a state read back from a persisted bundle/savedInstanceState that was serialized as DRAGGING (or null) during a drag.","commonSituations":"Restoring panel state from onSaveInstanceState where the state was DRAGGING at save time; mapping an enum from another system onto PanelState with a null/unknown default.","solutions":["Only pass EXPANDED, COLLAPSED, HIDDEN or ANCHORED","Guard against DRAGGING/null before calling: if a saved state is DRAGGING, substitute COLLAPSED","Never persist and restore DRAGGING; clamp it on restore"],"exampleFix":"// before\nlayout.setPanelState(savedState); // may be DRAGGING or null\n// after\nif (savedState != null && savedState != PanelState.DRAGGING) {\n    layout.setPanelState(savedState);\n} else {\n    layout.setPanelState(PanelState.COLLAPSED);\n}","handlingStrategy":"validation","validationCode":"private static PanelState sanitizeState(PanelState s) {\n    return (s == null || s == PanelState.DRAGGING) ? PanelState.COLLAPSED : s;\n}\nlayout.setPanelState(sanitizeState(savedState));","typeGuard":"boolean isSettableState(PanelState s) { return s == PanelState.EXPANDED || s == PanelState.COLLAPSED || s == PanelState.HIDDEN || s == PanelState.ANCHORED; }","tryCatchPattern":"try { layout.setPanelState(state); } catch (IllegalArgumentException e) { layout.setPanelState(PanelState.COLLAPSED); }","preventionTips":["Never persist/restore PanelState.DRAGGING","Clamp saved state to settable values","Null-check state loaded from bundles"],"tags":["android","illegal-argument","enum","panel-state"],"backgroundTag":"invalid-enum-value","analyzedSha":"45a460435b07e764138a700328836cafc1ed5c42","analyzedAt":"2026-09-11T10:02:33.403Z","contentChangedAt":"2026-09-11T10:02:33.403Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}