From: Caisking <3449750381@qq.com> Date: Wed, 13 Mar 2024 10:33:35 +0000 (+0800) Subject: 修改上拉列表的效果,后续还要优化 X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~11^2~5 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=dc8fb7546fa8a5c4ece37a1ae18a91444881a285;p=mirrors%2FFD230.git 修改上拉列表的效果,后续还要优化 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/dialupdate/src/DialUpdateModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/dialupdate/src/DialUpdateModel.cpp index 1dd95446a..958592f47 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dialupdate/src/DialUpdateModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dialupdate/src/DialUpdateModel.cpp @@ -17,7 +17,7 @@ #include "ui_resource_image.h" #include "common/image_cache_manager.h" -#define DIAL_DIR "user/res/dials" +#define DIAL_DIR "user/res/dials" // 表盘名称||表盘缩约图||表盘路径 DialInfo_1 dialInfo_1[MAX_DIALNUM_1]; @@ -32,78 +32,71 @@ void read_dial(void) { DIR *dirp = opendir(DIAL_DIR); // 遍历文件 - dial_num=0; - if (dirp != NULL) + dial_num = 0; + if (dirp != NULL) { - while (dirent * ret=readdir(dirp)) + while (dirent *ret = readdir(dirp)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"file_name %s \r\n",ret->d_name); - if(dialInfo_1[dial_num].dialPath) + //WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "file_name %s \r\n", ret->d_name); + if (dialInfo_1[dial_num].dialPath) { - free((void*)dialInfo_1[dial_num].dialPath); - dialInfo_1[dial_num].dialPath=NULL; + free((void *)dialInfo_1[dial_num].dialPath); + dialInfo_1[dial_num].dialPath = NULL; } - char path[124]={0}; + char path[124] = {0}; - sprintf(path,"user/res/dials/%s",ret->d_name); - char * str_1=(char*) malloc(sizeof(path)); - strcpy(str_1,path); - dialInfo_1[dial_num].dialPath=str_1; + sprintf(path, "user/res/dials/%s", ret->d_name); + char *str_1 = (char *)malloc(sizeof(path)); + strcpy(str_1, path); + dialInfo_1[dial_num].dialPath = str_1; - if(dialInfo_1[dial_num].thumbnailPath) + if (dialInfo_1[dial_num].thumbnailPath) { - free((void*)dialInfo_1[dial_num].thumbnailPath); - dialInfo_1[dial_num].thumbnailPath=NULL; + free((void *)dialInfo_1[dial_num].thumbnailPath); + dialInfo_1[dial_num].thumbnailPath = NULL; } - char path_1[124]={0}; - sprintf(path_1,"user/res/dialupdate/%s",ret->d_name); - str_1=(char*) malloc(sizeof(path_1)); - strcpy(str_1,path_1); - dialInfo_1[dial_num].thumbnailPath=str_1; + char path_1[124] = {0}; + sprintf(path_1, "user/res/dialupdate/%s", ret->d_name); + str_1 = (char *)malloc(sizeof(path_1)); + strcpy(str_1, path_1); + dialInfo_1[dial_num].thumbnailPath = str_1; - if(dialInfo_1[dial_num].title) + if (dialInfo_1[dial_num].title) { - free((void*)dialInfo_1[dial_num].title); - dialInfo_1[dial_num].title=NULL; + free((void *)dialInfo_1[dial_num].title); + dialInfo_1[dial_num].title = NULL; } - FILE * fp = fopen(path, "rb"); - if (fp == nullptr) + FILE *fp = fopen(path, "rb"); + if (fp == nullptr) { return; } - OHOS::DialHeader* data = static_cast - (OHOS::DialBinParser::GetInstance()->MallocAndReadBuf(fp, sizeof(OHOS::DialHeader))); - - char * str_2=(char*) malloc(sizeof(data->dialName)); - strcpy(str_2,data->dialName); - dialInfo_1->imageOffset=data->imageOffset; - dialInfo_1[dial_num++].title=str_2; + OHOS::DialHeader *data = static_cast(OHOS::DialBinParser::GetInstance()->MallocAndReadBuf(fp, sizeof(OHOS::DialHeader))); + char *str_2 = (char *)malloc(sizeof(data->dialName)); + strcpy(str_2, data->dialName); + dialInfo_1->imageOffset = data->imageOffset; + dialInfo_1[dial_num++].title = str_2; - - - - fclose(fp); UIFree(data); } } - + // 关闭目录 closedir(dirp); } void printf_dial(void) { - for(int i=0;iSetVisible(true); } - void DialUpdateView::init_button() { // read_dial(); - printf_dial(); // dial_num + // printf_dial(); // dial_num uint8_t fileid = DialUpdateModel::GetInstance()->GetDialConfigPath(); for (int i = fileid; i < dial_num + fileid; i++) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index 6cfd5a962..a3cb9d00d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -159,7 +159,6 @@ namespace OHOS if (!MainViewSample::GetInstance()->IsMainClockPage()) // 当前页面为主表盘的其他页面时,切换回主表盘页面 { MainViewSample::GetInstance()->SwitchToClockPage(); - RootView::GetInstance()->Invalidate(); // 刷新界面 } else { diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index 98bdb0948..eb9bfdc40 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -177,7 +177,7 @@ namespace OHOS VerticalViewInit(); VertViewLoad(); mainSwipeGroup->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - mainSwipeGroup->SetAnimatorTime(50); // 50: animator drag time(ms); + mainSwipeGroup->SetAnimatorTime(10); // 50: animator drag time(ms); mainSwipeGroup->SetLoopState(true); mainSwipeGroup->EnableScreenCap(true); // 屏幕截图展示,取消使用实时绘制 mainSwipeGroup->RegisterSwipeCallback(callback); @@ -256,10 +256,10 @@ namespace OHOS messageView->SetViewId("messageView"); messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); messageView->PreLoad(); messageView->SetDraggable(false); messageView->SetIntercept(true); + messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); #endif /* -------------------------------------------------------------------------- */ #if 0 @@ -340,7 +340,7 @@ namespace OHOS } #endif // DialUpdateModel::GetInstance()->LoadDialConfigFromJson(); - //read_dial(); + // read_dial(); uint8_t fileid = DialUpdateModel::GetInstance()->GetDialConfigPath(); std::string filePath = dialInfo_1[fileid].dialPath; mainClockView->SetDial(filePath); @@ -374,8 +374,8 @@ namespace OHOS UIView::OnLongPressListener *buttonLongPress = static_cast(MainPresenterSample::GetInstance()); mainClockView->SetOnLongPressListener(buttonLongPress); // Add to rootView - //mainClockView->Add(changebut); - //changebut->SetVisible(true); + // mainClockView->Add(changebut); + // changebut->SetVisible(true); #endif return mainClockView; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp index 856346e6a..5d1355dfc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp @@ -48,6 +48,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView->SetupViewPage() == false!"); return false; } + messageview->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); Add(messageview); messageview->GetList()->RefreshList(); // 刷新列表 return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp index 581d7b90b..fe412593b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp @@ -60,12 +60,13 @@ namespace OHOS bool MessagePresenter::OnDrag(UIView &view, const DragEvent &event) { - +#if 0 if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); } +#endif return true; } @@ -74,7 +75,7 @@ namespace OHOS UNUSED(event); MessageItemView *messageItemView = static_cast(&view); int index = messageItemView->GetMessageListIndex(); - printf("%d\n",index);//测试点击是否有效 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index:%d", index); if (index >= p_MessageModel->GetMessageListNum()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnClick is no index"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp index 62b6a8fd9..f34673f6c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp @@ -7,12 +7,12 @@ namespace OHOS { - + static constexpr uint8_t NUM_2 = 2; static MessageView *g_pMessageView{nullptr}; MessageView::MessageView() { - UIViewGroup::SetPosition(43, 120, 466, 466); + UIViewGroup::SetPosition(42, 120, 380, 960); g_pMessageView = this; } @@ -36,28 +36,16 @@ namespace OHOS { scrollView = new UIScrollView(); } - scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - scrollView->SetScrollBlankSize(20); + scrollView->SetPosition(0, 0, 380, 466); + // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView->SetScrollBlankSize(35); scrollView->SetReboundSize(50); scrollView->SetTouchable(true); scrollView->SetDraggable(true); + scrollView->SetDirection(1); draglistener = static_cast(MessagePresenter::GetInstance()); scrollView->SetOnDragListener(draglistener); /* -------------------------------------------------------------------------- */ - if (title == nullptr) - { - title = new UILabel(); - } - title->SetPosition(173, 52, 120, 35); - title->Resize(120, 35); - title->SetStyle(STYLE_TEXT_FONT, 30); - title->SetStyle(STYLE_LINE_HEIGHT, 36); - title->SetText("信息通知"); - title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - /* -------------------------------------------------------------------------- */ // UIList 的适配器 p_MessageListAdapter = new MessageListAdapter(); p_MessageListAdapter->SetItemClickListener(presenter_); @@ -66,7 +54,7 @@ namespace OHOS MessageList = new UIList(); } MessageList->SetPosition(43, 120, 380, 600); - MessageList->SetStyle(STYLE_BACKGROUND_COLOR, 0x00000000); + MessageList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); } void MessageView::DeInitView() @@ -112,12 +100,12 @@ namespace OHOS void MessageView::OnSetUpView() { View::OnSetUpView(); - scrollView->Add(title); + // scrollView->Add(title); scrollView->Add(MessageList); - scrollView->SetBackgroundBlur(10000); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); RootView::GetInstance()->Add(scrollView); MessageList->SetAdapter(p_MessageListAdapter); - MessageList->RefreshList(); // 刷新列表 + // MessageList->RefreshList(); // 刷新列表 Draw(); } @@ -146,16 +134,21 @@ namespace OHOS { MessageList = new UIList(); } - MessageList->SetPosition(0, 0, 380, 600); - MessageList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - MessageList->SetScrollBlankSize(10); - MessageList->EnableAutoAlign(true); - MessageList->RefreshList(); // 刷新列表 + MessageList->SetPosition(0, 0); + MessageList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); MessageList->SetDraggable(true); - MessageList->SetThrowDrag(false); - MessageList->SetLoopState(true); - - // MessageList->SetYScrollBarVisible(true); + MessageList->SetThrowDrag(true); + MessageList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + //MessageList->SetOpaScale(100); + + MessageList->SetScrollBlankSize(100); + MessageList->SetReboundSize(50); + MessageList->SetSelectPosition(HORIZONTAL_RESOLUTION / 2); // middle position + MessageList->SetDirection(1); + UIView::OnClickListener *list1Click = static_cast(MessagePresenter::GetInstance()); + MessageList->SetOnClickListener(list1Click); + UIView::OnDragListener *list1Drag = static_cast(MessagePresenter::GetInstance()); + MessageList->SetOnDragListener(list1Drag); Add(MessageList); MessageList->SetAdapter(p_MessageListAdapter); MessageList->SetVisible(true);