{"record":{"id":"69b8667771418332","repo":"didi/DoKit","slug":"use-setcolor-method-of-paint-class-to-specify-line","errorCode":null,"errorMessage":"Use setColor method of Paint class to specify line color. Do not provider ColorProvider if you set PaintProvider.","messagePattern":"Use setColor method of Paint class to specify line color\\. Do not provider ColorProvider if you set PaintProvider\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/kit/toolpanel/decoration/FlexibleDividerDecoration.java","lineNumber":545,"sourceCode":"        public T visibilityProvider(VisibilityProvider provider) {\n            mVisibilityProvider = provider;\n            return (T) this;\n        }\n\n        public T showLastDivider() {\n            mShowLastDivider = true;\n            return (T) this;\n        }\n\n        public T positionInsideItem(boolean positionInsideItem) {\n            mPositionInsideItem = positionInsideItem;\n            return (T) this;\n        }\n\n        protected void checkBuilderParams() {\n            if (mPaintProvider != null) {\n                if (mColorProvider != null) {\n                    throw new IllegalArgumentException(\n                            \"Use setColor method of Paint class to specify line color. Do not provider ColorProvider if you set PaintProvider.\");\n                }\n                if (mSizeProvider != null) {\n                    throw new IllegalArgumentException(\n                            \"Use setStrokeWidth method of Paint class to specify line size. Do not provider SizeProvider if you set PaintProvider.\");\n                }\n            }\n        }\n    }\n}","sourceCodeStart":527,"sourceCodeEnd":555,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/kit/toolpanel/decoration/FlexibleDividerDecoration.java#L527-L555","documentation":"Thrown by FlexibleDividerDecoration.Builder.checkBuilderParams() when both a PaintProvider and a ColorProvider are set on the divider builder. A PaintProvider supplies the whole Paint (which already carries its color via paint.setColor), so an additional ColorProvider is ambiguous and the builder rejects the conflicting configuration at build() time.","triggerScenarios":"Calling builder.paintProvider(...) followed by builder.colorProvider(...) (or the color(int) convenience) and then build() on a RecyclerView divider used by a DoKit tool panel.","commonSituations":"Copy-pasted divider setup where a base config sets a color and a later customization adds a custom Paint; upgrading a divider setup that previously used only color to a PaintProvider without removing the old color call","solutions":["Remove the ColorProvider/color() call and set the color directly on the Paint you supply: paint.setColor(color) before builder.paintProvider(...)","Keep ColorProvider and drop PaintProvider if you only need a color","If both are needed dynamically, choose per-item inside a single PaintProvider"],"exampleFix":"// before\nbuilder.paintProvider(() -> paint)\n       .color(0xFF00FF00) // throws in checkBuilderParams()\n       .build();\n\n// after\npaint.setColor(0xFF00FF00);\nbuilder.paintProvider(() -> paint)\n       .build();","handlingStrategy":"validation","validationCode":"if (paintProvider != null) {\n    // ensure no color()/colorProvider() was set: set color on the Paint itself\n    paint.setColor(lineColor);\n}\nbuilder.paintProvider(() -> paint).build(); // no ColorProvider set","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one styling channel: either PaintProvider (color+size on the Paint) or Color/Size providers, never both","Audit reused/shared divider builders for providers set by earlier helper calls"],"tags":["android","ui","recyclerview","builder","validation"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}