From 1ac4b4c7b2246120b0c3e1e5f1d078c07b6d309a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Tue, 14 Jan 2025 16:48:47 +0000 Subject: [PATCH] Merge #1628 into sdk602patch0911 from refs/changes/1628/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/1628/head: (4 commits squashed) - 优化音乐播放器界面的播放暂停按钮初UI始化状态 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 解决蓝牙耳机界面内存泄露问题 - 解决电话界面内存泄露 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: Caisking <3449750381@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1628 --- .../src/BluetoothDeviceCaseListAdapter.cpp | 282 +++++++++--------- .../nativeui/makephone/src/CallingView.cpp | 3 + .../nativeui/phone/include/PhoneCallView.h | 19 +- .../nativeui/phone/src/PhoneCallView.cpp | 122 ++------ 4 files changed, 177 insertions(+), 249 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp index ed75a08c8..dfda43dda 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp @@ -13,159 +13,169 @@ #include "UiConfig.h" #include "BluetoothPresenter.h" -namespace OHOS { -BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter"); - // UIView::OnClickListener *click = item->GetOnClickListener(); - // if (click != nullptr) { - // delete click; - // click = nullptr; - // } - if (listener != nullptr) { - delete listener; - listener = nullptr; - } -} - -uint16_t BluetoothDeviceCaseListAdapter::GetCount() -{ - return BluetoothModel::GetInstance()->GetConnedDevicesCase().Size(); -} - -class BluetoothDeviceOnClickListListener : public UIView::OnClickListener { -public: - BluetoothDeviceOnClickListListener(BluetoothCaseInfo *bluetoothInfo) - { - if (bluetoothInfo != nullptr) { - (void)memcpy_s(addr.addr, BD_ADDR_LEN, - bluetoothInfo->addr, BD_ADDR_LEN); // 源和目标内存长度一样,不做返回值判断 - (void)memcpy_s(bluetoothInfo_.addr, BD_ADDR_LEN, - bluetoothInfo->addr, BD_ADDR_LEN); // 源和目标内存长度一样,不做返回值判断 - (void)memcpy_s(bluetoothInfo_.deviceName, BD_NAME_LEN, - bluetoothInfo->deviceName, BD_NAME_LEN); // 源和目标内存长度一样,不做返回值判断 - bluetoothInfo_.index = bluetoothInfo->index; - bluetoothInfo_.connIndex = bluetoothInfo->connIndex; - } - } - ~BluetoothDeviceOnClickListListener() {} - bool OnClick(UIView& view, const ClickEvent& event) override + class BluetoothDeviceOnClickListListener; + static BluetoothDeviceOnClickListListener *g_btOnClickListListener = nullptr; + class BluetoothDeviceOnClickListListener : public UIView::OnClickListener { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClickListListener"); - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClickListListener addr: %02x%02x%02x%02x%02x%02x", - bluetoothInfo_.addr[5], bluetoothInfo_.addr[4], bluetoothInfo_.addr[3], /* mac下标 0 1 2 3 4 5 */ - bluetoothInfo_.addr[2], bluetoothInfo_.addr[1], bluetoothInfo_.addr[0]); /* mac下标 0 1 2 3 4 5 */ - BluetoothModel::GetInstance()->SetTempMacValue(&bluetoothInfo_); - /* 点击事件 */ - // 跳转可选页 - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - JumpView *jumpView = JumpView::GetInstance(); - if (jumpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick jumpView GetInstance fail"); - return false; - } - jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHDEVICELISTVIEW, - JumpView::BluetoothJumpViewNum::BLUETOOTHEOPTIONSVIEW); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance(); - if (mainBluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick mainBluetoothView GetInstance fail"); - return false; + public: + BluetoothDeviceOnClickListListener() {} + ~BluetoothDeviceOnClickListListener() {} + void SetItemInfo(const BluetoothCaseInfo *bluetoothInfo) + { + if (bluetoothInfo != nullptr) + { + (void)memcpy_s(addr.addr, BD_ADDR_LEN, + bluetoothInfo->addr, BD_ADDR_LEN); // 源和目标内存长度一样,不做返回值判断 + (void)memcpy_s(bluetoothInfo_.addr, BD_ADDR_LEN, + bluetoothInfo->addr, BD_ADDR_LEN); // 源和目标内存长度一样,不做返回值判断 + (void)memcpy_s(bluetoothInfo_.deviceName, BD_NAME_LEN, + bluetoothInfo->deviceName, BD_NAME_LEN); // 源和目标内存长度一样,不做返回值判断 + bluetoothInfo_.index = bluetoothInfo->index; + bluetoothInfo_.connIndex = bluetoothInfo->connIndex; } - if(view.GetViewType() == UIViewType::UI_BUTTON) + } + bool OnClick(UIView &view, const ClickEvent &event) override + { + UNUSED(event); + BluetoothItemView *itemView = static_cast(view.GetParent()); + BluetoothCaseInfo *g_BluetoothCaseInfo = itemView->GetItemInfo(); + SetItemInfo(g_BluetoothCaseInfo); // 保存点击的设备信息 + BluetoothModel::GetInstance()->SetTempMacValue(&bluetoothInfo_); + if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UIViewType::UI_BUTTON,%s",reinterpret_cast(bluetoothInfo_.deviceName)); - bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "lastAddr:%02X %02X %02X * * *", - lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]); - - bool ret = bt_is_acl_connected(lastAddr); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt_is_acl_connected:%d lastAddr:%02X %02X %02X * * *", - ret, lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]); - - //地址不是全0并且ret为真 - if (!( lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0 && - lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0 ) && ret) { - BluetoothModel::GetInstance()->SetTagConnectNew(false); - errcode_t retVal = gap_disconnect_remote_device(lastAddr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[gap_disconnect_remote_device] retVal = %d", retVal); - } else { - mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW); - errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnectRemoteDevice] retVal = %d", retVal); + JumpView *jumpView = JumpView::GetInstance(); + if (jumpView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick jumpView GetInstance fail"); + return false; } + jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHDEVICELISTVIEW, + JumpView::BluetoothJumpViewNum::BLUETOOTHEOPTIONSVIEW); } - else if(view.GetViewType() == UIViewType::UI_IMAGE_VIEW) /*点击的是图片*/ + else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UIViewType::UI_IMAGE_VIEW"); - mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHEOPTIONSVIEW); - BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance(); - if (bluetoothOptionsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick bluetoothOptionsView new fail"); + MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance(); + if (mainBluetoothView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick mainBluetoothView GetInstance fail"); return false; } - bluetoothOptionsView->SetCurrentAddr(addr); - bluetoothOptionsView->RefreshText(); + if (view.GetViewType() == UIViewType::UI_BUTTON) // 点击的是按钮 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UIViewType::UI_BUTTON,%s", reinterpret_cast(bluetoothInfo_.deviceName)); + bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr(); + bool ret = bt_is_acl_connected(lastAddr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bt_is_acl_connected:%d lastAddr:%02X %02X %02X * * *", + ret, lastAddr->addr[0], lastAddr->addr[1], lastAddr->addr[2]); + + // 地址不是全0并且ret为真 + if (!(lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0 && + lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0) && + ret) + { + BluetoothModel::GetInstance()->SetTagConnectNew(false); + errcode_t retVal = gap_disconnect_remote_device(lastAddr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[gap_disconnect_remote_device] retVal = %d", retVal); + } + else + { + mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW); + errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnectRemoteDevice] retVal = %d", retVal); + } + } + else if (view.GetViewType() == UIViewType::UI_IMAGE_VIEW) /*点击的是图片*/ + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UIViewType::UI_IMAGE_VIEW,%s", reinterpret_cast(bluetoothInfo_.deviceName)); + mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHEOPTIONSVIEW); + BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance(); + if (bluetoothOptionsView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick bluetoothOptionsView new fail"); + return false; + } + bluetoothOptionsView->SetCurrentAddr(addr); + bluetoothOptionsView->RefreshText(); + } } - } - - return true; - } -private: - BluetoothCaseInfo bluetoothInfo_{}; - bd_addr_t addr; -}; + return true; + } + private: + BluetoothCaseInfo bluetoothInfo_{}; + bd_addr_t addr; + }; -UIView *BluetoothDeviceCaseListAdapter::GetView(UIView *inView, int16_t index) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter GetView"); - List &bluetoothCaseList = BluetoothModel::GetInstance()->GetConnedDevicesCase(); - if (bluetoothCaseList.IsEmpty()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothCaseList IsEmpty"); - return nullptr; - } - if ((index > bluetoothCaseList.Size() - 1) || (index < 0)) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::GetView err,%d,%d",index,bluetoothCaseList.Size()); - return nullptr; + BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter"); + if (g_btOnClickListListener != nullptr) + { + delete g_btOnClickListListener; + g_btOnClickListListener = nullptr; + } } - ListNode* node = bluetoothCaseList.Begin(); - for (uint16_t i = 0; i < index; i++) { - node = node->next_; + + uint16_t BluetoothDeviceCaseListAdapter::GetCount() + { + return BluetoothModel::GetInstance()->GetConnedDevicesCase().Size(); } - node->data_.index = index; - BluetoothCaseInfo itemData = node->data_; - if (inView == nullptr) { - item = new BluetoothItemView(); - if (item == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetView item err"); + + UIView *BluetoothDeviceCaseListAdapter::GetView(UIView *inView, int16_t index) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter GetView"); + List &bluetoothCaseList = BluetoothModel::GetInstance()->GetConnedDevicesCase(); + if (bluetoothCaseList.IsEmpty()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothCaseList IsEmpty"); return nullptr; } - } else { - item = static_cast(inView); - } - item->SetViewIndex(index); - item->SetItemInfo(itemData, false); - item->SetConnectionstatus(itemData); + if ((index > bluetoothCaseList.Size() - 1) || (index < 0)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::GetView err,%d,%d", index, bluetoothCaseList.Size()); + return nullptr; + } + ListNode *node = bluetoothCaseList.Begin(); + for (uint16_t i = 0; i < index; i++) + { + node = node->next_; + } + node->data_.index = index; + BluetoothCaseInfo itemData = node->data_; + if (inView == nullptr) + { + item = new BluetoothItemView(); + if (item == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetView item err"); + return nullptr; + } + } + else + { + item = static_cast(inView); + } + item->SetViewIndex(index); + item->SetItemInfo(itemData, false); + item->SetConnectionstatus(itemData); - listener = item->GetOnClickListener(); - if (listener != nullptr) { - delete listener; - listener = nullptr; - } - listener = new BluetoothDeviceOnClickListListener(&node->data_); - if (listener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetView BluetoothDeviceOnClickListListener err"); - return nullptr; + if (g_btOnClickListListener == nullptr) + { + g_btOnClickListListener = new BluetoothDeviceOnClickListListener(); + if (g_btOnClickListListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::GetView new fail"); + return nullptr; + } + } + listener = static_cast(g_btOnClickListListener); + item->SetViewOnClickListener(listener); + sprintf_s(addrTmp, sizeof(addrTmp), "%02x%02x%02x%02x%02x%02x", node->data_.addr[0], node->data_.addr[1], + node->data_.addr[2], node->data_.addr[3], node->data_.addr[4], node->data_.addr[5]); // 没有%s类型,不做返回判断 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addrTmp %s", addrTmp); + return item; } - sprintf_s(addrTmp, sizeof(addrTmp), "%02x%02x%02x%02x%02x%02x", node->data_.addr[0], node->data_.addr[1], - node->data_.addr[2], node->data_.addr[3], node->data_.addr[4], node->data_.addr[5]); // 没有%s类型,不做返回判断 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "addrTmp %s", addrTmp); - - // item->SetOnClickListener(listener); - item->SetViewOnClickListener(listener); - return item; -} } // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp index 471bfc290..435584715 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp @@ -83,6 +83,9 @@ CallingView::~CallingView() imagedial = nullptr; + delete imageheadset; + imageheadset = nullptr; + delete imageperson; imageperson = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h index 59b844848..8878f6d40 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h @@ -45,7 +45,6 @@ namespace OHOS // 定义包含按钮初始化参数的结构体 struct ButtonInitParams { - UIButton *button; const char *buttonNumber; int leftPos; int topPos; @@ -74,7 +73,7 @@ namespace OHOS void Init(); void DeInit(); void container_child_init(); - void initButton(const ButtonInitParams ¶ms); + UIButton* initButton(const ButtonInitParams ¶ms); void UpdateLabel(const std::string &text); void container_child_SetVisible(bool); void start_call_roll_timer(); @@ -92,21 +91,7 @@ namespace OHOS UILabel *label_ = nullptr; UILabel *label_4G = nullptr; UILabel *label_BT = nullptr; - UIButton *button1_ = nullptr; - UIButton *button2_ = nullptr; - UIButton *button3_ = nullptr; - UIButton *button4_ = nullptr; - UIButton *button5_ = nullptr; - UIButton *button6_ = nullptr; - UIButton *button7_ = nullptr; - UIButton *button8_ = nullptr; - UIButton *button9_ = nullptr; - UIButton *button0_ = nullptr; - UIButton *buttoncall_ = nullptr; - UIButton *buttondel_ = nullptr; - UIButton *button_4G =NULL; - UIButton *button_BT =NULL; - + UIButton *button_[12] = {nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp index d98534d7d..b6e1da1e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp @@ -32,13 +32,9 @@ namespace OHOS return g_pPhoneCallView; } - void PhoneCallView ::initButton(const ButtonInitParams ¶ms) + UIButton* PhoneCallView ::initButton(const ButtonInitParams ¶ms) { - UIButton *button = params.button; - if (button == nullptr) - { - button = new UIButton(); - } + UIButton *button = new UIButton(); const char *buttonNumber = params.buttonNumber; int leftPos = params.leftPos; @@ -69,6 +65,7 @@ namespace OHOS container_->Add(button); button->SetVisible(true); + return button; } @@ -81,12 +78,6 @@ namespace OHOS void PhoneCallView::Init() { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } // Add Label to App if (label_ == nullptr) { @@ -110,23 +101,22 @@ namespace OHOS container_->Add(label_); label_->SetVisible(true); ButtonInitParams buttonParams[] = { - {button1_, BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, - {button2_, BUTTON2, 181, 104, 104, 70, button2Path, button2Path}, - {button3_, BUTTON3, 293, 104, 104, 70, button3Path, button3Path}, - {button4_, BUTTON4, 69, 182, 104, 70, button4Path, button4Path}, - {button5_, BUTTON5, 182, 182, 104, 70, button5Path, button5Path}, - {button6_, BUTTON6, 293, 182, 104, 70, button6Path, button6Path}, - {button7_, BUTTON7, 69, 260, 104, 70, button7Path, button7Path}, - {button8_, BUTTON8, 181, 260, 104, 70, button8Path, button8Path}, - {button9_, BUTTON9, 293, 260, 104, 70, button9Path, button9Path}, - {button0_, BUTTON0, 181, 338, 104, 70, button0Path, button0Path}, - {buttoncall_, BUTTONCALL, 69, 338, 104, 70, buttonCallPath, buttonCallPath}, - {buttondel_, BUTTONDEL, 293, 338, 104, 70, buttonDelPath, buttonDelPath}, + { BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, + {BUTTON2, 181, 104, 104, 70, button2Path, button2Path}, + { BUTTON3, 293, 104, 104, 70, button3Path, button3Path}, + { BUTTON4, 69, 182, 104, 70, button4Path, button4Path}, + { BUTTON5, 182, 182, 104, 70, button5Path, button5Path}, + { BUTTON6, 293, 182, 104, 70, button6Path, button6Path}, + { BUTTON7, 69, 260, 104, 70, button7Path, button7Path}, + { BUTTON8, 181, 260, 104, 70, button8Path, button8Path}, + { BUTTON9, 293, 260, 104, 70, button9Path, button9Path}, + { BUTTON0, 181, 338, 104, 70, button0Path, button0Path}, + { BUTTONCALL, 69, 338, 104, 70, buttonCallPath, buttonCallPath}, + { BUTTONDEL, 293, 338, 104, 70, buttonDelPath, buttonDelPath}, }; - for (const auto ¶ms : buttonParams) - { - initButton(params); + for(int i = 0;i<12;i++){ + button_[i] = initButton(buttonParams[i]); } } static int8_t roll_falg=0;//0.1s一次变换 @@ -213,89 +203,29 @@ namespace OHOS { container_->RemoveAll(); } - if(container_child!=NULL) + if(container_child!=nullptr) { container_child->RemoveAll(); } - if(button_4G!=NULL) - { - delete button_4G; - button_4G = nullptr; - } - if(button_BT!=NULL) + if(label_!=nullptr) { - delete button_BT; - button_BT = nullptr; + delete label_; + label_ = nullptr; } - if(label_4G!=NULL) + if(label_4G!=nullptr) { delete label_4G; label_4G = nullptr; } - if(label_BT!=NULL) + if(label_BT!=nullptr) { delete label_BT; label_BT = nullptr; } - if (button1_ != nullptr) - { - delete button1_; - button1_ = nullptr; - } - if (button2_ != nullptr) - { - delete button2_; - button2_ = nullptr; - } - if (button3_ != nullptr) - { - delete button3_; - button3_ = nullptr; - } - if (button4_ != nullptr) - { - delete button4_; - button4_ = nullptr; - } - if (button5_ != nullptr) - { - delete button5_; - button5_ = nullptr; - } - if (button6_ != nullptr) - { - delete button6_; - button6_ = nullptr; - } - if (button7_ != nullptr) - { - delete button7_; - button7_ = nullptr; - } - if (button8_ != nullptr) - { - delete button8_; - button8_ = nullptr; - } - if (button9_ != nullptr) - { - delete button9_; - button9_ = nullptr; - } - if (button0_ != nullptr) - { - delete button0_; - button0_ = nullptr; - } - if (buttoncall_ != nullptr) - { - delete buttoncall_; - buttoncall_ = nullptr; - } - if (buttondel_ != nullptr) + for(int i = 0;i<12;i++) { - delete buttondel_; - buttondel_ = nullptr; + delete button_[i]; + button_[i] = nullptr; } if(call_roll_timer) { -- 2.17.1