From aafd49b4d89f54ce77fc853f398f637fdeba907c Mon Sep 17 00:00:00 2001 From: wangtiantian Date: Fri, 18 Jun 2021 10:18:55 +0800 Subject: [PATCH] IssueNo:#I3W37E Description:fix UIPicker bug Sig:graphic Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian --- frameworks/components/text_adapter.cpp | 24 ++++++++++------------- interfaces/kits/components/text_adapter.h | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/frameworks/components/text_adapter.cpp b/frameworks/components/text_adapter.cpp index 3df75ff..1297bee 100755 --- a/frameworks/components/text_adapter.cpp +++ b/frameworks/components/text_adapter.cpp @@ -103,13 +103,7 @@ UILabel* TextAdapter::GetDynamicText(UIView* inView, int16_t index) for (int16_t i = 0; i < index; i++) { node = node->next_; } - UILabel* newView = nullptr; - if (inView == nullptr) { - newView = new UILabel(); - } else { - newView = static_cast(inView); - } - + UILabel* newView = CreateUILabel(inView); if (newView != nullptr) { newView->SetText(node->data_); if (fontName_ == nullptr) { @@ -127,13 +121,7 @@ UILabel* TextAdapter::GetIntegerText(UIView* inView, int16_t index) if ((index < 0) || ((integerTextEnd_ - integerTextStart_) < index)) { return nullptr; } - UILabel* newView = nullptr; - if (inView == nullptr) { - newView = new UILabel(); - } else { - newView = static_cast(inView); - } - + UILabel* newView = CreateUILabel(inView); if (newView != nullptr) { char buf[BUF_LEN] = {0}; if (formatter_ != nullptr) { @@ -166,6 +154,14 @@ UILabel* TextAdapter::GetIntegerText(UIView* inView, int16_t index) return newView; } +UILabel* TextAdapter::CreateUILabel(UIView* inView) +{ + if (inView == nullptr) { + return new UILabel(); + } + return static_cast(inView); +} + void TextAdapter::ClearDynamicText() { ListNode* node = dynamicText_.Begin(); diff --git a/interfaces/kits/components/text_adapter.h b/interfaces/kits/components/text_adapter.h index d3c486c..9000d6e 100755 --- a/interfaces/kits/components/text_adapter.h +++ b/interfaces/kits/components/text_adapter.h @@ -256,6 +256,7 @@ public: protected: virtual UILabel* GetTextView(UIView* inView, int16_t index); + virtual UILabel* CreateUILabel(UIView* inView); uint8_t dataMode_; private: -- GitLab