#642,解决:删除多余闹钟后,界面不能显示剩余闹钟bug
authorluozheng <1732036298@qq.com>
Wed, 11 Sep 2024 06:55:19 +0000 (14:55 +0800)
committerluozheng <1732036298@qq.com>
Wed, 11 Sep 2024 06:55:19 +0000 (14:55 +0800)
code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h
code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp

index 8b8b1e0..f6ff00d 100644 (file)
@@ -35,7 +35,7 @@
 namespace OHOS {
 constexpr int16_t D_CLOCK_Y = 210;
 constexpr int16_t LABEL_ZERO_Y = 270;
-constexpr int16_t ALARM_INTER_ADD = 130; // 130;
+constexpr int16_t ALARM_INTER_ADD = 120; // 120;
 
 class AlarmPresenter;
 class MainAlarmView : public View<AlarmPresenter> {
index 86e00a1..e4742a8 100644 (file)
@@ -235,14 +235,29 @@ void MainAlarmView::AlarmAddButtonUpdate(uint8_t count)
     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: is_up_drag       = %d", __LINE__, is_up_drag);
     // // group->ScrollBy(0, is_up_drag ? - 120 : 120);
     // group->Invalidate();
-    if(nullptr == AddButton_)
+    if(nullptr == AddButton_ || TitleLabelExt_ == nullptr)
         return; 
-
-    // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: 0_y=%d", __LINE__, SwipeView_[0]->GetY());
-    AddButton_->SetY((0 == count) ? (Screen::GetInstance().GetHeight() / 2 - 50) : (SwipeView_[0]->GetY() + (alarmInterval * count)));
-    // if(group) {
-    //     group->ScrollBy(0, ADD_BUTTON_Y - AddButton_->GetY());
-    // }
+    int bef_y = 0;
+    int aft_y = 0;
+    // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: 0_y=%d", __LINE__, Screen::GetInstance().GetHeight() / 2);
+    // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: 0_y=%d", __LINE__, TitleLabelExt_->GetHeight());
+    bef_y = AddButton_->GetY();
+    if((0 == count))
+    {
+        TitleLabelExt_->SetY(50);
+        AddButton_->SetY(120);
+    }
+    else
+    {
+        if(SwipeView_[0]) {
+            AddButton_->SetY(SwipeView_[0]->GetY() + (alarmInterval * count));
+        }
+    }
+    aft_y = AddButton_->GetY();
+    bool is_up_drag = bef_y- aft_y > 0 ? false:true;
+    if(group) {
+        group->ScrollBy(0, is_up_drag ? - 120 : 120);
+    }
     RootView::GetInstance()->Invalidate();
 }
 
@@ -451,14 +466,15 @@ void MainAlarmView::OnStart()
     // 增加按键监听
     RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::AlarmPresenter::GetInstance();
     RootView::GetInstance()->SetOnKeyActListener(keyactListener);
-    group = new UIScrollView();
     if (group == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainAlarmView:: new group fail");
-        return;
+        group = new UIScrollView();
+        if (group == nullptr) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainAlarmView:: new group fail");
+            return;
+        }
     }
     // group->SetPosition(CONTAINER_X, CONTAINER_Y, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
     group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
-    UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::AlarmPresenter::GetInstance();
     group->SetScrollBlankSize(50);
     // group->SetMaxScrollDistance(1000); // 1000: max scroll distance
     // group->SetSwipeACCLevel(800);      // 800: compensation distance