{"record":{"id":"fcb641be2743725a","repo":"didi/DoKit","slug":"onlyscaledown-can-not-be-applied-without-resize","errorCode":null,"errorMessage":"onlyScaleDown can not be applied without resize","messagePattern":"onlyScaleDown can not be applied without resize","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Request.java","lineNumber":366,"sourceCode":"        throw new IllegalStateException(\"Center inside can not be used after calling centerCrop\");\n      }\n      centerInside = true;\n      return this;\n    }\n\n    /** Clear the center inside transformation flag, if set. */\n    public Builder clearCenterInside() {\n      centerInside = false;\n      return this;\n    }\n\n    /**\n     * Only resize an image if the original image size is bigger than the target size\n     * specified by {@link #resize(int, int)}.\n     */\n    public Builder onlyScaleDown() {\n      if (targetHeight == 0 && targetWidth == 0) {\n        throw new IllegalStateException(\"onlyScaleDown can not be applied without resize\");\n      }\n      onlyScaleDown = true;\n      return this;\n    }\n\n    /** Clear the onlyScaleUp flag, if set. **/\n    public Builder clearOnlyScaleDown() {\n      onlyScaleDown = false;\n      return this;\n    }\n\n    /** Rotate the image by the specified degrees. */\n    public Builder rotate(float degrees) {\n      rotationDegrees = degrees;\n      return this;\n    }\n\n    /** Rotate the image by the specified degrees around a pivot point. */","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Request.java#L348-L384","documentation":"Thrown by Request.Builder.onlyScaleDown() when neither targetWidth nor targetHeight has been set via resize(). onlyScaleDown modifies an existing resize target (skip scaling up beyond the original size); without a target there is nothing to compare against, so it is rejected.","triggerScenarios":"Calling .onlyScaleDown() before any .resize(w, h) on the same builder, or after clearResize().","commonSituations":"Copying a chain like load(url).onlyScaleDown().resize(...) in the wrong order; calling clearResize() in shared code and then onlyScaleDown(); forgetting resize when switching from fit() to explicit sizing.","solutions":["Call resize(w, h) (at least one positive dimension) before onlyScaleDown().","If you want 'fit the view but never upscale', use .fit().centerInside() or resize to view dims then onlyScaleDown().","Audit builder pipelines that call clearResize() — onlyScaleDown becomes invalid after it."],"exampleFix":"// before\npicasso.load(url).onlyScaleDown().into(imageView); // no resize\n\n// after\npicasso.load(url).resize(imageView.getWidth(), 0).onlyScaleDown().into(imageView);","handlingStrategy":"validation","validationCode":"if (targetWidth > 0 || targetHeight > 0) {\n  builder.resize(targetWidth, targetHeight).onlyScaleDown();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Order matters: resize() must precede onlyScaleDown().","onlyScaleDown() becomes invalid again after clearResize()."],"tags":["android","picasso","image-loading","builder","ordering"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}