{"record":{"id":"365d04bf10fefebc","repo":"DrKLO/Telegram","slug":"view-is-not-a-child-cannot-hide","errorCode":null,"errorMessage":"view is not a child, cannot hide {}","messagePattern":"view is not a child, cannot hide (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/androidx/recyclerview/widget/ChildHelper.java","lineNumber":340,"sourceCode":"    /**\n     * Returns whether a View is visible to LayoutManager or not.\n     *\n     * @param view The child view to check. Should be a child of the Callback.\n     * @return True if the View is not visible to LayoutManager\n     */\n    public boolean isHidden(View view) {\n        return mHiddenViews.contains(view);\n    }\n\n    /**\n     * Marks a child view as hidden.\n     *\n     * @param view The view to hide.\n     */\n    void hide(View view) {\n        final int offset = mCallback.indexOfChild(view);\n        if (offset < 0) {\n            throw new IllegalArgumentException(\"view is not a child, cannot hide \" + view);\n        }\n        if (DEBUG && mBucket.get(offset)) {\n            throw new RuntimeException(\"trying to hide same view twice, how come ? \" + view);\n        }\n        mBucket.set(offset);\n        hideViewInternal(view);\n        if (DEBUG) {\n            Log.d(TAG, \"hiding child \" + view + \" at offset \" + offset + \", \" + this);\n        }\n    }\n\n    /**\n     * Moves a child view from hidden list to regular list.\n     * Calling this method should probably be followed by a detach, otherwise, it will suddenly\n     * show up in LayoutManager's children list.\n     *\n     * @param view The hidden View to unhide\n     */","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChildHelper.java#L322-L358","documentation":"ChildHelper manages two logical groups of child views attached to RecyclerView: visible children and hidden (cached-but-kept) children. hide() moves a view into the hidden bucket and requires that the view is currently a tracked child — verified by mCallback.indexOfChild returning a non-negative offset. A negative offset means the view is not in the LayoutManager's child list, so there is no slot to mark hidden. This typically indicates the caller (usually RecyclerView internals or a custom LayoutManager) tried to hide a view that was already removed or never added.","triggerScenarios":"A custom LayoutManager calling recyclerView.getChildAdapterPosition then trying to hide a detached view; RecyclerView internals calling hide during recycle after the view was already detached; a double-detach race during predictive animations; calling removeView followed by hide on the same view.","commonSituations":"A custom LayoutManager that does not track its attached children correctly; item animation conflict where a view is removed from the layout before the recycler tries to stash it; a view leak where the same View instance is reused across RecyclerViews.","solutions":["In a custom LayoutManager, verify getChildCount/indexOfChild returns the view before any operation that may hide or recycle it.","Avoid calling internal ChildHelper methods from app code.","If you see this with stock LayoutManagers, it is usually a RecyclerView version bug or a fork modification — update the library.","Ensure views are not detached twice during animations."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// In a custom LayoutManager: only hide currently-attached children\nvoid safeHide(ChildHelper helper, View v) {\n    if (indexOfChild(v) < 0) return; // not attached, nothing to hide\n    helper.hide(v);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In custom LayoutManagers, confirm indexOfChild(view) >= 0 before recycle/hide.","Do not call ChildHelper internals from application code.","Avoid double-detach of views during item animations."],"tags":["recyclerview","childhelper","layoutmanager","view-lifecycle"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}