From d9296441ea6e9940e3dcd23b31219b56ee5256aa Mon Sep 17 00:00:00 2001 From: Yacine Rezgui Date: Wed, 4 Sep 2024 16:19:30 +0200 Subject: [PATCH] Fix failing Ultra HDR sample on emulator --- .../graphics/ultrahdr/opengl/UltraHDRWithOpenGL.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/graphics/ultrahdr/src/main/java/com/example/platform/graphics/ultrahdr/opengl/UltraHDRWithOpenGL.kt b/samples/graphics/ultrahdr/src/main/java/com/example/platform/graphics/ultrahdr/opengl/UltraHDRWithOpenGL.kt index 212bf6fb..becc8c74 100644 --- a/samples/graphics/ultrahdr/src/main/java/com/example/platform/graphics/ultrahdr/opengl/UltraHDRWithOpenGL.kt +++ b/samples/graphics/ultrahdr/src/main/java/com/example/platform/graphics/ultrahdr/opengl/UltraHDRWithOpenGL.kt @@ -182,8 +182,11 @@ class UltraHDRWithOpenGL : Fragment(), } override fun onAttach(context: Context) { - requireActivity().display - ?.registerHdrSdrRatioChangedListener(Runnable::run, updateHdrSdrRatio) + requireActivity().display?.let { display -> + if (display.isHdrSdrRatioAvailable) { + display.registerHdrSdrRatioChangedListener(Runnable::run, updateHdrSdrRatio) + } + } super.onAttach(context) }