From: luozheng <1732036298@qq.com> Date: Thu, 29 Jan 2026 11:05:13 +0000 (+0800) Subject: 直线列表修改为居中显示 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F3153%2F1;p=mirrors%2FFD230.git 直线列表修改为居中显示 --- diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/include/ApplistView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/include/ApplistView.h index 546696221..fbe463ba0 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/include/ApplistView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/include/ApplistView.h @@ -126,6 +126,7 @@ public: private: /* for list style */ void ListStyleOnStart(); + void ListStyleOnSetUpView(); void ListStyleOnStop(); ApplistAdapter *listAdapter_{nullptr}; UIList *contentList_{nullptr}; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/src/ApplistView.cpp index b92725759..d36c98cf2 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/src/ApplistView.cpp @@ -897,6 +897,37 @@ void ApplistView::ListStyleOnStart() AddViewToRootContainer(contentList_); } +void ApplistView::ListStyleOnSetUpView(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnSetUpView [%d]", __LINE__); + uint16_t startIndex = 0; + int16_t headY = 0; + if (presenter_->GetStartIndex() >= presenter_->GetListItemNum()) { + startIndex = presenter_->GetListItemNum() - 1; + headY = VERTICAL_RESOLUTION / NUM_2; + } else { + uint16_t presliceId = NativeAbility::GetInstance().GetPreSliceId(); + if (presliceId == VIEW_MAIN) //如果是从主页进入的,那么startIndex = 0,headY = 0 + { + startIndex = 0; + headY = 68; + } else { //如果是从其他页面进入的,那么startIndex = presenter_->GetArcListStartIndex(),headY = presenter_->GetArcListHeadItemY() + startIndex = presenter_->GetArcListStartIndex(); + headY = presenter_->GetArcListHeadItemY(); + } + if (headY == 0) { + headY = VERTICAL_RESOLUTION / NUM_2; + } + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startIndex = %d, headY = %d\n", startIndex, headY); + contentList_->SetAdapter(listAdapter_); + contentList_->ScrollTo(startIndex); + contentList_->ScrollBy(headY); + contentList_->RefreshList(); + return; +} + + void ApplistView::ResumeWaterFallDraggable() { if (waterfallList_ != nullptr) { @@ -1058,23 +1089,8 @@ void ApplistView::RefreshAppList(void) ArcScaleListStyleOnSetUpView(); } else if (style == AppListStyle::CIRCLE_LIST_STYLE) { // 拨号盘 - } else { - uint16_t startIndex = 0; - int16_t headY = 0; - if (presenter_->GetStartIndex() >= presenter_->GetListItemNum()) { - startIndex = presenter_->GetListItemNum() - 1; - headY = VERTICAL_RESOLUTION / NUM_2; - } else { - startIndex = presenter_->GetStartIndex(); - headY = presenter_->GetHeadItemY(); - if (headY == 0) { - headY = VERTICAL_RESOLUTION / NUM_2; - } - } - contentList_->SetAdapter(listAdapter_); - contentList_->ScrollTo(startIndex); - contentList_->ScrollBy(headY); - contentList_->RefreshList(); + } else if (style == AppListStyle::APPLIST_STYLE) { + ListStyleOnSetUpView(); } }