Make android work

Differential Revision: D84055754
This commit is contained in:
Bartlomiej Bloniarz
2025-10-07 23:43:09 -07:00
committed by meta-codesync[bot]
parent f4e93df55e
commit ca5a0cc765
4 changed files with 48 additions and 11 deletions
@@ -975,6 +975,7 @@ AnimationMutations NativeAnimatedNodesManager::pullAnimationMutations() {
AnimationMutation{tag, nullptr, propsBuilder.get()});
containsChange = true;
}
updateViewPropsDirect_.clear();
}
if (!containsChange) {
@@ -82,6 +82,12 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
nativeAnimatedNodesManager_ =
std::make_shared<NativeAnimatedNodesManager>(animationBackend_);
nativeAnimatedDelegate_ =
std::make_shared<UIManagerNativeAnimatedDelegateBackendImpl>(
animationBackend_);
uiManager->setNativeAnimatedDelegate(nativeAnimatedDelegate_);
uiManager->unstable_setAnimationBackend(animationBackend_);
} else {
nativeAnimatedNodesManager_ =
@@ -90,6 +96,12 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
std::move(fabricCommitCallback),
std::move(startOnRenderCallback_),
std::move(stopOnRenderCallback_));
nativeAnimatedDelegate_ =
std::make_shared<UIManagerNativeAnimatedDelegateImpl>(
nativeAnimatedNodesManager_);
uiManager->setNativeAnimatedDelegate(nativeAnimatedDelegate_);
}
addEventEmitterListener(
@@ -112,12 +124,6 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
return false;
}));
nativeAnimatedDelegate_ =
std::make_shared<UIManagerNativeAnimatedDelegateImpl>(
nativeAnimatedNodesManager_);
uiManager->setNativeAnimatedDelegate(nativeAnimatedDelegate_);
// TODO: remove force casting.
auto* scheduler = (Scheduler*)uiManager->getDelegate();
animatedMountingOverrideDelegate_ =
@@ -10,6 +10,18 @@
namespace facebook::react {
UIManagerNativeAnimatedDelegateBackendImpl::
UIManagerNativeAnimatedDelegateBackendImpl(
std::weak_ptr<AnimationBackend> animationBackend)
: animationBackend_(std::move(animationBackend)) {}
void UIManagerNativeAnimatedDelegateBackendImpl::runAnimationFrame() {
if (auto animationBackendStrong = animationBackend_.lock()) {
animationBackendStrong->onAnimationFrame(
std::chrono::steady_clock::now().time_since_epoch().count() / 1000);
}
}
static inline Props::Shared cloneProps(
AnimatedProps& animatedProps,
const ShadowNode& shadowNode) {
@@ -108,13 +120,17 @@ void AnimationBackend::onAnimationFrame(double timestamp) {
void AnimationBackend::start(const Callback& callback) {
callbacks.push_back(callback);
// TODO: startOnRenderCallback_ should provide the timestamp from the platform
startOnRenderCallback_([this]() {
onAnimationFrame(
std::chrono::steady_clock::now().time_since_epoch().count() / 1000);
});
if (startOnRenderCallback_) {
startOnRenderCallback_([this]() {
onAnimationFrame(
std::chrono::steady_clock::now().time_since_epoch().count() / 1000);
});
}
}
void AnimationBackend::stop() {
stopOnRenderCallback_();
if (stopOnRenderCallback_) {
stopOnRenderCallback_();
}
callbacks.clear();
}
@@ -18,6 +18,20 @@
namespace facebook::react {
class AnimationBackend;
class UIManagerNativeAnimatedDelegateBackendImpl
: public UIManagerNativeAnimatedDelegate {
public:
explicit UIManagerNativeAnimatedDelegateBackendImpl(
std::weak_ptr<AnimationBackend> animationBackend);
void runAnimationFrame() override;
private:
std::weak_ptr<AnimationBackend> animationBackend_;
};
struct AnimationMutation {
Tag tag;
const ShadowNodeFamily* family;