* Base implementation for an efficient ImageView. * Need to be subclassed to provide an ImageLoader instance. */
| 23 | * Need to be subclassed to provide an ImageLoader instance. |
| 24 | */ |
| 25 | open class ValdiImageView(context: Context): View(context), ValdiForegroundHolder, |
| 26 | ValdiImageDrawable.Listener, |
| 27 | ValdiRecyclableView, |
| 28 | ValdiClippableView, |
| 29 | ValdiAssetReceiver { |
| 30 | |
| 31 | /** |
| 32 | * Dependencies |
| 33 | */ |
| 34 | private val coordinateResolver = CoordinateResolver(context) |
| 35 | |
| 36 | private val runtime: ValdiRuntime? |
| 37 | get() { |
| 38 | return ViewUtils.findValdiContext(this)?.runtimeOrNull |
| 39 | } |
| 40 | |
| 41 | private val logger: Logger? |
| 42 | get() { |
| 43 | return runtime?.logger |
| 44 | } |
| 45 | |
| 46 | val imageDrawable = ValdiImageDrawable(context, this).also { |
| 47 | it.callback = this |
| 48 | } |
| 49 | |
| 50 | var onImageDecoded: ValdiFunction? = null |
| 51 | |
| 52 | /** |
| 53 | * Proxy properties for setting up the image drawable |
| 54 | */ |
| 55 | override val clipper: CanvasClipper |
| 56 | get() { |
| 57 | return imageDrawable.clipper |
| 58 | } |
| 59 | |
| 60 | override var clipToBounds: Boolean |
| 61 | get() { |
| 62 | return imageDrawable.clipToBounds |
| 63 | } |
| 64 | set(value) { |
| 65 | imageDrawable.clipToBounds = value |
| 66 | } |
| 67 | |
| 68 | var imagePadding: Int |
| 69 | get() { |
| 70 | return imageDrawable.imagePadding |
| 71 | } |
| 72 | set(value) { |
| 73 | imageDrawable.imagePadding = value |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Valdi view overrides |
| 78 | */ |
| 79 | override val clipToBoundsDefaultValue = true |
| 80 | |
| 81 | private var valdiForegroundField: Drawable? = null |
| 82 | override var valdiForeground: Drawable? |
nothing calls this directly
no test coverage detected