#717,解决,设置界面向上滑有黑色空白,需优化bug
authorluozheng <1732036298@qq.com>
Wed, 18 Sep 2024 03:00:05 +0000 (11:00 +0800)
committerluozheng <1732036298@qq.com>
Wed, 18 Sep 2024 03:00:05 +0000 (11:00 +0800)
code/sdk/application/wearable/fd230app/nativeui/settings/include/SettingModel.h
code/sdk/application/wearable/fd230app/nativeui/settings/include/SettingPresenter.h
code/sdk/application/wearable/fd230app/nativeui/settings/include/SettingView.h
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingAdapter.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp

index fde1d10..c8a4cd8 100644 (file)
@@ -2,7 +2,7 @@
  * @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
  */
 
@@ -27,6 +27,10 @@ namespace OHOS
         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);
@@ -41,6 +45,8 @@ namespace OHOS
         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};
index fe56928..c29e368 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-02-19 11:58:05
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-22 11:05:00
+ * @LastEditTime: 2024-09-14 20:14:00
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/include/SettingPresenter.h
  */
 #ifndef SETTING_PRESENTER_H
@@ -24,7 +24,11 @@ namespace OHOS
         SettingPresenter();
         ~SettingPresenter() override;
         static SettingPresenter *GetInstance();
-
+        void SetStartIndex(uint16_t index);
+        uint16_t GetStartIndex(void);
+        void SetHeadItemY(int y);
+        int GetHeadItemY(void);
+        int GetListItemNum();
 
         void OnStart() override;
         void OnResume() override;
index 02d1af3..9f442dc 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-30 09:14:38
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-22 11:13:50
+ * @LastEditTime: 2024-09-14 20:06:44
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/include/SettingView.h
  */
 #ifndef SETTING_VIEW_H
@@ -36,6 +36,8 @@ namespace OHOS
     private:
         void CreateSettingView(void);
         void ClearAll(void);
+        void settingListOnSetUpView(void);
+        void settingListOnStop(void);
         SettingAdapter *listAdapter{nullptr};
         UIScrollView *scrollView{nullptr};
         UIList *contentList{nullptr};
index 5ee4337..5f4ba08 100644 (file)
@@ -2,10 +2,11 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-01-29 15:37:44
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-07 20:11:17
+ * @LastEditTime: 2024-09-14 21:19:30
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingAdapter.cpp
  */
-#include "SettingAdapter.h"
+// #include "SettingAdapter.h"
+#include "settings/include/SettingAdapter.h"
 namespace OHOS
 {
     SettingAdapter::SettingAdapter() {}
@@ -77,6 +78,7 @@ namespace OHOS
         {
             item->GetNeedToUpdateImage()->SetVisible(false);
         }
+        item->SetViewIndex(index);
         return item;
     }
 
index 4706486..06680a9 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-27 19:48:49
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-11 16:46:26
+ * @LastEditTime: 2024-09-18 10:12:06
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp
  */
 
@@ -19,7 +19,7 @@ namespace OHOS
     static constexpr int16_t SETTINGLABELEXT_X = 115;
     static constexpr int16_t SETTINGLABELEXT_Y = 33;
     static constexpr int16_t SETTINGLABELEXT_W = 180;
-    static constexpr int16_t SETTINGLABELEXT_H = 40;
+    static constexpr int16_t SETTINGLABELEXT_H = 35;
     static constexpr int16_t SETTINGLABELEXT_TEXT_FONT = 30;
     static constexpr int16_t SETTINGLABELEXT_LINE_HEIGHT = 35;
     static constexpr int16_t SETTINGLABELEXT_ROLLSPEED = 70;
index d9b0e04..1bfbc36 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-02-18 09:09:13
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-11 16:52:29
+ * @LastEditTime: 2024-09-14 19:58:19
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp
  */
 #include "settings/include/SettingModel.h"
@@ -45,6 +45,26 @@ namespace OHOS
         usedLen = index;
     }
 
+    void SettingModel::SetStartIndex(uint16_t index)
+    {
+        startIndex = index;
+    }
+
+    uint16_t SettingModel::GetStartIndex(void)
+    {
+        return startIndex;
+    }
+
+    void SettingModel::SetHeadItemY(int y)
+    {
+        headItemY = y;
+    }
+
+    int SettingModel::GetHeadItemY(void)
+    {
+        return headItemY;
+    }
+
     const SettingItem *SettingModel::GetSettinglistItems() const
     {
         return settings;
index dffffff..0986f91 100644 (file)
@@ -2,7 +2,7 @@
  * @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
  */
 /*
@@ -45,6 +45,31 @@ namespace OHOS
         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");
index 94efc0b..e6a2827 100644 (file)
@@ -2,7 +2,7 @@
  * @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
  */
 
@@ -28,7 +28,7 @@ namespace OHOS
     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()
     {
@@ -125,17 +125,21 @@ namespace OHOS
             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()
@@ -163,15 +167,7 @@ namespace OHOS
     {
         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;
     }
@@ -188,6 +184,7 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStop");
         View<SettingPresenter>::OnStop();
         RootView::GetInstance()->ClearOnKeyActListener();
+        settingListOnStop();
         ClearAll();
         return;
     }
@@ -197,4 +194,57 @@ namespace OHOS
         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);
+    }
 }