From: Caisking <3449750381@qq.com> Date: Wed, 24 Jan 2024 09:31:42 +0000 (+0800) Subject: 暂时实现上滑,需要点击一下界面才会出现 X-Git-Tag: release_V1.2.70_20241020_135402~1333 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=f5ef27d870f401e796c7cfdf0641042da7fd1920;p=mirrors%2FFD230.git 暂时实现上滑,需要点击一下界面才会出现 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index 8be7aca94..c1da733e2 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -78,7 +78,7 @@ namespace OHOS PullUpDownView *dropDownView{nullptr}; /* -------------------------------------------------------------------------- */ MessageCardView *messageView{nullptr}; - UILabel *Messagelabel = nullptr; + UILabel *MessageLable = nullptr; UIList *Messagelist = nullptr; IconAdapter *list1adapter_ = nullptr; List *Messagelistdate = nullptr; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index 2c20e5988..6e9f13931 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -55,7 +55,7 @@ namespace OHOS pageStatus[i] = false; } mainSwipeGroup->RemoveAll(); -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ #if 0 UIView *view = static_cast(MainViewSample::mainSwipeGroup)->GetChildrenHead(); while (view != nullptr) @@ -100,10 +100,10 @@ namespace OHOS delete messageView; messageView = nullptr; } - if (Messagelabel != nullptr) + if (MessageLable != nullptr) { - delete Messagelabel; - Messagelabel = nullptr; + delete MessageLable; + MessageLable = nullptr; } if (Messagelist != nullptr) { @@ -254,7 +254,7 @@ namespace OHOS dropDownView->SetViewId("dropDownView"); dropDownView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); dropDownView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - +#if 1 messageView = new MessageCardView(); if (messageView == nullptr) { @@ -265,8 +265,17 @@ namespace OHOS messageView->SetViewId("messageView"); messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - +#endif +/* -------------------------------------------------------------------------- */ #if 0 + messageView = new UICardPage(); + if (messageView == nullptr) + { + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail"); + return; + } + } messageView->SetPosition(0, 0); messageView->SetWidth(Screen::GetInstance().GetWidth()); messageView->SetHeight(Screen::GetInstance().GetHeight()); @@ -274,18 +283,18 @@ namespace OHOS messageView->SetViewId("messageView"); messageView->SetTouchable(true); messageView->SetIntercept(true); - messageLable = new UILabel(); - if (messageLable == nullptr) + MessageLable = new UILabel(); + if (MessageLable == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLable new fail"); return; } - messageLable->SetPosition(MESLABLE_X_TMP, MESLABLE_Y_TMP, MESLABLE_WIDTH_TMP, MESLABLE_HEIGHT_TMP); - messageLable->SetText("无消息"); - messageLable->SetAlign(TEXT_ALIGNMENT_CENTER); - messageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_SIZE_TMP); - messageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - messageView->Add(messageLable); + MessageLable->SetPosition(MESLABLE_X_TMP, MESLABLE_Y_TMP, MESLABLE_WIDTH_TMP, MESLABLE_HEIGHT_TMP); + MessageLable->SetText("无消息"); + MessageLable->SetAlign(TEXT_ALIGNMENT_CENTER); + MessageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_SIZE_TMP); + MessageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + messageView->Add(MessageLable); #endif } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h index bfbfa1a0f..053d52969 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageAdapter.h @@ -24,7 +24,7 @@ namespace OHOS typedef struct { int index; - const char *icon; // 图标 + ImageInfo *icon; // 图标 const char *label; // 标签 const char *labelbutton; // 未读 bool hasSecondMenu; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageCradView.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageCradView.h deleted file mode 100644 index 00b3283ac..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageCradView.h +++ /dev/null @@ -1,10 +0,0 @@ -/*** - * @Author: Caisking 3449750381@qq.com - * @Date: 2024-01-23 10:38:47 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-23 10:38:49 - * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageCradView.h - * @Description: - * @ - * @Copyright (c) 2024 by Caisking , All Rights Reserved. - */ diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h index 97c01b118..d4249d883 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h @@ -2,7 +2,7 @@ * @Author: Caisking 3449750381@qq.com * @Date: 2024-01-23 16:03:34 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-23 18:05:43 + * @LastEditTime: 2024-01-24 14:33:55 * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageModel.h * @Description: * @ @@ -35,7 +35,7 @@ namespace OHOS MessageModel &operator=(const MessageModel &); virtual ~MessageModel(); static const uint16_t MessageListMaxNum = 4; - MessageListItem Messages[MessageListMaxNum] = {0, nullptr}; + MessageListItem Messages[MessageListMaxNum] = {0, nullptr, nullptr, nullptr, false}; //std::map MessageIdToViewId; bool btConnectStatus{false}; }; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h index 148f7b33f..229b1a0fd 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/include/MessageView.h @@ -22,7 +22,7 @@ namespace OHOS { class MessagePresenter; class MessageModel; - class MessageView : public View + class MessageView : public View,public UIViewGroup { public: @@ -36,7 +36,7 @@ namespace OHOS void OnStop() override; void AddMessageToList(const MessageListItem &item); bool InitPage(); - bool SetupViewPage(MessageView *MessageView); + bool SetupViewPage(MessageView *messageView); private: void InitView(void); @@ -47,7 +47,7 @@ namespace OHOS UIScrollView *scrollView = nullptr; UILabel *title{nullptr}; MessageListAdapter *p_MessageListAdapter{nullptr}; - UIList *MessageList = nullptr; // 音乐列表 + UIList *MessageList = nullptr; UIView::OnDragListener *draglistener{nullptr}; MessagePresenter *g_MessagePresenter{nullptr}; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp index 033533405..4acd4b125 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp @@ -2,7 +2,7 @@ * @Author: Caisking 3449750381@qq.com * @Date: 2024-01-23 16:03:34 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-23 17:27:19 + * @LastEditTime: 2024-01-24 11:43:05 * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp * @Description: * @ @@ -10,6 +10,7 @@ */ #include "message/include/MessageAdapter.h" #include "message/include/MessageItemView.h" +#include "wearable_log.h" namespace OHOS { @@ -44,6 +45,7 @@ namespace OHOS /// @return 返回该视图对象 UIView *MessageListAdapter::GetView(UIView *inView, int16_t index) { + DEBUG_PRINT("GetView::"); //1.先检查列表数据是否为空,若为空则返回空指针 if (listData.empty()) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp index 0248e3ca6..f642891c5 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp @@ -1,14 +1,15 @@ -/*** +/*** * @Author: Caisking 3449750381@qq.com * @Date: 2024-01-23 16:03:34 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-23 19:37:35 + * @LastEditTime: 2024-01-24 10:38:52 * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp - * @Description: + * @Description: * @ - * @Copyright (c) 2024 by Caisking , All Rights Reserved. + * @Copyright (c) 2024 by Caisking , All Rights Reserved. */ #include "message/include/MessageCardView.h" +#include "wearable_log.h" namespace OHOS { @@ -39,29 +40,33 @@ namespace OHOS bool MessageCardView::InitView(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageCardView::InitView()"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ::InitView()"); messageview = new MessageView(); + DEBUG_PRINT("MessageCardView::"); if (messageview == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new mainweatherView fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView::new mainweatherView fail!"); return false; } + DEBUG_PRINT("MessageCardView::"); if (messageview->InitPage() == false) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView->InitPage() == false!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView->InitPage() == false!"); return false; } + DEBUG_PRINT("MessageCardView::"); if (messageview->SetupViewPage(messageview) == false) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageView->SetupViewPage() == false!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView->SetupViewPage() == false!"); return false; } - viewiInitStatus = true; + Add(messageview); return true; } void MessageCardView::PreLoad(void) { + DEBUG_PRINT("PreLoad"); if (!viewiInitStatus) { InitView(); @@ -71,7 +76,6 @@ namespace OHOS void MessageCardView::UnLoad(void) { - } } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp index 8efef7ae2..674b75db7 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageModel.cpp @@ -9,6 +9,7 @@ * @Copyright (c) 2024 by Caisking , All Rights Reserved. */ #include "message/include/MessageModel.h" +#include "common/image_cache_manager.h" namespace OHOS { @@ -25,10 +26,15 @@ namespace OHOS void MessageModel::InitMessageListItem() { - Messages[0] = {0, "/user/res/message/system-icon.bin", "系统", "暂无信息", false}; - Messages[1] = {1, "/user/res/message/message-icon.bin", "信息", "暂无信息", false}; - Messages[2] = {2, "/user/res/message/WeChat-icon.bin", "微信", "暂无信息", false}; - Messages[3] = {3, "/user/res/message/QQ-icon.bin", "QQ", "暂无信息", false}; + ImageInfo *imgSystem = ImageCacheManager::GetInstance().LoadSingleRes(PNG_Message_System); + ImageInfo *imgNote = ImageCacheManager::GetInstance().LoadSingleRes(PNG_Message_Note); + ImageInfo *imgWechat = ImageCacheManager::GetInstance().LoadSingleRes(PNG_Message_Wechat); + ImageInfo *imgQQ = ImageCacheManager::GetInstance().LoadSingleRes(PNG_Message_QQ); + + Messages[0] = {0, imgSystem, "系统", "暂无信息", false}; + Messages[1] = {1, imgNote, "信息", "暂无信息", false}; + Messages[2] = {2, imgWechat, "微信", "暂无信息", false}; + Messages[3] = {3, imgQQ, "QQ", "暂无信息", false}; } const MessageListItem *MessageModel::GetMessagelistItems() const diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp index 6e3abf829..383a2fedb 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp @@ -12,6 +12,7 @@ #include "message/include/MessagePresenter.h" #include "UiConfig.h" +#include "wearable_log.h" namespace OHOS { @@ -20,7 +21,7 @@ namespace OHOS MessageView::MessageView() { - + UIViewGroup::SetPosition(0, 0, 466, 466); g_pMessageView = this; } @@ -79,7 +80,8 @@ namespace OHOS void MessageView::DeInitView() { - scrollView->RemoveAll(); + // scrollView-> RemoveAll(); + RemoveAll(); delete title; title = nullptr; @@ -169,6 +171,7 @@ namespace OHOS title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView->Add(title); /* -------------------------------------------------------------------------- */ // UIList 的适配器 p_MessageListAdapter = new MessageListAdapter(); @@ -179,19 +182,24 @@ namespace OHOS } MessageList->SetPosition(43, 120, 380, 600); MessageList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - scrollView->Add(title); scrollView->Add(MessageList); MessageList->SetAdapter(p_MessageListAdapter); + MessageList->SetVisible(true); + Add(scrollView); + scrollView->SetVisible(true); return true; } // 设置页面视图 - bool MessageView::SetupViewPage(MessageView *MessageView) + bool MessageView::SetupViewPage(MessageView *messageView) { + g_MessageModel = &MessageModel::GetInstance(); + g_MessageModel->InitMessageListItem(); const MessageListItem *itemInfo = g_MessageModel->GetMessagelistItems(); for (int i = 0; i < g_MessageModel->GetMessageListNum(); i++) { - AddMessageToList(itemInfo[i]); + messageView->AddMessageToList(itemInfo[i]); + printf("Index: %d, Icon: %s, Label: %s, Label Button: , Has Second Menu: \n", itemInfo[i].index, itemInfo[i].icon, itemInfo[i].label); } return true; } diff --git a/code/sdk/application/wearable/ohos_deps/wearable_log.h b/code/sdk/application/wearable/ohos_deps/wearable_log.h index 47b6fd080..b56f669d5 100755 --- a/code/sdk/application/wearable/ohos_deps/wearable_log.h +++ b/code/sdk/application/wearable/ohos_deps/wearable_log.h @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-20 10:32:41 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-24 10:38:48 + * @FilePath: /FD230/code/sdk/application/wearable/ohos_deps/wearable_log.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ /* * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. * Description: Wearable log header file. @@ -66,6 +76,15 @@ typedef enum { #ifdef __cplusplus #if __cplusplus + +/* -------------------------------------------------------------------------- */ +#define DEBUG 1 // 1表示开启打印,0表示关闭打印 +#if DEBUG +#define DEBUG_PRINT(msg) printf("File: %s, Line: %d - %s\n", __FILE__, __LINE__, msg) +#else +#define PRINT_DEBUG(msg) // 空语句,即关闭打印 +#endif +/* -------------------------------------------------------------------------- */ } #endif #endif