{"record":{"id":"e9e843a015bbe4d4","repo":"didi/DoKit","slug":"already-explicitly-declared-as-no-placeholder","errorCode":null,"errorMessage":"Already explicitly declared as no placeholder.","messagePattern":"Already explicitly declared as no placeholder\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":110,"sourceCode":"    public RequestCreator noPlaceholder() {\n        if (placeholderResId != 0) {\n            throw new IllegalStateException(\"Placeholder resource already set.\");\n        }\n        if (placeholderDrawable != null) {\n            throw new IllegalStateException(\"Placeholder image already set.\");\n        }\n        setPlaceholder = false;\n        return this;\n    }\n\n    /**\n     * A placeholder drawable to be used while the image is being loaded. If the requested image is\n     * not immediately available in the memory cache then this resource will be set on the target\n     * {@link ImageView}.\n     */\n    public RequestCreator placeholder(int placeholderResId) {\n        if (!setPlaceholder) {\n            throw new IllegalStateException(\"Already explicitly declared as no placeholder.\");\n        }\n        if (placeholderResId == 0) {\n            throw new IllegalArgumentException(\"Placeholder image resource invalid.\");\n        }\n        if (placeholderDrawable != null) {\n            throw new IllegalStateException(\"Placeholder image already set.\");\n        }\n        this.placeholderResId = placeholderResId;\n        return this;\n    }\n\n    /**\n     * A placeholder drawable to be used while the image is being loaded. If the requested image is\n     * not immediately available in the memory cache then this resource will be set on the target\n     * {@link ImageView}.\n     * <p>\n     * If you are not using a placeholder image but want to clear an existing image (such as when\n     * used in an {@link android.widget.Adapter adapter}), pass in {@code null}.","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L92-L128","documentation":"Thrown by RequestCreator.placeholder(int) when the creator was already switched to no-placeholder mode via noPlaceholder(). noPlaceholder() is an explicit opt-out of placeholder behavior, so subsequently setting a placeholder resource is rejected to catch the contradiction.","triggerScenarios":"Chaining .noPlaceholder().placeholder(R.drawable.ph) on the same RequestCreator.","commonSituations":"Shared code calling noPlaceholder() defensively, then call-site code adding a placeholder; merging two code paths during refactoring; adapting adapter-view code (where noPlaceholder is common) into a context that wants a placeholder.","solutions":["Decide placeholder behavior once per request; remove either noPlaceholder() or placeholder(...).","Parameterize your loader helper so the placeholder decision is made in a single if/else.","Do not blanket-apply noPlaceholder() in base helpers — leave the choice to call sites."],"exampleFix":"// before\nRequestCreator c = defaultCreator(url).noPlaceholder();\nc.placeholder(R.drawable.ph); // throws\n\n// after\nRequestCreator c = defaultCreator(url);\nif (usePlaceholder) c.placeholder(R.drawable.ph); else c.noPlaceholder();","handlingStrategy":"validation","validationCode":"RequestCreator c = picasso.load(url);\nif (!useNoPlaceholder) c.placeholder(R.drawable.ph);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["noPlaceholder() locks the creator: no placeholder may follow.","Keep placeholder mode as a single boolean/resId pair in your loader API."],"tags":["android","picasso","builder","state-conflict","placeholder"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}