{"record":{"id":"efcec352f7e1af41","repo":"YoKeyword/Fragmentation","slug":"threshold-value-should-be-between-0-and-1-0","errorCode":null,"errorMessage":"Threshold value should be between 0 and 1.0","messagePattern":"Threshold value should be between 0 and 1\\.0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation/SwipeBackLayout.java","lineNumber":163,"sourceCode":"\n    /**\n     * 滑动中，上一个页面View的阴影透明度\n     *\n     * @param alpha 0.0f:无阴影, 1.0f:较重的阴影, 默认:0.5f\n     */\n    public void setSwipeAlpha(@FloatRange(from = 0.0f, to = 1.0f) float alpha) {\n        this.mSwipeAlpha = alpha;\n    }\n\n    /**\n     * Set scroll threshold, we will close the activity, when scrollPercent over\n     * this value\n     *\n     * @param threshold\n     */\n    public void setScrollThresHold(@FloatRange(from = 0.0f, to = 1.0f) float threshold) {\n        if (threshold >= 1.0f || threshold <= 0) {\n            throw new IllegalArgumentException(\"Threshold value should be between 0 and 1.0\");\n        }\n        mScrollFinishThreshold = threshold;\n    }\n\n    public void setParallaxOffset(float offset) {\n        this.mParallaxOffset = offset;\n    }\n\n    /**\n     * Enable edge tracking for the selected edges of the parent view.\n     * The callback's {@link ViewDragHelper.Callback#onEdgeTouched(int, int)} and\n     * {@link ViewDragHelper.Callback#onEdgeDragStarted(int, int)} methods will only be invoked\n     * for edges for which edge tracking has been enabled.\n     *\n     * @param orientation Combination of edge flags describing the edges to watch\n     * @see #EDGE_LEFT\n     * @see #EDGE_RIGHT\n     */","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/YoKeyword/Fragmentation/blob/0394930a3e2368f210df31f2632fb89b9c44e121/fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation/SwipeBackLayout.java#L145-L181","documentation":"setScrollThresHold sets the fraction of the swipe distance required to trigger a swipe-back finish. It is annotated @FloatRange(0.0, 1.0) and explicitly rejects values >= 1.0f or <= 0 with an IllegalArgumentException, since the threshold must be an exclusive fraction.","triggerScenarios":"Calling swipeBackLayout.setScrollThresHold(0), setScrollThresHold(1), or any negative value / value above 1.","commonSituations":"Passing a percentage as whole numbers (e.g. 50 instead of 0.5); mistakenly using 1.0 meaning 'always finish' when 1.0 is invalid; porting config values from dp/px-based libraries.","solutions":["Pass an exclusive fraction between 0 and 1.0, e.g. 0.5f.","Convert integer percentages: threshold = percent / 100f, clamped to (0, 1)."],"exampleFix":"// before\nswipeBackLayout.setScrollThresHold(50);\n// after\nswipeBackLayout.setScrollThresHold(0.5f);","handlingStrategy":"validation","validationCode":"float t = 0.5f;\nif (t > 0f && t < 1.0f) swipeBackLayout.setScrollThresHold(t);","typeGuard":null,"tryCatchPattern":"try {\n    swipeBackLayout.setScrollThresHold(threshold);\n} catch (IllegalArgumentException e) {\n    // fall back to default threshold\n}","preventionTips":["Use floats strictly between 0 and 1.0 (e.g. 0.5f).","Convert percentages with percent / 100f.","Remember 0 and 1.0 are both invalid (exclusive bounds)."],"tags":["android","swipeback","argument-range"],"backgroundTag":"value-out-of-range","analyzedSha":"0394930a3e2368f210df31f2632fb89b9c44e121","analyzedAt":"2026-09-10T13:16:30.469Z","contentChangedAt":"2026-09-10T13:16:30.469Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}