{"record":{"id":"1b13cb26455e9b6c","repo":"nostra13/Android-Universal-Image-Loader","slug":"imageaware-should-wrap-imageview-imageviewaware-i-1b13cb","errorCode":null,"errorMessage":"ImageAware should wrap ImageView. ImageViewAware is expected.","messagePattern":"ImageAware should wrap ImageView\\. ImageViewAware is expected\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/nostra13/universalimageloader/core/display/RoundedVignetteBitmapDisplayer.java","lineNumber":47,"sourceCode":" * Romain Guy's article</a>. It rounds images using custom drawable drawing. Original bitmap isn't changed.\n * <br />\n * <br />\n * If this implementation doesn't meet your needs then consider\n * <a href=\"https://github.com/vinc3m1/RoundedImageView\">this project</a> for usage.\n *\n * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)\n * @since 1.9.1\n */\npublic class RoundedVignetteBitmapDisplayer extends RoundedBitmapDisplayer {\n\n\tpublic RoundedVignetteBitmapDisplayer(int cornerRadiusPixels, int marginPixels) {\n\t\tsuper(cornerRadiusPixels, marginPixels);\n\t}\n\n\t@Override\n\tpublic void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {\n\t\tif (!(imageAware instanceof ImageViewAware)) {\n\t\t\tthrow new IllegalArgumentException(\"ImageAware should wrap ImageView. ImageViewAware is expected.\");\n\t\t}\n\n\t\timageAware.setImageDrawable(new RoundedVignetteDrawable(bitmap, cornerRadius, margin));\n\t}\n\n\tprotected static class RoundedVignetteDrawable extends RoundedDrawable {\n\n\t\tRoundedVignetteDrawable(Bitmap bitmap, int cornerRadius, int margin) {\n\t\t\tsuper(bitmap, cornerRadius, margin);\n\t\t}\n\n\t\t@Override\n\t\tprotected void onBoundsChange(Rect bounds) {\n\t\t\tsuper.onBoundsChange(bounds);\n\t\t\tRadialGradient vignette = new RadialGradient(\n\t\t\t\t\tmRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f,\n\t\t\t\t\tnew int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f},\n\t\t\t\t\tShader.TileMode.CLAMP);","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/nostra13/Android-Universal-Image-Loader/blob/ba33ec64d0daaa881d35852460e78c58d086bc18/library/src/main/java/com/nostra13/universalimageloader/core/display/RoundedVignetteBitmapDisplayer.java#L29-L65","documentation":"RoundedVignetteBitmapDisplayer extends RoundedBitmapDisplayer and repeats the same guard: display() only accepts ImageViewAware targets, throwing IllegalArgumentException otherwise. The vignette drawable it creates must be set on an ImageView via setImageDrawable, so non-ImageView awares are rejected. The failure happens at display time, after download and decode succeeded.","triggerScenarios":"Configuring options with .displayer(new RoundedVignetteBitmapDisplayer(radius, margin)) and invoking displayImage with NonViewAware or any custom ImageAware that does not extend ImageViewAware. Inheriting display options from a base class that includes the vignette displayer and reusing them for non-view loads.","commonSituations":"Central DisplayImageOptions constants shared across an app (image grid + background prefetch) where one path uses NonViewAware; refactoring from ImageView-only loading to generic ImageAware targets without stripping the displayer.","solutions":["Supply an ImageViewAware target (or the ImageView itself) when the vignette displayer is active","Split options: keep a displayer-free variant for NonViewAware/prefetch loads","Substitute a custom BitmapDisplayer without the instanceof check for non-view pipelines"],"exampleFix":"// before\nimageLoader.displayImage(uri, nonViewAware, baseOptions); // baseOptions has RoundedVignetteBitmapDisplayer\n\n// after\nDisplayImageOptions plain = baseOptions.newBuilder().displayer(null).build();\nimageLoader.displayImage(uri, nonViewAware, plain);","handlingStrategy":"type-guard","validationCode":"if (aware instanceof ImageViewAware) {\n    imageLoader.displayImage(uri, aware, vignetteOptions);\n} else {\n    imageLoader.displayImage(uri, aware, vignetteOptions.newBuilder().displayer(null).build());\n}","typeGuard":"private static boolean isVignetteSafe(ImageAware aware, DisplayImageOptions opts) {\n    return !(opts.getDisplayer() instanceof RoundedVignetteBitmapDisplayer)\n            || aware instanceof ImageViewAware;\n}","tryCatchPattern":null,"preventionTips":["Remember RoundedVignetteBitmapDisplayer inherits the ImageViewAware requirement from RoundedBitmapDisplayer","When introducing NonViewAware targets, grep option builders for '*BitmapDisplayer' entries"],"tags":["universal-image-loader","displayer","vignette","imageview"],"backgroundTag":null,"analyzedSha":"ba33ec64d0daaa881d35852460e78c58d086bc18","analyzedAt":"2026-08-14T15:41:15.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}