{"record":{"id":"beec709760ed4db1","repo":"jfeinstein10/SlidingMenu","slug":"touchmode-must-be-set-to-eithertouchmode-fullscree","errorCode":null,"errorMessage":"TouchMode must be set to eitherTOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE.","messagePattern":"TouchMode must be set to eitherTOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java","lineNumber":720,"sourceCode":"\t * Gets the touch mode above.\n\t *\n\t * @return the touch mode above\n\t */\n\tpublic int getTouchModeAbove() {\n\t\treturn mViewAbove.getTouchMode();\n\t}\n\n\t/**\n\t * Controls whether the SlidingMenu can be opened with a swipe gesture.\n\t * Options are {@link #TOUCHMODE_MARGIN TOUCHMODE_MARGIN}, {@link #TOUCHMODE_FULLSCREEN TOUCHMODE_FULLSCREEN},\n\t * or {@link #TOUCHMODE_NONE TOUCHMODE_NONE}\n\t *\n\t * @param i the new touch mode\n\t */\n\tpublic void setTouchModeAbove(int i) {\n\t\tif (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN\n\t\t\t\t&& i != TOUCHMODE_NONE) {\n\t\t\tthrow new IllegalStateException(\"TouchMode must be set to either\" +\n\t\t\t\t\t\"TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE.\");\n\t\t}\n\t\tmViewAbove.setTouchMode(i);\n\t}\n\n\t/**\n\t * Controls whether the SlidingMenu can be opened with a swipe gesture.\n\t * Options are {@link #TOUCHMODE_MARGIN TOUCHMODE_MARGIN}, {@link #TOUCHMODE_FULLSCREEN TOUCHMODE_FULLSCREEN},\n\t * or {@link #TOUCHMODE_NONE TOUCHMODE_NONE}\n\t *\n\t * @param i the new touch mode\n\t */\n\tpublic void setTouchModeBehind(int i) {\n\t\tif (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN\n\t\t\t\t&& i != TOUCHMODE_NONE) {\n\t\t\tthrow new IllegalStateException(\"TouchMode must be set to either\" +\n\t\t\t\t\t\"TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE.\");\n\t\t}","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/jfeinstein10/SlidingMenu/blob/4254feca3ece9397cd501921ee733f19ea0fdad8/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java#L702-L738","documentation":"An IllegalStateException guard thrown by SlidingMenu.setTouchModeAbove(int) when the touch mode integer is not one of the three accepted constants (TOUCHMODE_FULLSCREEN, TOUCHMODE_MARGIN, TOUCHMODE_NONE). This is a generic sentinel validation: the input at fault is the raw int argument to setTouchModeAbove, usually an invalid literal, a wrong constant from another class, or unvalidated persisted settings. Only the declared TOUCHMODE_* constants are legal.","triggerScenarios":"Calling setTouchModeAbove() with an int that is not one of the three SlidingMenu touch-mode constants, e.g. a custom value or a constant from another class.","commonSituations":"Persisting the touch mode in SharedPreferences as an arbitrary int and restoring an invalid value; passing Gravity or edge constants; typo'd constant import.","solutions":["Pass only SlidingMenu.TOUCHMODE_FULLSCREEN, TOUCHMODE_MARGIN, or TOUCHMODE_NONE","Validate any persisted/restored int against the three constants before applying","Fall back to TOUCHMODE_MARGIN when the stored value is unknown"],"exampleFix":"// before\nslidingMenu.setTouchModeAbove(prefs.getInt(\"touchmode\", 99));\n// after\nint tm = prefs.getInt(\"touchmode\", SlidingMenu.TOUCHMODE_MARGIN);\nif (tm == SlidingMenu.TOUCHMODE_FULLSCREEN || tm == SlidingMenu.TOUCHMODE_MARGIN || tm == SlidingMenu.TOUCHMODE_NONE)\n    slidingMenu.setTouchModeAbove(tm);","handlingStrategy":"validation","validationCode":"static boolean isValidTouchMode(int i) { return i == SlidingMenu.TOUCHMODE_FULLSCREEN || i == SlidingMenu.TOUCHMODE_MARGIN || i == SlidingMenu.TOUCHMODE_NONE; }\nif (isValidTouchMode(tm)) slidingMenu.setTouchModeAbove(tm);","typeGuard":null,"tryCatchPattern":"try { slidingMenu.setTouchModeAbove(tm); } catch (IllegalStateException e) { slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); }","preventionTips":["Validate values restored from SharedPreferences","Use only SlidingMenu TOUCHMODE_* constants","Store the constant name (string) rather than raw int if persisting"],"tags":["android","slidingmenu","enum-argument","touch-mode"],"backgroundTag":"invalid-enum-value","analyzedSha":"4254feca3ece9397cd501921ee733f19ea0fdad8","analyzedAt":"2026-09-09T10:08:27.041Z","contentChangedAt":"2026-09-09T10:08:27.041Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}