Stay organized with collections
Save and categorize content based on your preferences.
OnPartialImageListener
interface OnPartialImageListener
Interface for inspecting a DecodeException
and potentially preventing it from being thrown.
If an instance is passed to setOnPartialImageListener
, a DecodeException
that would otherwise have been thrown can be inspected inside onPartialImage
. If onPartialImage
returns true
, a partial image will be created.
Summary
Public methods |
abstract Boolean |
Called by ImageDecoder when there is only a partial image to display.
|
Public methods
onPartialImage
abstract fun onPartialImage(exception: ImageDecoder.DecodeException): Boolean
Called by ImageDecoder
when there is only a partial image to display.
If decoding is interrupted after having decoded a partial image, this method will be called. The implementation can inspect the DecodeException
and optionally finish the rest of the decode creation process to create a partial Drawable
or Bitmap
.
Parameters |
exception |
ImageDecoder.DecodeException: exception containing information about the decode interruption. This value cannot be null . |
Return |
Boolean |
true to create and return a Drawable or Bitmap with partial data. false (which is the default) to abort the decode and throw e . Any undecoded lines in the image will be blank. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ImageDecoder.OnPartialImageListener\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnPartialImageListener\n======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/graphics/ImageDecoder.OnPartialImageListener \"View this page in Java\") \n\n```\ninterface OnPartialImageListener\n```\n\n|-----------------------------------------------------------|\n| [android.graphics.ImageDecoder.OnPartialImageListener](#) |\n\nInterface for inspecting a [DecodeException](/reference/kotlin/android/graphics/ImageDecoder.DecodeException) and potentially preventing it from being thrown.\n\nIf an instance is passed to [setOnPartialImageListener](/reference/kotlin/android/graphics/ImageDecoder#setOnPartialImageListener(android.graphics.ImageDecoder.OnPartialImageListener)), a [DecodeException](/reference/kotlin/android/graphics/ImageDecoder.DecodeException) that would otherwise have been thrown can be inspected inside [onPartialImage](#onPartialImage(android.graphics.ImageDecoder.DecodeException)). If [onPartialImage](#onPartialImage(android.graphics.ImageDecoder.DecodeException)) returns `true`, a partial image will be created.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onPartialImage](#onPartialImage(android.graphics.ImageDecoder.DecodeException))`(`exception:` `[ImageDecoder.DecodeException](/reference/kotlin/android/graphics/ImageDecoder.DecodeException)`)` Called by [ImageDecoder](/reference/kotlin/android/graphics/ImageDecoder) when there is only a partial image to display. |\n\nPublic methods\n--------------\n\n### onPartialImage\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onPartialImage(exception: ImageDecoder.DecodeException): Boolean\n```\n\nCalled by [ImageDecoder](/reference/kotlin/android/graphics/ImageDecoder) when there is only a partial image to display.\n\nIf decoding is interrupted after having decoded a partial image, this method will be called. The implementation can inspect the [DecodeException](/reference/kotlin/android/graphics/ImageDecoder.DecodeException) and optionally finish the rest of the decode creation process to create a partial [Drawable](/reference/kotlin/android/graphics/drawable/Drawable) or [Bitmap](/reference/kotlin/android/graphics/Bitmap).\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `exception` | [ImageDecoder.DecodeException](/reference/kotlin/android/graphics/ImageDecoder.DecodeException): exception containing information about the decode interruption. This value cannot be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` to create and return a [Drawable](/reference/kotlin/android/graphics/drawable/Drawable) or [Bitmap](/reference/kotlin/android/graphics/Bitmap) with partial data. `false` (which is the default) to abort the decode and throw `e`. Any undecoded lines in the image will be blank. |"]]