-
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 AndroidChoreographerProvider (#43839)
Summary: Pull Request resolved: #43839 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: cortinico Differential Revision: D55731620 fbshipit-source-id: c75eca4d324fb6761b681f28a9fe65fb2659aa3e
- Loading branch information
1 parent
bc3e336
commit 9d51bfd
Showing
2 changed files
with
33 additions
and
41 deletions.
There are no files selected for viewing
41 changes: 0 additions & 41 deletions
41
.../ReactAndroid/src/main/java/com/facebook/react/internal/AndroidChoreographerProvider.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...ve/ReactAndroid/src/main/java/com/facebook/react/internal/AndroidChoreographerProvider.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.internal | ||
|
||
import com.facebook.react.bridge.UiThreadUtil | ||
|
||
/** An implementation of ChoreographerProvider that directly uses android.view.Choreographer. */ | ||
public object AndroidChoreographerProvider : ChoreographerProvider { | ||
|
||
private class AndroidChoreographer : ChoreographerProvider.Choreographer { | ||
private val instance: android.view.Choreographer = android.view.Choreographer.getInstance() | ||
|
||
override public fun postFrameCallback(callback: android.view.Choreographer.FrameCallback) { | ||
instance.postFrameCallback(callback) | ||
} | ||
|
||
override public fun removeFrameCallback(callback: android.view.Choreographer.FrameCallback) { | ||
instance.removeFrameCallback(callback) | ||
} | ||
} | ||
|
||
@JvmStatic public fun getInstance(): AndroidChoreographerProvider = this | ||
|
||
override public fun getChoreographer(): ChoreographerProvider.Choreographer { | ||
UiThreadUtil.assertOnUiThread() | ||
return AndroidChoreographer() | ||
} | ||
} |