{"record":{"id":"c02084c148ef8a1e","repo":"DrKLO/Telegram","slug":"invalid-direction-direction","errorCode":null,"errorMessage":"Invalid direction: {direction}","messagePattern":"Invalid direction: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java","lineNumber":2895,"sourceCode":"                || mTempRect.top >= mTempRect2.bottom)\n                && mTempRect.top > mTempRect2.top) {\n            downness = -1;\n        }\n        switch (direction) {\n            case View.FOCUS_LEFT:\n                return rightness < 0;\n            case View.FOCUS_RIGHT:\n                return rightness > 0;\n            case View.FOCUS_UP:\n                return downness < 0;\n            case View.FOCUS_DOWN:\n                return downness > 0;\n            case View.FOCUS_FORWARD:\n                return downness > 0 || (downness == 0 && rightness * rtl > 0);\n            case View.FOCUS_BACKWARD:\n                return downness < 0 || (downness == 0 && rightness * rtl < 0);\n        }\n        throw new IllegalArgumentException(\"Invalid direction: \" + direction + exceptionLabel());\n    }\n\n    @Override\n    public void requestChildFocus(View child, View focused) {\n        if (!mLayout.onRequestChildFocus(this, mState, child, focused) && focused != null) {\n            requestChildOnScreen(child, focused);\n        }\n        super.requestChildFocus(child, focused);\n    }\n\n    /**\n     * Requests that the given child of the RecyclerView be positioned onto the screen. This method\n     * can be called for both unfocusable and focusable child views. For unfocusable child views,\n     * the {@param focused} parameter passed is null, whereas for a focusable child, this parameter\n     * indicates the actual descendant view within this child view that holds the focus.\n     * @param child The child view of this RecyclerView that wants to come onto the screen.\n     * @param focused The descendant view that actually has the focus if child is focusable, null\n     *                otherwise.","sourceCodeStart":2877,"sourceCodeEnd":2913,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java#L2877-L2913","documentation":"RecyclerView's internal focus-search helper resolves whether a candidate is 'closer' in a given focus direction. Its switch covers FOCUS_LEFT/RIGHT/UP/DOWN/FORWARD/BACKWARD; any other direction constant throws 'Invalid direction'. The focus machinery cannot rank candidates for an axis-less direction.","triggerScenarios":"An external caller (accessibility service, custom keyboard handler, test framework) invoking focusSearch with a direction constant outside the six known View.FOCUS_* values (e.g. View.FOCUS_DOWN === 130 but a typo or a custom constant like 0).","commonSituations":"Passing 0 or an arbitrary int as direction in requestFocus/arrowScroll tests. Custom focus handling that invents a direction constant.","solutions":["Use only View.FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_BACKWARD.","Validate the direction against the set of known constants before invoking focus search.","If you only need nearest-neighbor focus, rely on the default arrow-key handling instead of custom direction injection."],"exampleFix":"// before\nrecyclerView.focusSearch(focusedView, myCustomDir); // e.g. 0\n\n// after\nint dir = View.FOCUS_FORWARD; // one of the six valid constants\nrecyclerView.focusSearch(focusedView, dir);","handlingStrategy":"validation","validationCode":"static boolean isValidFocusDirection(int dir) {\n    return dir == View.FOCUS_LEFT || dir == View.FOCUS_RIGHT\n        || dir == View.FOCUS_UP || dir == View.FOCUS_DOWN\n        || dir == View.FOCUS_FORWARD || dir == View.FOCUS_BACKWARD;\n}\nif (isValidFocusDirection(dir)) {\n    recyclerView.focusSearch(view, dir);\n}","typeGuard":"static boolean isKnownFocusDirection(int dir) {\n    switch (dir) {\n        case View.FOCUS_LEFT: case View.FOCUS_RIGHT:\n        case View.FOCUS_UP: case View.FOCUS_DOWN:\n        case View.FOCUS_FORWARD: case View.FOCUS_BACKWARD:\n            return true;\n        default: return false;\n    }\n}","tryCatchPattern":"null","preventionTips":["Use only the six View.FOCUS_* constants.","Do not pass 0 or custom constants into focusSearch.","Rely on default arrow-key handling instead of injecting custom directions."],"tags":["recyclerview","focus","accessibility","validation"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}