forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate SystemClock and JavaScriptException to Kotlin (facebook#43732)
Summary: Pull Request resolved: facebook#43732 ## Changelog: [Internal] - As in the title. Reviewed By: cortinico Differential Revision: D55574532 fbshipit-source-id: bffa17a4be0f881a574988c34d9446f6392c816c
- Loading branch information
1 parent
f2bdec2
commit e180072
Showing
5 changed files
with
55 additions
and
73 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
37 changes: 0 additions & 37 deletions
37
...eact-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
.../react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.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,27 @@ | ||
/* | ||
* 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.common | ||
|
||
import com.facebook.proguard.annotations.DoNotStrip | ||
|
||
/** | ||
* A JS exception that was propagated to native. In debug mode, these exceptions are normally shown | ||
* to developers in a redbox. | ||
*/ | ||
@DoNotStrip | ||
public open class JavascriptException(jsStackTrace: String) : | ||
RuntimeException(jsStackTrace), HasJavascriptExceptionMetadata { | ||
private var extraDataAsJson: String? = null | ||
|
||
override fun getExtraDataAsJson(): String? = extraDataAsJson | ||
|
||
public fun setExtraDataAsJson(extraDataAsJson: String?): JavascriptException { | ||
this.extraDataAsJson = extraDataAsJson | ||
return this | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.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,22 @@ | ||
/* | ||
* 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.common | ||
|
||
import android.os.SystemClock | ||
|
||
/** | ||
* Detour for System.currentTimeMillis and System.nanoTime calls so that they can be mocked out in | ||
* tests. | ||
*/ | ||
public object SystemClock { | ||
@JvmStatic public fun currentTimeMillis(): Long = System.currentTimeMillis() | ||
|
||
@JvmStatic public fun nanoTime(): Long = System.nanoTime() | ||
|
||
@JvmStatic public fun uptimeMillis(): Long = SystemClock.uptimeMillis() | ||
} |