From 40521e6e5d3f0576ae45c718551e92ea875111a0 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005287564 Date: Tue, 28 Jan 2025 05:12:29 -0800 Subject: [PATCH] //fbandroid/libraries/fresco/static-webp/src/main/java/com/facebook/imagepipeline/nativecode:nativecode Reviewed By: defHLT Differential Revision: D68764290 fbshipit-source-id: c23897648ad7f9823349066a3e488a8d550aeff6 --- ...eLoader.java => StaticWebpNativeLoader.kt} | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) rename static-webp/src/main/java/com/facebook/imagepipeline/nativecode/{StaticWebpNativeLoader.java => StaticWebpNativeLoader.kt} (53%) diff --git a/static-webp/src/main/java/com/facebook/imagepipeline/nativecode/StaticWebpNativeLoader.java b/static-webp/src/main/java/com/facebook/imagepipeline/nativecode/StaticWebpNativeLoader.kt similarity index 53% rename from static-webp/src/main/java/com/facebook/imagepipeline/nativecode/StaticWebpNativeLoader.java rename to static-webp/src/main/java/com/facebook/imagepipeline/nativecode/StaticWebpNativeLoader.kt index 316a8f1285..febf22ce98 100644 --- a/static-webp/src/main/java/com/facebook/imagepipeline/nativecode/StaticWebpNativeLoader.java +++ b/static-webp/src/main/java/com/facebook/imagepipeline/nativecode/StaticWebpNativeLoader.kt @@ -5,32 +5,32 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.imagepipeline.nativecode; +package com.facebook.imagepipeline.nativecode -import android.os.Build; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.soloader.nativeloader.NativeLoader; +import android.os.Build +import com.facebook.soloader.nativeloader.NativeLoader /** Single place responsible for ensuring that `static-webp.so` is loaded */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public class StaticWebpNativeLoader { +object StaticWebpNativeLoader { - private static boolean sInitialized; + private var initialized = false - public static synchronized void ensure() { - if (!sInitialized) { + @JvmStatic + @Synchronized + fun ensure() { + if (!initialized) { // On Android 4.1.2 the loading of the static-webp native library can fail because // of the dependency with fb_jpegturbo. In this case we have to explicitely load that // library if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) { try { - NativeLoader.loadLibrary("fb_jpegturbo"); - } catch (UnsatisfiedLinkError error) { + NativeLoader.loadLibrary("fb_jpegturbo") + } catch (error: UnsatisfiedLinkError) { // Head in the sand } } - NativeLoader.loadLibrary("static-webp"); - sInitialized = true; + NativeLoader.loadLibrary("static-webp") + initialized = true } } }