* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-30 09:14:38
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-24 17:50:33
+ * @LastEditTime: 2024-09-14 19:57:56
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/include/SettingModel.h
*/
void InitSettingItem();
const SettingItem *GetSettinglistItems() const;
uint8_t GetSettingListNum() const;
+ void SetStartIndex(uint16_t index);
+ uint16_t GetStartIndex(void);
+ void SetHeadItemY(int y);
+ int GetHeadItemY(void);
bool GetPhoneConnectStatus(void);
bool GetEarPhoneConnectStatus(void);
bool GetBlueToothConnectStatus(void);
virtual ~SettingModel();
SettingItem settings[SETTING_ITEM_COUNT] = {VIEW_INVALID, nullptr, STR_EXERCISE_GENERAL, false};
int usedLen;
+ uint16_t startIndex{0};
+ int headItemY{0};
bool phoneConnectStatus{false};
bool earphoneConnectStatus{false};
bool btConnectStatus{false};
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-12 11:44:04
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-29 17:49:05
+ * @LastEditTime: 2024-09-18 09:39:55
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp
*/
/*
return g_pSettingPresenter;
}
+ void SettingPresenter::SetStartIndex(uint16_t index)
+ {
+ settingModel->SetStartIndex(index);
+ }
+
+ uint16_t SettingPresenter::GetStartIndex(void)
+ {
+ return settingModel->GetStartIndex();
+ }
+
+ void SettingPresenter::SetHeadItemY(int y)
+ {
+ settingModel->SetHeadItemY(y);
+ }
+
+ int SettingPresenter::GetHeadItemY(void)
+ {
+ return settingModel->GetHeadItemY();
+ }
+
+ int SettingPresenter::GetListItemNum()
+ {
+ return settingModel->GetSettingListNum();
+ }
+
void SettingPresenter::OnStart()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnStart");
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-07-12 09:55:29
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-22 18:30:57
+ * @LastEditTime: 2024-09-18 10:49:14
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp
*/
static constexpr int16 LIST_POS = 20;
static constexpr int16 SNUM_2 = 2;
static constexpr int16 ROLLSPEED = 70;
- static constexpr int16 REBOUNDSIZE = 35;
+ static constexpr int16 REBOUNDSIZE = 30;
SettingView::SettingView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::contentList is nullptr");
return;
}
- contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y, 380, 400);
+ contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y, 380, 360);
contentList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- contentList->SetScrollBlankSize(75);
- // contentList->SetSelectPosition(820 / SNUM_2); // middle position
+ contentList->SetScrollBlankSize(30);
contentList->SetDraggable(true);
contentList->SetThrowDrag(true);
contentList->EnableAutoAlign(true);
contentList->SetReboundSize(REBOUNDSIZE);
contentList->SetMaxScrollDistance(MAX_SCR_DIS);
+ contentList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/
contentList->RequestFocus();
- contentList->SetRotateFactor(2);
+ contentList->SetRotateFactor(1.0);
+ /* ----------------------------------- Add ---------------------------------- */
+ scrollView->Add(title);
+ scrollView->Add(contentList);
+ container_->Add(scrollView);
}
void SettingView::OnStart()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnSetUpView");
View<SettingPresenter>::OnSetUpView();
- if (scrollView == nullptr || contentList == nullptr || listAdapter == nullptr || title == nullptr)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnSetUpView has nullptr");
- return;
- }
- scrollView->Add(title);
- scrollView->Add(contentList);
- contentList->SetAdapter(listAdapter);
- container_->Add(scrollView);
+ settingListOnSetUpView();
Draw();
return;
}
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStop");
View<SettingPresenter>::OnStop();
RootView::GetInstance()->ClearOnKeyActListener();
+ settingListOnStop();
ClearAll();
return;
}
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::AddSettingItemToList");
listAdapter->AddListItem(item);
}
+
+ void SettingView::settingListOnSetUpView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::settingListOnSetUpView");
+ if (contentList == nullptr || listAdapter == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::settingListOnSetUpView fail!!");
+ return;
+ }
+ uint16_t startIndex = 0;
+ int16_t headY = 0;
+ int NUM_2 = 2;
+ int screen_h = Screen::GetInstance().GetHeight();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetStartIndex = %d,GetListItemNum = %d", presenter_->GetStartIndex(), presenter_->GetListItemNum());
+ if (presenter_->GetStartIndex() >= presenter_->GetListItemNum())
+ {
+ startIndex = presenter_->GetListItemNum() - 1;
+ headY = screen_h / NUM_2;
+ }
+ else
+ {
+ uint16_t presliceId = NativeAbility::GetInstance().GetPreSliceId();
+ if (presliceId == VIEW_MAIN)
+ {
+ startIndex = 0;
+ headY = 0;
+ }
+ else
+ {
+ startIndex = presenter_->GetStartIndex();
+ headY = presenter_->GetHeadItemY();
+ }
+ if (headY == 0)
+ {
+ headY = screen_h / NUM_2;
+ }
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startIndex = %d,headY = %d", startIndex, headY);
+ contentList->SetStartIndex(startIndex);
+ contentList->SetAdapter(listAdapter);
+ contentList->RefreshList();
+ contentList->ScrollBy(headY);
+ }
+
+ void SettingView::settingListOnStop(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::settingListOnStop");
+ int16_t listHeadY = contentList->GetChildrenHead()->GetY();
+ int16_t listHeadIndex = contentList->GetChildrenHead()->GetViewIndex();
+ presenter_->SetHeadItemY(listHeadY);
+ presenter_->SetStartIndex(listHeadIndex);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listHeadY = %d,listHeadIndex = %d", listHeadY, listHeadIndex);
+ }
}