优化星历下载
authorCaisking <Casiking@zhihuishixun.com>
Fri, 31 Oct 2025 13:36:53 +0000 (21:36 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Fri, 31 Oct 2025 13:36:53 +0000 (21:36 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp

index db3993c..27272f1 100644 (file)
@@ -93,8 +93,9 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() == 0)
         {
-            EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-                "正在链接网络");
+            EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText("正在链接网络");
+            //设置下载按键
+            EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() > 0)
         {
@@ -106,6 +107,8 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
             }
             std::string progress_str = "正在下载"+std::to_string(progress)+"%";
             EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(progress_str.c_str());
+            //设置下载按键
+            EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() == 10)
         {
@@ -123,6 +126,8 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
       if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
         EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
             "下载成功");
+        //设置下载按键
+        EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
       }
       //更新有效期
       if(EphemerisDownloadView::GetInstance()->GetValidityPeriodLabel()) {
@@ -134,19 +139,13 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
   case EphemerisDownloadStatus::FAILED:
     if (EphemerisDownloadView::GetInstance()) {
       if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
-        EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-            "下载失败");
+        EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText("下载失败");
       }
+      //设置下载按键
+      EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
     }
-    break;
-  // case EphemerisDownloadStatus::NOT_DOWNLOADED:
-  //   if (EphemerisDownloadView::GetInstance()) {
-  //     if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
-  //       EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-  //           "未下载");
-  //     }
-  //   }
-  //   break;
+    default:
+      break;
   }
 }
 
index ba6efdb..c21482e 100644 (file)
@@ -189,23 +189,14 @@ UILabelExt *EphemerisDownloadView::GetValidityPeriodLabel() {
 // 更新下载状态显示
 void EphemerisDownloadView::UpdateDownloadStatus() {
     if (labelStatusValue_ == nullptr) return;
-    
-    auto status = EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus();
-    int progress = EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress();
-    
-    switch (status) {
-        case EphemerisDownloadStatus::NOT_DOWNLOADED:
-            labelStatusValue_->SetText("未下载");
-            break;
-        case EphemerisDownloadStatus::DOWNLOADING:
-            labelStatusValue_->SetText(("下载中 " + std::to_string(progress) + "%").c_str());
-            break;
-        case EphemerisDownloadStatus::DOWNLOADED:
-            labelStatusValue_->SetText("已完成");
-            break;
-        case EphemerisDownloadStatus::FAILED:
-            labelStatusValue_->SetText("下载失败");
-            break;
+    //如果有效期大于0,则显示下载成功
+    if(EphemerisDownloadModel::GetInstance().GetValidityPeriod())
+    {
+        labelStatusValue_->SetText("数据有效");
+    }
+    else
+    {
+        labelStatusValue_->SetText("未下载");
     }
 }
 
@@ -231,17 +222,17 @@ void EphemerisDownloadView::UpdateDownloadButton() {
         case EphemerisDownloadStatus::NOT_DOWNLOADED:
         case EphemerisDownloadStatus::FAILED:
             btnDownload_->SetText("未下载");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0xff, 0x8c, 0x00, 0xff).full); // 橙色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); // 蓝色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0xcc, 0x70, 0x00, 0xff).full, UIButton::PRESSED);
             break;
         case EphemerisDownloadStatus::DOWNLOADING:
             btnDownload_->SetText("下载中");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff).full); // 灰色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); // 灰色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x44, 0x44, 0x44, 0xff).full, UIButton::PRESSED);
             break;
         case EphemerisDownloadStatus::DOWNLOADED:
             btnDownload_->SetText("已下载");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff).full); // 灰色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); // 绿色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x44, 0x44, 0x44, 0xff).full, UIButton::PRESSED);
             break;
     }
index db3993c..27272f1 100644 (file)
@@ -93,8 +93,9 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() == 0)
         {
-            EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-                "正在链接网络");
+            EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText("正在链接网络");
+            //设置下载按键
+            EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() > 0)
         {
@@ -106,6 +107,8 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
             }
             std::string progress_str = "正在下载"+std::to_string(progress)+"%";
             EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(progress_str.c_str());
+            //设置下载按键
+            EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() == 10)
         {
@@ -123,6 +126,8 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
       if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
         EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
             "下载成功");
+        //设置下载按键
+        EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
       }
       //更新有效期
       if(EphemerisDownloadView::GetInstance()->GetValidityPeriodLabel()) {
@@ -134,19 +139,13 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
   case EphemerisDownloadStatus::FAILED:
     if (EphemerisDownloadView::GetInstance()) {
       if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
-        EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-            "下载失败");
+        EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText("下载失败");
       }
+      //设置下载按键
+      EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
     }
-    break;
-  // case EphemerisDownloadStatus::NOT_DOWNLOADED:
-  //   if (EphemerisDownloadView::GetInstance()) {
-  //     if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
-  //       EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-  //           "未下载");
-  //     }
-  //   }
-  //   break;
+    default:
+      break;
   }
 }
 
index ba6efdb..c21482e 100644 (file)
@@ -189,23 +189,14 @@ UILabelExt *EphemerisDownloadView::GetValidityPeriodLabel() {
 // 更新下载状态显示
 void EphemerisDownloadView::UpdateDownloadStatus() {
     if (labelStatusValue_ == nullptr) return;
-    
-    auto status = EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus();
-    int progress = EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress();
-    
-    switch (status) {
-        case EphemerisDownloadStatus::NOT_DOWNLOADED:
-            labelStatusValue_->SetText("未下载");
-            break;
-        case EphemerisDownloadStatus::DOWNLOADING:
-            labelStatusValue_->SetText(("下载中 " + std::to_string(progress) + "%").c_str());
-            break;
-        case EphemerisDownloadStatus::DOWNLOADED:
-            labelStatusValue_->SetText("已完成");
-            break;
-        case EphemerisDownloadStatus::FAILED:
-            labelStatusValue_->SetText("下载失败");
-            break;
+    //如果有效期大于0,则显示下载成功
+    if(EphemerisDownloadModel::GetInstance().GetValidityPeriod())
+    {
+        labelStatusValue_->SetText("数据有效");
+    }
+    else
+    {
+        labelStatusValue_->SetText("未下载");
     }
 }
 
@@ -231,17 +222,17 @@ void EphemerisDownloadView::UpdateDownloadButton() {
         case EphemerisDownloadStatus::NOT_DOWNLOADED:
         case EphemerisDownloadStatus::FAILED:
             btnDownload_->SetText("未下载");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0xff, 0x8c, 0x00, 0xff).full); // 橙色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); // 蓝色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0xcc, 0x70, 0x00, 0xff).full, UIButton::PRESSED);
             break;
         case EphemerisDownloadStatus::DOWNLOADING:
             btnDownload_->SetText("下载中");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff).full); // 灰色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); // 灰色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x44, 0x44, 0x44, 0xff).full, UIButton::PRESSED);
             break;
         case EphemerisDownloadStatus::DOWNLOADED:
             btnDownload_->SetText("已下载");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff).full); // 灰色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); // 绿色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x44, 0x44, 0x44, 0xff).full, UIButton::PRESSED);
             break;
     }
index db3993c..27272f1 100644 (file)
@@ -93,8 +93,9 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() == 0)
         {
-            EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-                "正在链接网络");
+            EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText("正在链接网络");
+            //设置下载按键
+            EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() > 0)
         {
@@ -106,6 +107,8 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
             }
             std::string progress_str = "正在下载"+std::to_string(progress)+"%";
             EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(progress_str.c_str());
+            //设置下载按键
+            EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
         }
         else if(EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress() == 10)
         {
@@ -123,6 +126,8 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
       if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
         EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
             "下载成功");
+        //设置下载按键
+        EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
       }
       //更新有效期
       if(EphemerisDownloadView::GetInstance()->GetValidityPeriodLabel()) {
@@ -134,19 +139,13 @@ void EphemerisDownloadPresenter::UpdateDownloadStatus() {
   case EphemerisDownloadStatus::FAILED:
     if (EphemerisDownloadView::GetInstance()) {
       if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
-        EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-            "下载失败");
+        EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText("下载失败");
       }
+      //设置下载按键
+      EphemerisDownloadView::GetInstance()->UpdateDownloadButton();
     }
-    break;
-  // case EphemerisDownloadStatus::NOT_DOWNLOADED:
-  //   if (EphemerisDownloadView::GetInstance()) {
-  //     if (EphemerisDownloadView::GetInstance()->GetDownloadLabel()) {
-  //       EphemerisDownloadView::GetInstance()->GetDownloadLabel()->SetText(
-  //           "未下载");
-  //     }
-  //   }
-  //   break;
+    default:
+      break;
   }
 }
 
index ba6efdb..c21482e 100644 (file)
@@ -189,23 +189,14 @@ UILabelExt *EphemerisDownloadView::GetValidityPeriodLabel() {
 // 更新下载状态显示
 void EphemerisDownloadView::UpdateDownloadStatus() {
     if (labelStatusValue_ == nullptr) return;
-    
-    auto status = EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus();
-    int progress = EphemerisDownloadModel::GetInstance().GetEphemerisDownloadProgress();
-    
-    switch (status) {
-        case EphemerisDownloadStatus::NOT_DOWNLOADED:
-            labelStatusValue_->SetText("未下载");
-            break;
-        case EphemerisDownloadStatus::DOWNLOADING:
-            labelStatusValue_->SetText(("下载中 " + std::to_string(progress) + "%").c_str());
-            break;
-        case EphemerisDownloadStatus::DOWNLOADED:
-            labelStatusValue_->SetText("已完成");
-            break;
-        case EphemerisDownloadStatus::FAILED:
-            labelStatusValue_->SetText("下载失败");
-            break;
+    //如果有效期大于0,则显示下载成功
+    if(EphemerisDownloadModel::GetInstance().GetValidityPeriod())
+    {
+        labelStatusValue_->SetText("数据有效");
+    }
+    else
+    {
+        labelStatusValue_->SetText("未下载");
     }
 }
 
@@ -231,17 +222,17 @@ void EphemerisDownloadView::UpdateDownloadButton() {
         case EphemerisDownloadStatus::NOT_DOWNLOADED:
         case EphemerisDownloadStatus::FAILED:
             btnDownload_->SetText("未下载");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0xff, 0x8c, 0x00, 0xff).full); // 橙色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); // 蓝色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0xcc, 0x70, 0x00, 0xff).full, UIButton::PRESSED);
             break;
         case EphemerisDownloadStatus::DOWNLOADING:
             btnDownload_->SetText("下载中");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff).full); // 灰色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); // 灰色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x44, 0x44, 0x44, 0xff).full, UIButton::PRESSED);
             break;
         case EphemerisDownloadStatus::DOWNLOADED:
             btnDownload_->SetText("已下载");
-            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff).full); // 灰色
+            btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); // 绿色
             btnDownload_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA(0x44, 0x44, 0x44, 0xff).full, UIButton::PRESSED);
             break;
     }