Skip to content

Commit

Permalink
Expose scheduler through FabricUIManager
Browse files Browse the repository at this point in the history
Summary:
Allows to access `react::renderer::Scheduler` given `FabricUIManager` from Java side.

Changelog: [Added] Added `FabricUIManager` binding with FBJNI

Reviewed By: javache

Differential Revision: D35313399

fbshipit-source-id: 54e7adcceae40368c2735ddfc8a083f87b08dc5e
  • Loading branch information
cortinico authored and facebook-github-bot committed Apr 26, 2022
1 parent e51e19e commit 1730949
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Binding : public jni::HybridClass<Binding>,

static void registerNatives();

std::shared_ptr<Scheduler> getScheduler();

private:
void setConstraints(
jint surfaceId,
Expand Down Expand Up @@ -133,7 +135,6 @@ class Binding : public jni::HybridClass<Binding>,
std::shared_ptr<FabricMountingManager> mountingManager_;
std::shared_ptr<Scheduler> scheduler_;

std::shared_ptr<Scheduler> getScheduler();
std::shared_ptr<FabricMountingManager> verifyMountingManager(
std::string const &locationHint);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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.
*/

#include "JFabricUIManager.h"

namespace facebook::react {

Binding *JFabricUIManager::getBinding() {
static const auto bindingField =
javaClassStatic()->getField<Binding::javaobject>("mBinding");

return getFieldValue(bindingField)->cthis();
}
} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.
*/

#pragma once

#include <fbjni/fbjni.h>
#include "Binding.h"

using namespace facebook::jni;

namespace facebook::react {

class JFabricUIManager : public JavaClass<JFabricUIManager> {
public:
static constexpr auto kJavaDescriptor =
"Lcom/facebook/react/fabric/FabricUIManager;";

Binding *getBinding();
};

} // namespace facebook::react

0 comments on commit 1730949

Please sign in to comment.