umano/AndroidSlidingUpPanel · error · java.lang.IllegalArgumentException

Panel state cannot be null or DRAGGING.

Error message

Panel state cannot be null or DRAGGING.

What it means

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.

Solutions

  1. Only pass EXPANDED, COLLAPSED, HIDDEN or ANCHORED
  2. Guard against DRAGGING/null before calling: if a saved state is DRAGGING, substitute COLLAPSED
  3. Never persist and restore DRAGGING; clamp it on restore

Example fix

// before
layout.setPanelState(savedState); // may be DRAGGING or null
// after
if (savedState != null && savedState != PanelState.DRAGGING) {
    layout.setPanelState(savedState);
} else {
    layout.setPanelState(PanelState.COLLAPSED);
}
Defensive patterns

Strategy: validation

Validate before calling

private static PanelState sanitizeState(PanelState s) {
    return (s == null || s == PanelState.DRAGGING) ? PanelState.COLLAPSED : s;
}
layout.setPanelState(sanitizeState(savedState));

Type guard

boolean isSettableState(PanelState s) { return s == PanelState.EXPANDED || s == PanelState.COLLAPSED || s == PanelState.HIDDEN || s == PanelState.ANCHORED; }

Try / catch

try { layout.setPanelState(state); } catch (IllegalArgumentException e) { layout.setPanelState(PanelState.COLLAPSED); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of umano/AndroidSlidingUpPanel@45a460435b (2026-09-11). Data as JSON: /api/errors/64c68ca8df22e77b. Report an issue: GitHub.

Appendix: source

Thrown at library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java:1108

    public PanelState getPanelState() {
        return mSlideState;
    }

    /**
     * Change panel state to the given state with
     *
     * @param state - new panel state
     */
    public void setPanelState(PanelState state) {

        // Abort any running animation, to allow state change
        if(mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING){
            Log.d(TAG, "View is settling. Aborting animation.");
            mDragHelper.abort();
        }

        if (state == null || state == PanelState.DRAGGING) {
            throw new IllegalArgumentException("Panel state cannot be null or DRAGGING.");
        }
        if (!isEnabled()
                || (!mFirstLayout && mSlideableView == null)
                || state == mSlideState
                || mSlideState == PanelState.DRAGGING) return;

        if (mFirstLayout) {
            setPanelStateInternal(state);
        } else {
            if (mSlideState == PanelState.HIDDEN) {
                mSlideableView.setVisibility(View.VISIBLE);
                requestLayout();
            }
            switch (state) {
                case ANCHORED:
                    smoothSlideTo(mAnchorPoint, 0);
                    break;
                case COLLAPSED:

View on GitHub (pinned to 45a460435b)