{"record":{"id":"3dd736f6ad324862","repo":"didi/DoKit","slug":"use-setstrokewidth-method-of-paint-class-to-specif","errorCode":null,"errorMessage":"Use setStrokeWidth method of Paint class to specify line size. Do not provider SizeProvider if you set PaintProvider.","messagePattern":"Use setStrokeWidth method of Paint class to specify line size\\. Do not provider SizeProvider 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":549,"sourceCode":"\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":531,"sourceCodeEnd":555,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/kit/toolpanel/decoration/FlexibleDividerDecoration.java#L531-L555","documentation":"Thrown by FlexibleDividerDecoration.Builder.checkBuilderParams() when both a PaintProvider and a SizeProvider are set. SizeProvider controls divider thickness, but a supplied Paint already defines thickness via paint.setStrokeWidth, so configuring both is contradictory and rejected at build() time.","triggerScenarios":"Calling builder.paintProvider(...) and builder.size(...) (or sizeProvider(...)) on the same divider builder, then build(); commonly hit when a shared divider builder is reused and a size was set earlier in the chain.","commonSituations":"Incremental migration from simple color/size configuration to a full PaintProvider without cleaning up prior size() calls; builders assembled from helper methods that each add their own provider","solutions":["Remove the SizeProvider/size() call and set thickness on the Paint: paint.setStrokeWidth(dp) before supplying the PaintProvider","Keep SizeProvider and drop PaintProvider if you only need a custom size","Set stroke width per-item inside the PaintProvider when sizes vary by position"],"exampleFix":"// before\nbuilder.paintProvider(() -> paint)\n       .size(4) // throws in checkBuilderParams()\n       .build();\n\n// after\npaint.setStrokeWidth(4);\nbuilder.paintProvider(() -> paint)\n       .build();","handlingStrategy":"validation","validationCode":"if (paintProvider != null) {\n    // ensure no size()/sizeProvider() was set: set stroke width on the Paint itself\n    paint.setStrokeWidth(dpToPx);\n}\nbuilder.paintProvider(() -> paint).build(); // no SizeProvider set","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set divider thickness via paint.setStrokeWidth when using a PaintProvider","When migrating a builder from size() to paintProvider(), remove the old size() call in the same change"],"tags":["android","ui","recyclerview","builder","validation"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}