mirror of
https://github.com/openharmony/ace_engine_lite.git
synced 2026-07-18 18:34:29 -04:00
Description: add component visible status change notify logic
IssueNo: I4M2B3 Feature or Bugfix: Feature Binary Source:No Signed-off-by: jiadexiang <jiadexiang@huawei.com>
This commit is contained in:
@@ -173,6 +173,10 @@ public:
|
|||||||
{
|
{
|
||||||
UNUSED(child);
|
UNUSED(child);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief OnVisibleChanged the component can be notified if the visibility status is changed
|
||||||
|
*/
|
||||||
|
virtual void OnVisibilityChanged(bool isVisible) {}
|
||||||
/**
|
/**
|
||||||
* @brief OnViewAttached called when the native view is attached to the tree
|
* @brief OnViewAttached called when the native view is attached to the tree
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -105,6 +105,22 @@ void SwiperComponent::AttachView(const Component *child)
|
|||||||
SetPageIndex();
|
SetPageIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SwiperComponent::OnVisibilityChanged(bool isVisible)
|
||||||
|
{
|
||||||
|
if (changeListener_ == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isVisible) {
|
||||||
|
swiperView_.SetOnSwipeListener(nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// component will be visible
|
||||||
|
if (swiperView_.GetOnSwipeListener() != nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
swiperView_.SetOnSwipeListener(changeListener_);
|
||||||
|
}
|
||||||
|
|
||||||
bool SwiperComponent::RegisterPrivateEventListener(uint16_t eventTypeId,
|
bool SwiperComponent::RegisterPrivateEventListener(uint16_t eventTypeId,
|
||||||
jerry_value_t funcValue,
|
jerry_value_t funcValue,
|
||||||
bool isStopPropagation)
|
bool isStopPropagation)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ protected:
|
|||||||
bool ProcessChildren() override;
|
bool ProcessChildren() override;
|
||||||
bool RegisterPrivateEventListener(uint16_t eventTypeId, jerry_value_t funcValue, bool isStopPropagation) override;
|
bool RegisterPrivateEventListener(uint16_t eventTypeId, jerry_value_t funcValue, bool isStopPropagation) override;
|
||||||
void AttachView(const Component *child) override;
|
void AttachView(const Component *child) override;
|
||||||
|
void OnVisibilityChanged(bool isVisible) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ChangeListener : public UISwipeView::OnSwipeListener {
|
class ChangeListener : public UISwipeView::OnSwipeListener {
|
||||||
|
|||||||
@@ -362,5 +362,16 @@ uint16_t FatalHandler::GetComponentCount() const
|
|||||||
{
|
{
|
||||||
return componentNodes_.Size();
|
return componentNodes_.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FatalHandler::NotifyVisibleStatusChange(bool isVisible) const
|
||||||
|
{
|
||||||
|
ListNode<Component *> *node = componentNodes_.Begin();
|
||||||
|
while (node != componentNodes_.End()) {
|
||||||
|
if (node->data_ != nullptr) {
|
||||||
|
node->data_->OnVisibilityChanged(isVisible);
|
||||||
|
}
|
||||||
|
node = node->next_;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace ACELite
|
} // namespace ACELite
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
void SetCurrentPageRootView(UIView *pageRoot);
|
void SetCurrentPageRootView(UIView *pageRoot);
|
||||||
void DumpFatalTrace(int errorCode) const;
|
void DumpFatalTrace(int errorCode) const;
|
||||||
uint16_t GetComponentCount() const;
|
uint16_t GetComponentCount() const;
|
||||||
|
void NotifyVisibleStatusChange(bool isVisible) const;
|
||||||
// define all fatal error below, please note the jerry fatal defines, avoid conflicts
|
// define all fatal error below, please note the jerry fatal defines, avoid conflicts
|
||||||
static const int ERR_INVALID = 0;
|
static const int ERR_INVALID = 0;
|
||||||
static const int ERR_NATIVE_OUT_OF_MEMORY = 200;
|
static const int ERR_NATIVE_OUT_OF_MEMORY = 200;
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ void JSAbilityImpl::Show() const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
router_->Show();
|
router_->Show();
|
||||||
|
FatalHandler::GetInstance().NotifyVisibleStatusChange(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSAbilityImpl::Hide() const
|
void JSAbilityImpl::Hide() const
|
||||||
@@ -146,6 +147,7 @@ void JSAbilityImpl::Hide() const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
router_->Hide();
|
router_->Hide();
|
||||||
|
FatalHandler::GetInstance().NotifyVisibleStatusChange(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSAbilityImpl::NotifyBackPressed() const
|
void JSAbilityImpl::NotifyBackPressed() const
|
||||||
|
|||||||
Reference in New Issue
Block a user