{"record":{"id":"a31005f806bfa88a","repo":"umano/AndroidSlidingUpPanel","slug":"cannot-settlecapturedviewat-outside-of-a-call-to-c","errorCode":null,"errorMessage":"Cannot settleCapturedViewAt outside of a call to Callback#onViewReleased","messagePattern":"Cannot settleCapturedViewAt outside of a call to Callback#onViewReleased","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java","lineNumber":589,"sourceCode":"        mActivePointerId = INVALID_POINTER;\n\n        return forceSettleCapturedViewAt(finalLeft, finalTop, 0, 0);\n    }\n\n    /**\n     * Settle the captured view at the given (left, top) position.\n     * The appropriate velocity from prior motion will be taken into account.\n     * If this method returns true, the caller should invoke {@link #continueSettling(boolean)}\n     * on each subsequent frame to continue the motion until it returns false. If this method\n     * returns false there is no further work to do to complete the movement.\n     *\n     * @param finalLeft Settled left edge position for the captured view\n     * @param finalTop Settled top edge position for the captured view\n     * @return true if animation should continue through {@link #continueSettling(boolean)} calls\n     */\n    public boolean settleCapturedViewAt(int finalLeft, int finalTop) {\n        if (!mReleaseInProgress) {\n            throw new IllegalStateException(\"Cannot settleCapturedViewAt outside of a call to \" +\n                    \"Callback#onViewReleased\");\n        }\n\n        return forceSettleCapturedViewAt(finalLeft, finalTop,\n                (int) VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),\n                (int) VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId));\n    }\n\n    /**\n     * Settle the captured view at the given (left, top) position.\n     *\n     * @param finalLeft Target left position for the captured view\n     * @param finalTop Target top position for the captured view\n     * @param xvel Horizontal velocity\n     * @param yvel Vertical velocity\n     * @return true if animation should continue through {@link #continueSettling(boolean)} calls\n     */\n    private boolean forceSettleCapturedViewAt(int finalLeft, int finalTop, int xvel, int yvel) {","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/umano/AndroidSlidingUpPanel/blob/45a460435b07e764138a700328836cafc1ed5c42/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java#L571-L607","documentation":"settleCapturedViewAt() may only be invoked from inside Callback.onViewReleased(), while mReleaseInProgress is true. Calling it elsewhere throws IllegalStateException because settle logic depends on release-time velocity tracking state.","triggerScenarios":"Calling settleCapturedViewAt from onViewCaptured, onViewPositionChanged, computeScroll, or any app code outside onViewReleased.","commonSituations":"Developers trying to programmatically animate the captured view after drag ends, or reusing AOSP ViewDragHelper sample code in the wrong callback.","solutions":["Move the call into Callback.onViewReleased","For programmatic settling outside a drag, use smoothSlideViewTo + continueSettling instead","Use forceSettleCapturedViewAt only if you understand it bypasses the guard"],"exampleFix":"// before\npublic void onViewPositionChanged(View child, int l, int t, int dx, int dy) {\n    mDragHelper.settleCapturedViewAt(l, t);\n}\n// after\n@Override\npublic void onViewReleased(View releasedChild, float xvel, float yvel) {\n    mDragHelper.settleCapturedViewAt(finalLeft, finalTop);\n}","handlingStrategy":"validation","validationCode":"if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_DRAGGING && !inOnViewReleased) {\n    // settle via smoothSlideViewTo instead\n    mDragHelper.smoothSlideViewTo(captured, finalLeft, finalTop);\n    ViewCompat.postInvalidateOnAnimation(container);\n}","typeGuard":null,"tryCatchPattern":"try { mDragHelper.settleCapturedViewAt(l, t); } catch (IllegalStateException e) { mDragHelper.smoothSlideViewTo(view, l, t); }","preventionTips":["Only call settleCapturedViewAt inside onViewReleased","Use smoothSlideViewTo + continueSettling for programmatic settling","Never call drag-helper settle APIs from UI events"],"tags":["android","viewdraghelper","invalid-state","callback-lifecycle"],"backgroundTag":"invalid-state-transition","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"}