{"record":{"id":"9a760fdf1d90383f","repo":"YoKeyword/Fragmentation","slug":"must-extends-fragment-and-implements-isupportfragm","errorCode":null,"errorMessage":"Must extends Fragment and implements ISupportFragment!","messagePattern":"Must extends Fragment and implements ISupportFragment!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation_swipeback/core/SwipeBackFragmentDelegate.java","lineNumber":25,"sourceCode":"import androidx.fragment.app.Fragment;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport me.yokeyword.fragmentation.ISupportFragment;\nimport me.yokeyword.fragmentation.SwipeBackLayout;\n\n/**\n * Created by YoKey on 17/6/29.\n */\n\npublic class SwipeBackFragmentDelegate {\n    private Fragment mFragment;\n    private ISupportFragment mSupport;\n    private SwipeBackLayout mSwipeBackLayout;\n\n    public SwipeBackFragmentDelegate(ISwipeBackFragment swipeBackFragment) {\n        if (!(swipeBackFragment instanceof Fragment) || !(swipeBackFragment instanceof ISupportFragment))\n            throw new RuntimeException(\"Must extends Fragment and implements ISupportFragment!\");\n        mFragment = (Fragment) swipeBackFragment;\n        mSupport = (ISupportFragment) swipeBackFragment;\n    }\n\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        onFragmentCreate();\n    }\n\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        if (view instanceof SwipeBackLayout) {\n            View childView = ((SwipeBackLayout) view).getChildAt(0);\n            mSupport.getSupportDelegate().setBackground(childView);\n        } else {\n            mSupport.getSupportDelegate().setBackground(view);\n        }\n    }\n\n    public View attachToSwipeBack(View view) {","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/YoKeyword/Fragmentation/blob/0394930a3e2368f210df31f2632fb89b9c44e121/fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation_swipeback/core/SwipeBackFragmentDelegate.java#L7-L43","documentation":"A generic constructor guard in SwipeBackFragmentDelegate: the object passed to new SwipeBackFragmentDelegate(...) is checked with instanceof against both androidx.fragment.app.Fragment and me.yokeyword.fragmentation.ISupportFragment, and this unchecked RuntimeException fires when either check fails. It exists so the later unchecked casts of the ISwipeBackFragment argument to Fragment (mFragment) and ISupportFragment (mSupport) would not throw a ClassCastException at an arbitrary later point. The input at fault is the class using the swipe-back delegate: it declared itself ISwipeBackFragment but did not also subclass the AndroidX Fragment and/or implement the fragmentation support interface, so the delegate has no valid fragment lifecycle host to attach to.","triggerScenarios":"Thrown at fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation_swipeback/core/SwipeBackFragmentDelegate.java:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the class that constructs SwipeBackFragmentDelegate extend androidx.fragment.app.Fragment (or its subclass, e.g. SupportFragment from the fragmentation library) and implement both ISupportFragment and ISwipeBackFragment","If the class already extends a base fragment, verify it is the AndroidX one (androidx.fragment.app.Fragment) and not the deprecated android.support.v4.app.Fragment from an older fragmentation release — migrate to the AndroidX-compatible version of the library","Ensure the ISwipeBackFragment interface is implemented on the same concrete Fragment subclass that is actually instantiated, not on a wrapper, delegate, or non-fragment helper object"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}