优化不必要的设置
authorCaisking <3449750381@qq.com>
Fri, 21 Jun 2024 09:17:41 +0000 (17:17 +0800)
committerCaisking <3449750381@qq.com>
Fri, 21 Jun 2024 09:17:41 +0000 (17:17 +0800)
code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageAdapter.cpp
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp
code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp

index ea3aba4..c165cce 100644 (file)
@@ -1,7 +1,7 @@
 /*** 
  * @Date: 2024-04-15 10:55:58
  * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-06-19 17:38:19
+ * @LastEditTime: 2024-06-21 17:13:44
  * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h
  */
 /***
@@ -62,7 +62,6 @@ namespace OHOS
         bool SetupViewPage(MessageView *messageView);
 
     private:
-        UIScrollView *container_ = nullptr;
 
         /*无消息界面*/
         UIScrollView *lackView{nullptr};
index 4ca0785..9b05ec7 100644 (file)
@@ -2,8 +2,8 @@
  * @Author: Caisking 3449750381@qq.com
  * @Date: 2024-01-29 19:58:37
  * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-26 18:16:05
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/message/src/MessageAdapter.cpp
+ * @LastEditTime: 2024-06-21 10:35:36
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageAdapter.cpp
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
 
@@ -79,6 +79,7 @@ namespace OHOS
             item = static_cast<MessageItemView *>(inView);
         }
         item->SetItemInfo(itemData);
+        item->SetViewIndex(index);
         item->SetOnClickListener(itemClickListener);
         return item;
     }
index 974b77e..f43b380 100644 (file)
@@ -91,23 +91,17 @@ namespace OHOS
         sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
 
         stitle.SetPosition(60, 31, 280, 35);
-        stitle.SetStyle(STYLE_TEXT_FONT, 30);
-        stitle.SetStyle(STYLE_LINE_HEIGHT, 36);
-        stitle.SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
-        stitle.SetRollSpeed(30);
         stitle.SetTextColor(Color::White());
         stitle.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        stitle.SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+        stitle.SetRollSpeed(30);
 
         smessgae.SetPosition(40, 69, 300, label_length);
-        smessgae.SetStyle(STYLE_TEXT_FONT, 30);
-        smessgae.SetStyle(STYLE_LINE_HEIGHT, 36);
         smessgae.SetLineBreakMode(UILabel::LINE_BREAK_CLIP);
-        smessgae.SetTextColor(Color::Gray());
+        smessgae.SetTextColor(Color::Gray());      
         smessgae.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
 
         stime.SetPosition(40, time_top, 300, 33);
-        stime.SetStyle(STYLE_TEXT_FONT, 30);
-        stime.SetStyle(STYLE_LINE_HEIGHT, 36);
         stime.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
         stime.SetTextColor(Color::Gray());
         stime.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28);
index 4fcdaf3..2043ac7 100644 (file)
@@ -52,7 +52,6 @@ namespace OHOS
 
     void MessagePresenter::OnStart()
     {
-
         // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitMessageListItem");
         p_MessageModel->InitMessageListItems();
         Presenter<MessageView>::OnStart();
@@ -62,13 +61,14 @@ namespace OHOS
     {
         Presenter<MessageView>::OnPause();
     }
-
     void MessagePresenter::OnResume(void)
     {
         if (view_ == nullptr)
         {
             return;
         }
+
+        // p_MessageModel->InitMessageListItems();
         if (p_MessageModel->GetPopupViewState())
         {
             const MessageListItem *itemInfo = p_MessageModel->GetMessageListItems();
@@ -77,6 +77,7 @@ namespace OHOS
                 view_->AddMessageToList(itemInfo[i]);
             }
         }
+
         Presenter<MessageView>::OnResume();
     }
 
index 824a597..7a8e383 100644 (file)
@@ -19,7 +19,7 @@ namespace OHOS
     static constexpr int16 LIST_POS = 20;
     static constexpr int16 SNUM_2 = 2;
     static constexpr uint8_t NUM_2 = 2;
-    
+
     static MessageView *g_pMessageView{nullptr};
 
     MessageView::MessageView()
@@ -63,7 +63,6 @@ namespace OHOS
     }
     void MessageView::DeInitView()
     {
-        container_->RemoveAll();
         lackView->RemoveAll();
         messageView->RemoveAll();
         MessageList->RemoveAll();
@@ -115,12 +114,6 @@ namespace OHOS
             delete messageView;
             messageView = nullptr;
         }
-        if (container_ != nullptr)
-        {
-            container_->RemoveAll();
-            delete container_;
-            container_ = nullptr;
-        }
         delete draglistener;
         draglistener = nullptr;
     }
@@ -252,39 +245,15 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL");
             return;
         }
-        if (container_ != nullptr)
-        {
-            container_->SetVisible(!status);
-        }
         popupView->SetVisible(status);
     }
 
     /// @brief 页面启动时需要执行的代码逻辑
     void MessageView::OnStart()
     {
-        container_ = new UIScrollView();
-        if (container_ == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail");
-            return;
-        }
-        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(MessagePresenter::GetInstance());
-        if (draglistener == nullptr)
-        {
-            return;
-        }
-        container_->SetOnDragListener(draglistener);
-        container_->SetTouchable(true);
-        container_->SetDraggable(true);
-        container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR);
-        container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
-
         ShowLackView();
         ShowMessageView();
         PreLoad();
-        RootView::GetInstance()->Add(container_);
     }
     void MessageView::AddMessageToList(const MessageListItem &item)
     {
@@ -303,10 +272,8 @@ namespace OHOS
         {
             messageView->Add(MessageList);
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageList is add");
-            messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
             RootView::GetInstance()->Add(messageView);
             MessageList->SetAdapter(p_MessageListAdapter);
-            MessageList->RefreshList(); // 刷新列表
         }
         Draw();
     }