| 392 | |
| 393 | if (_scrollState != nullptr) { |
| 394 | _scrollState->setNeedsSyncWithView(true); |
| 395 | } |
| 396 | |
| 397 | if (hasView()) { |
| 398 | _attributesApplier.didAddView(viewTransactionScope, animator); |
| 399 | |
| 400 | callViewCallbackIfNeeded(_onViewCreatedCallback); |
| 401 | if (_flags[kLayoutDidCompleteOnceFlag]) { |
| 402 | setViewFrameNeedsUpdate(); |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | callViewChangedIfNeeded(); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | bool ViewNode::removeView(ViewTransactionScope& viewTransactionScope) { |
| 411 | return removeView(viewTransactionScope, true); |
| 412 | } |
| 413 | |
| 414 | bool ViewNode::removeView(ViewTransactionScope& viewTransactionScope, bool safeRemove) { |
| 415 | if (hasView()) { |
| 416 | if (safeRemove) { |
| 417 | // To ensure that we are not going to enqueue a view that has children, |
| 418 | // we explicitly remove all the view children from this view. |
| 419 | for (auto i = getChildCount(); i > 0; i--) { |
| 420 | getChildAt(i - 1)->removeViewFromParent(viewTransactionScope, false); |
| 421 | } |
| 422 | } |
| 423 | setView(viewTransactionScope, nullptr, nullptr); |
| 424 | return true; |
| 425 | } else { |
| 426 | return false; |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | bool ViewNode::createView(ViewTransactionScope& viewTransactionScope, const Ref<Animator>& animator) { |
| 431 | if (hasView() || isLayout() || _viewNodeTree == nullptr || _viewFactory == nullptr) { |
| 432 | return false; |
| 433 | } |
| 434 | |
| 435 | bool reusedFromPool = false; |
| 436 | auto allowReuse = !_flags[kDisallowViewReuseFlag]; |
| 437 | auto view = _viewFactory->createView(_viewNodeTree, this, /*allowPool*/ allowReuse, &reusedFromPool); |
| 438 | |
| 439 | if (view != nullptr) { |
| 440 | if (!allowReuse) { |
| 441 | // allowReuse={false}: the view is new, and it is dropped instead of pooled when removed. |
| 442 | view->setCanBeReused(false); |
| 443 | } |
| 444 | _viewNodeTree->recordViewPoolCreate(reusedFromPool); |
| 445 | viewTransactionScope.transaction().moveViewToTree(view, _viewNodeTree, this); |
| 446 | setView(viewTransactionScope, view, animator); |
| 447 | _flags[kViewFromFactoryFlag] = true; |
| 448 | return true; |
| 449 | } else { |
| 450 | VALDI_WARN(getLogger(), "{} Could not create view with class {}", getLoggerFormatPrefix(), getViewClassName()); |
| 451 | return false; |
nothing calls this directly
no test coverage detected