{"record":{"id":"2e1c80607939d5e9","repo":"DrKLO/Telegram","slug":"invalid-orientation","errorCode":null,"errorMessage":"invalid orientation:{}","messagePattern":"invalid orientation:(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/androidx/recyclerview/widget/LinearLayoutManager.java","lineNumber":342,"sourceCode":"     * Returns the current orientation of the layout.\n     *\n     * @return Current orientation,  either {@link #HORIZONTAL} or {@link #VERTICAL}\n     * @see #setOrientation(int)\n     */\n    @RecyclerView.Orientation\n    public int getOrientation() {\n        return mOrientation;\n    }\n\n    /**\n     * Sets the orientation of the layout. {@link LinearLayoutManager}\n     * will do its best to keep scroll position.\n     *\n     * @param orientation {@link #HORIZONTAL} or {@link #VERTICAL}\n     */\n    public void setOrientation(@RecyclerView.Orientation int orientation) {\n        if (orientation != HORIZONTAL && orientation != VERTICAL) {\n            throw new IllegalArgumentException(\"invalid orientation:\" + orientation);\n        }\n\n        assertNotInLayoutOrScroll(null);\n\n        if (orientation != mOrientation || mOrientationHelper == null) {\n            mOrientationHelper =\n                    OrientationHelper.createOrientationHelper(this, orientation);\n            mAnchorInfo.mOrientationHelper = mOrientationHelper;\n            mOrientation = orientation;\n            requestLayout();\n        }\n    }\n\n    /**\n     * Calculates the view layout order. (e.g. from end to start or start to end)\n     * RTL layout support is applied automatically. So if layout is RTL and\n     * {@link #getReverseLayout()} is {@code true}, elements will be laid out starting from left.\n     */","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/androidx/recyclerview/widget/LinearLayoutManager.java#L324-L360","documentation":"LinearLayoutManager.setOrientation() only accepts HORIZONTAL (0) or VERTICAL (1). Any other int is rejected before rebuilding the OrientationHelper, because the layout pass has no defined axis for an unknown orientation.","triggerScenarios":"Calling layoutManager.setOrientation(2), setOrientation(-1), or passing a raw int constant from another source (e.g. Configuration.ORIENTATION_LANDSCAPE = 2) instead of LinearLayoutManager.VERTICAL/HORIZONTAL.","commonSituations":"Confusing Configuration.ORIENTATION_* (which are 1/2) with RecyclerView.HORIZONTAL(0)/VERTICAL(1). Passing a resource integer or an enum ordinal that does not map to 0/1. Data-binding an orientation attribute whose backing value is out of range.","solutions":["Pass LinearLayoutManager.VERTICAL or LinearLayoutManager.HORIZONTAL explicitly.","If mapping from Configuration.ORIENTATION_*, translate: Configuration.ORIENTATION_PORTRAIT -> VERTICAL is NOT automatic; choose your own mapping and only emit 0 or 1.","Validate the value before calling: assert orientation == 0 || orientation == 1."],"exampleFix":"// before (Configuration.ORIENTATION_LANDSCAPE == 2)\nlayoutManager.setOrientation(getResources().getConfiguration().orientation);\n\n// after\nint cfg = getResources().getConfiguration().orientation;\nlayoutManager.setOrientation(\n    cfg == Configuration.ORIENTATION_LANDSCAPE ? LinearLayoutManager.HORIZONTAL : LinearLayoutManager.VERTICAL);","handlingStrategy":"validation","validationCode":"static void setSafeOrientation(LinearLayoutManager lm, int orientation) {\n    if (orientation != LinearLayoutManager.HORIZONTAL\n            && orientation != LinearLayoutManager.VERTICAL) {\n        throw new IllegalArgumentException(\"orientation must be 0 or 1, got \" + orientation);\n    }\n    lm.setOrientation(orientation);\n}","typeGuard":"static boolean isValidOrientation(int o) {\n    return o == LinearLayoutManager.HORIZONTAL || o == LinearLayoutManager.VERTICAL;\n}","tryCatchPattern":"null","preventionTips":["Never feed Configuration.ORIENTATION_* directly into setOrientation; map explicitly.","Define orientation constants in one place and reference them everywhere.","Add a unit test asserting setOrientation rejects out-of-range values."],"tags":["recyclerview","layoutmanager","orientation","validation"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}