{"record":{"id":"ef0a5b5c68cb49d7","repo":"DrKLO/Telegram","slug":"message","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java","lineNumber":3042,"sourceCode":"    @Override\n    public boolean isAttachedToWindow() {\n        return mIsAttached;\n    }\n\n    /**\n     * Checks if RecyclerView is in the middle of a layout or scroll and throws an\n     * {@link IllegalStateException} if it <b>is not</b>.\n     *\n     * @param message The message for the exception. Can be null.\n     * @see #assertNotInLayoutOrScroll(String)\n     */\n    void assertInLayoutOrScroll(String message) {\n        if (!isComputingLayout()) {\n            if (message == null) {\n                throw new IllegalStateException(\"Cannot call this method unless RecyclerView is \"\n                        + \"computing a layout or scrolling\" + exceptionLabel());\n            }\n            throw new IllegalStateException(message + exceptionLabel());\n\n        }\n    }\n\n    /**\n     * Checks if RecyclerView is in the middle of a layout or scroll and throws an\n     * {@link IllegalStateException} if it <b>is</b>.\n     *\n     * @param message The message for the exception. Can be null.\n     * @see #assertInLayoutOrScroll(String)\n     */\n    void assertNotInLayoutOrScroll(String message) {\n        if (isComputingLayout()) {\n            if (message == null) {\n                throw new IllegalStateException(\"Cannot call this method while RecyclerView is \"\n                        + \"computing a layout or scrolling\" + exceptionLabel());\n            }\n            throw new IllegalStateException(message);","sourceCodeStart":3024,"sourceCodeEnd":3060,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java#L3024-L3060","documentation":"The same assertInLayoutOrScroll method, but called WITH a custom message. When isComputingLayout() is false, it throws IllegalStateException(message + exceptionLabel()). The custom message lets the call site identify which API was misused (e.g. 'Cannot remove item decoration during layout'). The semantics are identical to the null-message variant: the call must occur within the layout/scroll window.","triggerScenarios":"Any of dozens of RecyclerView APIs that pass a specific message to assertInLayoutOrScroll — e.g. removeItemDecoration, addItemDecoration, certain adapter mutations — invoked outside the layout/scroll pass.","commonSituations":"Removing an ItemDecoration from a button click (outside layout). Mutating adapter data from a background thread callback that lands outside the layout window. Calling requestLayout-forcing APIs during a scroll callback incorrectly.","solutions":["Read the custom message to identify the offending API, then defer it to a layout-valid moment.","Post the operation to the next frame: recyclerView.post(() -> recyclerView.removeItemDecoration(d)).","For adapter mutations, use notifyItem* on the main thread after data is set, not during scroll callbacks that mutate structure."],"exampleFix":"// before\nbutton.setOnClickListener(v -> recyclerView.removeItemDecoration(divider));\n\n// after\nbutton.setOnClickListener(v -> recyclerView.post(() -> recyclerView.removeItemDecoration(divider)));","handlingStrategy":"validation","validationCode":"Runnable remove = () -> recyclerView.removeItemDecoration(divider);\nif (recyclerView.isComputingLayout()) {\n    recyclerView.post(remove);\n} else {\n    remove.run();\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Read the custom message to identify the offending API, then defer it out of the layout pass.","Use recyclerView.post for any structural mutation triggered by user input.","Keep ItemDecoration add/remove out of scroll and layout callbacks."],"tags":["recyclerview","lifecycle","layout-pass","threading"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}