-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kotlinify GuardedFrameCallback (#43841)
Summary: Pull Request resolved: #43841 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: cortinico Differential Revision: D55732555 fbshipit-source-id: baab9a33be7d963dfe0fe765211de3d5abaebaca
- Loading branch information
1 parent
13cdd48
commit c1081cc
Showing
3 changed files
with
34 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
...-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/GuardedFrameCallback.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...ct-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/GuardedFrameCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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.uimanager | ||
|
||
import android.view.Choreographer | ||
import com.facebook.react.bridge.ReactContext | ||
|
||
/** | ||
* Abstract base for a Choreographer FrameCallback that should have any RuntimeExceptions it throws | ||
* handled by the [JSExceptionHandler] registered if the app is in dev mode. | ||
*/ | ||
public abstract class GuardedFrameCallback | ||
protected constructor(private val reactContext: ReactContext) : Choreographer.FrameCallback { | ||
|
||
override public fun doFrame(frameTimeNanos: Long) { | ||
try { | ||
doFrameGuarded(frameTimeNanos) | ||
} catch (e: RuntimeException) { | ||
reactContext.handleException(e) | ||
} | ||
} | ||
|
||
/** | ||
* Like the standard doFrame but RuntimeExceptions will be caught and passed to | ||
* [ReactContext#handleException(RuntimeException)]. | ||
*/ | ||
protected abstract fun doFrameGuarded(frameTimeNanos: Long) | ||
} |