diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 48d0cfa5267..4e609943101 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2899,7 +2899,7 @@ public abstract interface class com/facebook/react/jstasks/HeadlessJsTaskRetryPo public abstract fun update ()Lcom/facebook/react/jstasks/HeadlessJsTaskRetryPolicy; } -public class com/facebook/react/jstasks/LinearCountingRetryPolicy : com/facebook/react/jstasks/HeadlessJsTaskRetryPolicy { +public final class com/facebook/react/jstasks/LinearCountingRetryPolicy : com/facebook/react/jstasks/HeadlessJsTaskRetryPolicy { public fun (II)V public fun canRetry ()Z public fun copy ()Lcom/facebook/react/jstasks/HeadlessJsTaskRetryPolicy; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/LinearCountingRetryPolicy.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/LinearCountingRetryPolicy.java deleted file mode 100644 index a008a5aa0f8..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/LinearCountingRetryPolicy.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.jstasks; - -import com.facebook.infer.annotation.Nullsafe; - -@Nullsafe(Nullsafe.Mode.LOCAL) -public class LinearCountingRetryPolicy implements HeadlessJsTaskRetryPolicy { - - private final int mRetryAttempts; - private final int mDelayBetweenAttemptsInMs; - - public LinearCountingRetryPolicy(int retryAttempts, int delayBetweenAttemptsInMs) { - mRetryAttempts = retryAttempts; - mDelayBetweenAttemptsInMs = delayBetweenAttemptsInMs; - } - - @Override - public boolean canRetry() { - return mRetryAttempts > 0; - } - - @Override - public int getDelay() { - return mDelayBetweenAttemptsInMs; - } - - @Override - public HeadlessJsTaskRetryPolicy update() { - final int remainingRetryAttempts = mRetryAttempts - 1; - - if (remainingRetryAttempts > 0) { - return new LinearCountingRetryPolicy(remainingRetryAttempts, mDelayBetweenAttemptsInMs); - } else { - return NoRetryPolicy.INSTANCE; - } - } - - @Override - public HeadlessJsTaskRetryPolicy copy() { - return new LinearCountingRetryPolicy(mRetryAttempts, mDelayBetweenAttemptsInMs); - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/LinearCountingRetryPolicy.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/LinearCountingRetryPolicy.kt new file mode 100644 index 00000000000..1ba4ff038f7 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/LinearCountingRetryPolicy.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.jstasks + +public class LinearCountingRetryPolicy( + private val retryAttempts: Int, + private val delayBetweenAttemptsInMs: Int +) : HeadlessJsTaskRetryPolicy { + + override public fun canRetry(): Boolean = retryAttempts > 0 + + override public fun getDelay(): Int = delayBetweenAttemptsInMs + + override public fun update(): HeadlessJsTaskRetryPolicy { + val remainingRetryAttempts = retryAttempts - 1 + + return if (remainingRetryAttempts > 0) { + LinearCountingRetryPolicy(remainingRetryAttempts, delayBetweenAttemptsInMs) + } else { + NoRetryPolicy.INSTANCE + } + } + + override public fun copy(): HeadlessJsTaskRetryPolicy = + LinearCountingRetryPolicy(retryAttempts, delayBetweenAttemptsInMs) +}