Skip to content

Commit

Permalink
Kotlinify AndroidChoreographerProvider (#43839)
Browse files Browse the repository at this point in the history
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
fabriziocucci authored and facebook-github-bot committed Apr 4, 2024
1 parent bc3e336 commit 9d51bfd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 41 deletions.

This file was deleted.

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()
}
}

0 comments on commit 9d51bfd

Please sign in to comment.