增加自定义表盘配置
authorCaisking <Casiking@zhihuishixun.com>
Tue, 29 Jul 2025 08:31:51 +0000 (16:31 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 29 Jul 2025 08:31:51 +0000 (16:31 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/include/MainClockView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/MainClockView.cpp

index 5567c4f..f517a09 100644 (file)
  * Create: 2021-10-18
  */
 
- #ifndef MAIN_CLOCK_VIEW_H
- #define MAIN_CLOCK_VIEW_H
- 
- #include <string>
+#ifndef MAIN_CLOCK_VIEW_H
+#define MAIN_CLOCK_VIEW_H
+
+#include <cstdint>
+#include <string>
  #include <time.h>
- #include "View.h"
- #include "components/ui_view_group.h"
- #include "components/ui_image_view.h"
- #include "components/ui_label.h"
- #include "components/ui_label_ext.h"
- #include "components/ui_label_button.h"
- #include "components/ui_box_progress.h"
- #include "components/ui_image_animator.h"
- #include "components/root_view.h"
- 
- #include "components/ui_sweep_clock.h"
- #include "ChangeSliceListener.h"
- #include "font/ui_font_bitmap.h"
- #include "font/ui_font.h"
- #include "graphic_config.h"
- #include "HealthModel.h"
- #include "ActivityModel.h"
- #include "UiConfig.h"
- #include "components/ui_card_page.h"
- #include "animator/animator_manager.h"
- #include "time.h"
- #include "sys/time.h"
- 
- namespace OHOS
- {
-     /*表盘颜色配置*/
-     enum ColorTypeSet
-     {
-         COLOR_WHITE = 0,
-         COLOR_BLACK,
-         COLOR_GRAY,
-         COLOR_GREEN,
-         COLOR_ORANGE,
-         COLOR_BLUE,
-         COLOR_DEFAULT = COLOR_WHITE // 默认颜色
-     };
-     /*表盘电量配置*/
-     enum BatteryDisplayType
-     {
-         BATTERY_DISPLAY_NONE = 0,                       // 不显示图标
-         BATTERY_DISPLAY_BLACK,                          // 显示黑色
-         BATTERY_DISPLAY_WHITE,                          // 显示白色
-         BATTERY_DISPLAY_DEFAULT = BATTERY_DISPLAY_WHITE // 默认:白色
-     };
-     /*表盘时间配置*/
-     enum TimeDisplayPosition
-     {
-         TIME_DISPLAY_BELOW = 0,                   // 显示在表盘下方
-         TIME_DISPLAY_ABOVE,                       // 显示在表盘上方
-         TIME_DISPLAY_DEFAULT = TIME_DISPLAY_BELOW // 默认:下方
-     };
- 
-     class MainClockView : public UICardPage
-     {
-     public:
-         MainClockView();
-         virtual ~MainClockView();
-         static MainClockView *GetInstance(void);
-         bool InitView(void);
-         void PreLoad(void) override;
-         void UnLoad(void) override;
-         /*刷新数据*/
-         void RefreshStep(int step);
-         void RefreshHeartRate(int value);
-         void ClockAnimatorStart(void);
-         void ClockAnimatorStop(void);
-         /*更新数据*/
-         void UpdateTime(void);
-         void UpdataBattery(void);
-         void SetViewColor(int64_t color);
-         void UpdateBatteryColor(void);
-         /*配置文件*/
-         void SetDialPath(std::string dialpath);
- 
-         /*配置自定义表盘*/
-         void SetCustomId(int Id);
- 
-         /*配置函数*/
-         bool InitBackground(const char *filename);
-         bool InitTimeView(TimeDisplayPosition type);   // 时间
-         bool InitBatteryView(BatteryDisplayType type); // 电量
-         bool InitColor(ColorTypeSet type);             // 颜色
-         void SetLabelsColor(ColorType color);
- 
-         void UpdateStateShow(void);
- 
-     private:
-         void InitStepValue();
-         bool InitLabelView(void);
-         bool InitCenterCircleView(void);
-         bool InitHandView(void);
-         void InitDateTime(void);
-         bool InitClock(void);
-         bool LoadClockImage(Image *view, uint32_t resId);
-         bool LoadClockImage(UIImageView *view, uint32_t resId);
- 
-         /*表盘背景*/
-         UIImageView *curFace{nullptr};
-         
-         /*时间相关*/
-         UILabel *timerlabel{nullptr};
-         UILabel *weekLabel{nullptr};
-         UILabel *datelabel{nullptr};
- 
-         /*电量相关*/
-         UIImageView *batteryiamge{nullptr};
-         UIBoxProgress *batteryprogress{nullptr};
-         UILabel *batterylabel{nullptr};
-         UIImageView *batteryicon{nullptr};
- 
-         /*数据相关*/
-         UILabel *stepLabel{nullptr};
-         UILabel *heartlabel{nullptr};
- 
-         /*指针表盘相关 暂不使用*/
-         UISweepClock *mainSweepClock{nullptr};
-         Image *secondHand{nullptr};
-         Image *minuteHand{nullptr};
-         Image *hourHand{nullptr};
-         UIImageView *heartRate{nullptr};
-         Image *hand24Hour{nullptr};
-         UIImageView *weekDay{nullptr};
-         UIImageView *progress{nullptr};
-         Image *bigCircle{nullptr};
-         Image *medCircle{nullptr};
-         Image *smallCircle{nullptr};
- 
-         UIImageView *dialstateicon_{nullptr}; // 勿扰
-         UIImageView *messageicon_{nullptr};   // 未读图标   
- 
-         bool viewiInitStatus{false};
-         bool resLoadStatus{false};
- 
-         std::string dialFile;                                     // 表盘背景文件名
-         ColorTypeSet colorType = COLOR_DEFAULT;                   // 颜色类型
-         BatteryDisplayType batterySetting = BATTERY_DISPLAY_NONE; // 电池设置
-         TimeDisplayPosition timePosition = TIME_DISPLAY_DEFAULT;  // 时间位置
-         int64_t color_ = Color::White().full;                     // 电量颜色
-         int32_t power_ = -1;                                      // 电量
-         bool isBatteryIconVisible{false};                         // 电池暂停
-     };
- } // namespace OHOS
- #endif // MAIN_CLOCK_VIEW_H
- 
\ No newline at end of file
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_label_button.h"
+#include "components/ui_box_progress.h"
+#include "components/ui_image_animator.h"
+#include "components/root_view.h"
+
+#include "components/ui_sweep_clock.h"
+#include "ChangeSliceListener.h"
+#include "font/ui_font_bitmap.h"
+#include "font/ui_font.h"
+#include "graphic_config.h"
+#include "HealthModel.h"
+#include "ActivityModel.h"
+#include "UiConfig.h"
+#include "components/ui_card_page.h"
+#include "animator/animator_manager.h"
+#include "time.h"
+#include "sys/time.h"
+#include "components/ui_lite_surface_view.h"
+#include "video_play_wrapper.h"
+#include "DialVideoView.h"
+
+namespace OHOS
+{
+    /*表盘颜色配置*/
+    enum ColorTypeSet
+    {
+        COLOR_WHITE = 0,
+        COLOR_BLACK,
+        COLOR_GRAY,
+        COLOR_GREEN,
+        COLOR_ORANGE,
+        COLOR_BLUE,
+        COLOR_DEFAULT = COLOR_WHITE // 默认颜色
+    };
+    /*表盘电量配置*/
+    enum BatteryDisplayType
+    {
+        BATTERY_DISPLAY_NONE = 0,                       // 不显示图标
+        BATTERY_DISPLAY_BLACK,                          // 显示黑色
+        BATTERY_DISPLAY_WHITE,                          // 显示白色
+        BATTERY_DISPLAY_DEFAULT = BATTERY_DISPLAY_WHITE // 默认:白色
+    };
+    /*表盘时间配置*/
+    enum TimeDisplayPosition
+    {
+        TIME_DISPLAY_BELOW = 0,                   // 显示在表盘下方
+        TIME_DISPLAY_ABOVE,                       // 显示在表盘上方
+        TIME_DISPLAY_DEFAULT = TIME_DISPLAY_BELOW // 默认:下方
+    };
+
+    class MainClockView : public UICardPage 
+    {
+    public:
+        MainClockView();
+        virtual ~MainClockView();
+        static MainClockView *GetInstance(void);
+        bool InitView(void);
+        void PreLoad(void) override;
+        void UnLoad(void) override;
+        /*刷新数据*/
+        void RefreshStep(int step);
+        void RefreshHeartRate(int value);
+        void ClockAnimatorStart(void);
+        void ClockAnimatorStop(void);
+        /*更新数据*/
+        void UpdateTime(void);
+        void UpdataBattery(void);
+        void SetViewColor(int64_t color);
+        void UpdateBatteryColor(void);
+        /*配置文件*/
+        void SetDialPath(std::string dialpath);
+
+        /*配置自定义表盘*/
+        void SetCustomId(int Id);
+
+        /*配置函数*/
+        bool InitBackground(const char *filename);
+        bool InitTimeView(TimeDisplayPosition type);   // 时间
+        bool InitBatteryView(BatteryDisplayType type); // 电量
+        bool InitColor(ColorTypeSet type);             // 颜色
+        void SetLabelsColor(ColorType color);
+
+        void UpdateStateShow(void);
+
+
+        void ScrollBegin(bool isActive) override;
+        void ScrollEnd(bool isActive) override;
+        void CoverBegin(bool isCovered) override;
+        void CoverEnd(bool isCovered) override;
+        void OnActive(void) override;
+        void OnInactive(void) override;
+
+    private:
+        void InitStepValue();
+        bool InitLabelView(void);
+        bool InitCenterCircleView(void);
+        bool InitHandView(void);
+        void InitDateTime(void);
+        bool InitClock(void);
+        bool LoadClockImage(Image *view, uint32_t resId);
+        bool LoadClockImage(UIImageView *view, uint32_t resId);
+
+        /*表盘背景*/
+        UIImageView *curFace{nullptr};
+        DialVideoView* videoPlayer_ = nullptr;
+        UILiteSurfaceView *surfaceView_ = nullptr;
+        
+        /*时间相关*/
+        UILabel *timerlabel{nullptr};
+        UILabel *weekLabel{nullptr};
+        UILabel *datelabel{nullptr};
+
+        /*电量相关*/
+        UIImageView *batteryiamge{nullptr};
+        UIBoxProgress *batteryprogress{nullptr};
+        UILabel *batterylabel{nullptr};
+        UIImageView *batteryicon{nullptr};
+
+        /*数据相关*/
+        UILabel *stepLabel{nullptr};
+        UILabel *heartlabel{nullptr};
+
+        /*指针表盘相关 暂不使用*/
+        UISweepClock *mainSweepClock{nullptr};
+        Image *secondHand{nullptr};
+        Image *minuteHand{nullptr};
+        Image *hourHand{nullptr};
+        UIImageView *heartRate{nullptr};
+        Image *hand24Hour{nullptr};
+        UIImageView *weekDay{nullptr};
+        UIImageView *progress{nullptr};
+        Image *bigCircle{nullptr};
+        Image *medCircle{nullptr};
+        Image *smallCircle{nullptr};
+
+        UIImageView *dialstateicon_{nullptr}; // 勿扰
+        UIImageView *messageicon_{nullptr};   // 未读图标   
+
+        bool viewiInitStatus{false};
+        bool resLoadStatus{false};
+
+        std::string dialFile;                                     // 表盘背景文件名
+        ColorTypeSet colorType = COLOR_DEFAULT;                   // 颜色类型
+        BatteryDisplayType batterySetting = BATTERY_DISPLAY_NONE; // 电池设置
+        TimeDisplayPosition timePosition = TIME_DISPLAY_DEFAULT;  // 时间位置
+        int64_t color_ = Color::White().full;                     // 电量颜色
+        int32_t power_ = 101;                                     // 电量
+        bool isBatteryIconVisible{false};                         // 电池暂停
+        uint8_t custom_id = 0;
+    };
+} // namespace OHOS
+#endif // MAIN_CLOCK_VIEW_H
index 140458b..f3e8930 100644 (file)
  * Create: 2021-08-14
  */
 
- #include "MainClockView.h"
- #include "MainModel.h"
- #include "MainPresenterSample.h"
- #include "SetDialModel.h"
- #include "battery_hal.h"
- #include "common/image_cache_manager.h"
- #include "components/ui_label.h"
- #include "custom_runtime.h"
-
- #include "main/include/PullUpDownView.h"
+#include "MainClockView.h"
+#include "MainModel.h"
+#include "MainPresenterSample.h"
+#include "SetDialModel.h"
+
+#ifdef SUPPORT_BATTERY_SERVICE
+#include "battery_hal.h"
+#endif
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label.h"
+#include "custom_runtime.h"
+#include "main/include/PullUpDownView.h"
+#include "message/include/MessageControlView.h"
  #include "message/include/MessageControlView.h"
 #include "uicomponents/UIComponents.h"
+#include "components/ui_lite_surface_view.h"
+#include "video_play_wrapper.h"
+// #include "main/include/dial/DialVideoView.h"
+#include "ui_resource_image.h"
+#include "wearable_log.h"
+#include <cwchar>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
 
- #include "ui_resource_image.h"
- 
- #include "wearable_log.h"
- #include <cwchar>
- #include <iomanip>
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <sys/stat.h>
- #include <time.h>
- #include <unistd.h>
- 
- #include "battery_hal.h"
- extern uint8_t battery_get_voltage(float *voltage);
- 
- #define TIMEVIEW_UP 0
- #define TIMEVIEW_DOWN 1
- #define SECONDTEST 0
- #define TIMEFORMAT 1
- 
- std::string Enweekdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
- std::string Cnweekdays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
- 
- static constexpr const char *CHAGE_BATTERY = "/user/res/Battery/Icon.bin";
- static constexpr const char *WHITE_BATTERY = "/user/res/Battery/Battery_White.bin";
- static constexpr const char *BLACK_BATTERY = "/user/res/Battery/Battery_Black.bin";
- 
- static constexpr const char *DISTURBICON = "user/res/dial_state/disturbicon.bin";
- static constexpr const char *MESSAGEICON = "user/res/dial_state/unread.bin";
- static constexpr const char *SLEEPICON = "user/res/dial_state/sleep.bin";
- static constexpr const char *LOCKICON = "user/res/dial_state/lock.bin";
- 
- // 定义一些常量
- constexpr int HOURS_IN_DAY = 24;
- constexpr int MINUTES_IN_HOUR = 60;
- constexpr int HOUR_FORMAT_12 = 12;
- constexpr int BATTERY_LOW_THRESHOLD = 10;
- constexpr int BATTERY_MEDIUM_THRESHOLD = 20;
- 
- namespace OHOS
- {
- #if 0
-     static constexpr uint16_t FONT_DEFAULT_SIZE = 25;
-     static constexpr uint16_t FONT_TEXT_SIZE = 24;
-     static constexpr uint16_t STEP_LABEL_X = 100;
-     static constexpr uint16_t STEP_LABEL_Y = 230;
-     static constexpr uint16_t BATTERYP_LABEL_X = 315;
-     static constexpr uint16_t BATTERYP_LABEL_Y = 230;
-     static constexpr uint16_t TEXT_WIDTH = 60;
-     static constexpr uint16_t TEXT_HEIGHT = 35;
-     static constexpr uint16_t POINT_POSITION_X = 202;
-     static constexpr uint16_t POINT_POSITION_Y = 16;
-     static constexpr uint16_t SECOND_POINT_POSITION_Y = 16;
-     static constexpr uint16_t POINT_CENTER_X = 25;
-     static constexpr uint16_t POINT_CENTER_Y = 211;
-     static constexpr int16_t STEP_LABLE_WIDTH = 75;
-     static constexpr int16_t STEP_LABLE_SIZE = 35;
-     static constexpr uint16_t WEEKLABEL_POSITION_X = 181;
-     static constexpr uint16_t WEEKLABEL_POSITION_Y = 365;
-     static constexpr uint16_t HEARTRATELABEL_POSITION_X = 198;
-     static constexpr uint16_t HEARTRATELABEL_POSITION_Y = 330;
-     static constexpr uint16_t HEARTRATE_POSITION_X = 156;
-     static constexpr uint16_t HEARTRATE_POSITION_Y = 260;
-     static constexpr uint16_t PROGRESS_POSITION_X = 53;
-     static constexpr uint16_t PROGRESS_POSITION_Y = 54;
-     static constexpr uint16_t BIGCIRCLE_POSITION_X = 202;
-     static constexpr uint16_t BIGCIRCLE_POSITION_Y = 202;
-     static constexpr uint16_t MEDCIRCLE_POSITION_X = 202;
-     static constexpr uint16_t MEDCIRCLE_POSITION_Y = 202;
-     static constexpr uint16_t SMALLCIRCLE_POSITION_X = 202;
-     static constexpr uint16_t SMALLCIRCLE_POSITION_Y = 202;
-     static constexpr uint16_t WEEKDAY_POSITION_X = 193;
-     static constexpr uint16_t WEEKDAY_POSITION_Y = 127;
-     static constexpr int16_t SEC_TO_MILLI = 1000;
-     static constexpr int16_t USEC_TO_MILLI = 1000;
-     static constexpr int16_t MIN_TO_HOUR = 60;
-     static constexpr int16_t HOURLY_SYSTEM = 24;
-     static constexpr int16_t INTERVAL = 30;
- #endif
-     static constexpr uint16_t STEP_CHAR_NUM = 255;
-     static MainClockView *g_pMainClockView = nullptr;
-     MainClockView::MainClockView()
-     {
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::MainClockView");
-         SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-         g_pMainClockView = this;
-     }
- 
-     MainClockView::~MainClockView()
-     {
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::~MainClockView");
- 
-         delete curFace; // 背景
-         curFace = nullptr;
-         delete timerlabel; // 时间
-         timerlabel = nullptr;
-         delete weekLabel; // 星期
-         weekLabel = nullptr;
-         delete datelabel; // 日期
-         datelabel = nullptr;
-         delete batteryiamge; // 电量框
-         batteryiamge = nullptr;
-         delete batteryprogress; // 电量进度条
-         batteryprogress = nullptr;
-         delete batterylabel; // 电量label
-         batterylabel = nullptr;
-         delete batteryicon; // 充电图标
-         batteryicon = nullptr;
-         delete stepLabel; // 步数
-         stepLabel = nullptr;
-         delete heartlabel; // 心率
-         heartlabel = nullptr;
-         if (dialstateicon_ != nullptr) {
-           delete dialstateicon_;
-           dialstateicon_ = nullptr;
-         }
- 
-         if (messageicon_ != nullptr) {
-           delete messageicon_;
-           messageicon_ = nullptr;
-         }
- 
-         g_pMainClockView = nullptr;
-     }
- 
-     MainClockView *MainClockView::GetInstance(void)
-     {
-         return g_pMainClockView;
-     }
-     /*配置自定义表盘*/
-     void MainClockView::SetCustomId(int Id)
-     {
-         // 默认表盘和异常表盘采用原表盘配置
-         if (Id == DIAL_CLOCK || Id > DIAL_MAX)
-             return;
- 
-         DialLayout dialconfig;
-         if (SetDialModel::GetInstance().loadDialConfig(Id, dialconfig))
-         {
-             // 设置背景
-             dialFile = SetDialModel::GetInstance().GetSaveDir(Id) + "/" + "main_bg.bin";
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialFile is %s", dialFile.c_str());
- 
-             // 设置表盘配置
-             timePosition = static_cast<TimeDisplayPosition>(dialconfig.timeDisplay);
-             batterySetting = static_cast<BatteryDisplayType>(dialconfig.batteryDisplay);
-             colorType = static_cast<ColorTypeSet>(dialconfig.colorTypeSet);
-         }
-         else
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_id [%d] file is error! ", Id);
-         }
-     }
- 
-     /*设置表盘背景*/
-     void MainClockView::SetDialPath(std::string dialpath)
-     {
-         if (dialpath.empty())
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: The specified dial path does not exist:");
-             return;
-         }
-         dialFile.clear();
-         dialFile = dialpath;
-     }
- 
-     bool MainClockView::InitClock(void)
-     {
-         InitBackground(dialFile.c_str());
-         InitTimeView(timePosition);
-         InitBatteryView(batterySetting);
-         InitColor(colorType);
-         return true;
-     }
-     /*初始化表盘背景*/
-     bool MainClockView::InitBackground(const char *filename) {
- 
-         if (filename == nullptr) {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "filename is null");
-             return false;
-         }
-         curFace = new UIImageView();
-         if (curFace == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curFace new fail");
-             return false;
-         }
-         curFace->SetPosition(0, 0);
- 
-         ImageCacheManager::GetInstance().UnloadSingleRes(filename);
-         ImageInfo *image = ImageCacheManager::GetInstance().LoadSingleRes(filename, false);
-         if (image == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail",
-                             filename);
-             curFace->SetSrc(DEFAULT_DIALBACK_PATH);
-             Add(curFace);
-             return false;
-         }
-         curFace->SetSrc(image);
-         Add(curFace);
-         return true;
-     }
- 
-     /*
-         时间显示 [时间 日期 星期]
-         0 显示在表盘上方
-         1 显示在表盘下方
- 
-         默认:下方
-     */
-     bool MainClockView::InitTimeView(TimeDisplayPosition type)
-     {
-         // 创建UILabel的助手函数
-         auto createLabel = [](UILabel *&label, const std::string &labelName) -> bool
-         {
-             label = new UILabel();
-             if (label == nullptr)
-             {
-                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s creation failed", labelName.c_str());
-                 return false;
-             }
-             label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
-             label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 居中
-             label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-             label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);
-             return true;
-         };
- 
-         // 创建时间、星期、日期标签
-         if (!createLabel(timerlabel, "timerlabel") ||
-             !createLabel(datelabel, "datelabel"))
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Label creation failed, exiting InitTimeView");
-             return false; // 分配失败
-         }
- 
-         // 设置标签的位置和字体大小
-         switch (type)
-         {
-         case TIME_DISPLAY_ABOVE:
-             timerlabel->SetPosition(0, 65, 466, 150);
-             timerlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 100);
-             datelabel->SetPosition(83, 186, 300, 60);
-             datelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
-             // weekLabel->SetPosition(246, 196, 200, 60);
-             // weekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
-             break;
- 
-         case TIME_DISPLAY_BELOW:
-         default: // 默认情况下显示在下方
-             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "type is unknown, defaulting to TIMEVIEW_DOWN");
-             timerlabel->SetPosition(83, 300, 300, 100);
-             timerlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 65);
-             datelabel->SetPosition(137, 380, 200, 60);
-             datelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
-             // weekLabel->SetPosition(252, 390, 200, 60);
-             // weekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
-             break;
-         }
- 
-         Add(timerlabel);
-         Add(datelabel);
-         // Add(weekLabel);
-
-        //  timerlabel->SetWorkMode(UISweepClock::WorkMode::NORMAL);
-         return true;
-     }
-     /*
-         界面颜色显示
-         0 白
-         1 黑
-         2 灰
-         3 绿
-         4 橙
-         5 蓝
- 
-       默认:白
-     */
-     bool MainClockView::InitColor(ColorTypeSet type)
-     {
-         if (!timerlabel ||!datelabel)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is null");
-             return false;
-         }
- 
-         // 根据传入的颜色类型设置文本颜色
-         switch (type)
-         {
-         case COLOR_BLACK:
-             SetLabelsColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0xff));
-             break;
-         case COLOR_GRAY:
-             SetLabelsColor(Color::GetColorFromRGBA(0xCC, 0xCC, 0xCC, 0xff));
-             break;
-         case COLOR_GREEN:
-             SetLabelsColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
-             break;
-         case COLOR_ORANGE:
-             SetLabelsColor(Color::GetColorFromRGBA(0xFF, 0x5A, 0x36, 0xff));
-             break;
-         case COLOR_BLUE:
-             SetLabelsColor(Color::GetColorFromRGBA(0x35, 0x49, 0xFF, 0xff));
-             break;
-         case COLOR_WHITE:
-         default: // 默认情况下使用白色
-             SetLabelsColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
-             break;
-         }
-         return true;
-     }
- 
-     void MainClockView::SetLabelsColor(ColorType color)
-     {
-         timerlabel->SetTextColor(color);
-         datelabel->SetTextColor(color);
-         // weekLabel->SetTextColor(color);
-     }
- 
-     /*
-         电量显示 [电池框图片 电池进度条 电池标签]
-         0 不显示图标
-         1 显示黑色
-         2 显示白色
- 
-         默认:白色
-     */
-     bool MainClockView::InitBatteryView(BatteryDisplayType type)
-     {
-         // 不显示电池 icon
-         if (type == BATTERY_DISPLAY_NONE)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no show battery");
-             return false;
-         }
- 
-         // 创建电池框图像
-         batteryiamge = new UIImageView();
-         if (!batteryiamge)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryiamge creation failed");
-             return false;
-         }
- 
-         // 创建电池图标图像
-         batteryicon = new UIImageView();
-         if (!batteryicon)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryicon creation failed");
-             return false;
-         }
- 
-         // 创建电池进度条
-         batteryprogress = new UIBoxProgress();
-         if (!batteryprogress)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryprogress creation failed");
-             return false;
-         }
- 
-         // 创建电池标签
-         batterylabel = new UILabel();
-         if (!batterylabel)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batterylabel creation failed");
-             return false;
-         }
- 
-         // 设置位置
-         batteryicon->SetPosition(186, 52, 100, 100);
-         batteryiamge->SetPosition(176, 52, 100, 100);
- 
-         batteryprogress->SetPosition(182, 58, 30, 18);
-         batteryprogress->SetViewId("progress");
-         batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
-         batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00);
- 
-         batterylabel->SetPosition(228, 52, 200, 60);
-         batterylabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
- 
-         // 设置图标和颜色
-         switch (type) {
-         case BATTERY_DISPLAY_BLACK:
-           batteryiamge->SetSrc(BLACK_BATTERY);
-           batterylabel->SetTextColor(Color::Black());
-           batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR,
-                                               0xff000000);
-           break;
-         case BATTERY_DISPLAY_WHITE:
-         default:
-           batteryiamge->SetSrc(WHITE_BATTERY);
-           batterylabel->SetTextColor(Color::White());
-           batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR,
-                                               0xffffffff);
-           break;
-         }
-         batteryicon->SetSrc(CHAGE_BATTERY);
-         batteryicon->SetVisible(false); // 设置不可见
- 
-         Add(batteryiamge);
-         Add(batterylabel);
-         Add(batteryprogress);
-         Add(batteryicon);
-         return true;
-     }
- 
-     void MainClockView::UpdateStateShow()
-     {
-         if (messageicon_ == nullptr || dialstateicon_ == nullptr)
-             return;
- 
-         /*配置未读状态*/
-         messageicon_->SetVisible(MainModel::GetInstance().getMessageActiveState());
-         /*配置表盘状态*/
-         dialstateicon_->SetVisible(true);
-         switch (MainModel::GetInstance().getHighestPriorityActiveState())
-         {
-         case DialState::DO_NOT_DISTURB:
-             dialstateicon_->SetSrc(DISTURBICON);
-             break;
-         case DialState::SLEEP:
-             dialstateicon_->SetSrc(SLEEPICON);
-             break;
-         case DialState::LOCK:
-             dialstateicon_->SetSrc(LOCKICON);
-             break;
-         default:
-             dialstateicon_->SetVisible(false);
-             break;
-         }
-     }
- 
-     void MainClockView::PreLoad(void)
-     {
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::PreLoad");
-         if (!viewiInitStatus)
-         {
-             InitView();
-           
-             /*增加手表状态图标*/
-             InitImageView(dialstateicon_, 213, 2, 40, 40, "disturbicon", DISTURBICON);
-             dialstateicon_->SetVisible(false);
- 
-             /*增加未读图标*/
-             InitImageView(messageicon_, 223, 444, 20, 20, "messageicon_", MESSAGEICON);
- 
-             UpdateStateShow();
- 
-             Add(dialstateicon_);
-             Add(messageicon_);
- 
-             viewiInitStatus = true;
-         }
- 
-         if (!resLoadStatus)
-         {
-            //  if (PullUpDownView::GetInstance() != nullptr)
-            //  {
-            //      PullUpDownView::GetInstance()->PreLoad();
-            //  }
-            //  if (MessageControlView::GetInstance() != nullptr)
-            //  {
-            //      MessageControlView::GetInstance()->PreLoad();
-            //  }
-             resLoadStatus = true;
-         }
-     }
- 
-     void MainClockView::UnLoad(void)
-     {
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::UnLoad");
- 
-         if (resLoadStatus)
-         {
-            //  if (PullUpDownView::GetInstance() != nullptr)
-            //  {
-            //      PullUpDownView::GetInstance()->UnLoad();
-            //  }
- 
-            //  if (MessageControlView::GetInstance() != nullptr)
-            //  {
-            //      MessageControlView::GetInstance()->UnLoad();
-            //  }
-             resLoadStatus = false;
-         }
-     }
- 
-     bool MainClockView::InitView(void)
-     {
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitView");
-         if (InitClock() == false)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitClock is error");
-             return false;
-         }
-         InitDateTime(); // 初始化数据
-         SetCoverable(true);
-         return true;
-     }
- 
-     void MainClockView::InitDateTime(void)
-     {
-         UpdateTime();
-     }
- 
-     /* 更新时间 */
-     void MainClockView::UpdateTime(void) {  
-         struct tm local_time = {0};  
-         time_t seconds = time(nullptr);  
- 
-         // Get local time  
-         if (localtime_r(&seconds, &local_time) == nullptr) {  
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");  
-             return;  
-         }  
- 
-         // Extract hour and minute  
-         uint8_t hour = local_time.tm_hour % HOURS_IN_DAY;
-         uint8_t minute = local_time.tm_min % MINUTES_IN_HOUR;
-         char timebuf[64] = {0};  
-         //时间显示样式
-         #if TIMEFORMAT   
-             if (uapi_dev_runtime_get_time_hour_show_model() == HOUR_FORMAT_12) {
-                 if (hour > HOUR_FORMAT_12) {
-                     hour -= HOUR_FORMAT_12;
-                 }
-             }
-         #endif
-         //是否显示秒
-         #if SECONDTEST  
-             uint8_t second = local_time.tm_sec;
-             sprintf(timebuf, "%02d:%02d:%02d", hour, minute, second);
-         #else
-             sprintf_s(timebuf, sizeof(timebuf), "%02d:%02d", hour, minute);
-         #endif  
- 
-         // Update display labels  
-         if (timerlabel != nullptr)  
-             timerlabel->SetText(timebuf);  
- 
-         // Update date and week day  
-         std::string weekStr = Cnweekdays[local_time.tm_wday];  
-         std::string dateStr = std::to_string(local_time.tm_mon + 1) + "月" +  
-                             std::to_string(local_time.tm_mday) + "号 " + weekStr;  
- 
-         if (datelabel != nullptr)  
-             datelabel->SetText(dateStr.c_str());  
- 
-         // Update battery status  
-         if (batterySetting == BATTERY_DISPLAY_NONE)  
-             return;  
- 
-         UpdateBatteryColor();  
- 
-         float voltage = 0.0F;  
-         int power = battery_get_voltage(&voltage);  
-         if (power == power_)  
-             return;  
- 
-         power_ = power;  
-         // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryprogress power_:%d", power_);  
- 
-         if (batteryprogress != nullptr && batterylabel != nullptr) {  
-             batteryprogress->SetValue(power_);  
-             std::string batteryStr = std::to_string(power_) + "%";  
-             batterylabel->SetText(batteryStr.c_str());  
-         }  
-     }
- 
-     void MainClockView::UpdateBatteryColor(void)
-     {
-         bool isCharging = get_charge_stat(); // 获取充电状态
- 
-         if (isCharging)
-         {
-             if (!isBatteryIconVisible)
-             {
-                 batteryicon->SetVisible(true);
-                 isBatteryIconVisible = true;
-             }
-             SetViewColor(Color::Green().full); // 充电状态为绿色
-             return;
-         }
-         else
-         {
-             if (isBatteryIconVisible)
-             {
-                 batteryicon->SetVisible(false);
-                 isBatteryIconVisible = false;
-             }
- 
-             if (power_ <= BATTERY_LOW_THRESHOLD)
-             {
-                 SetViewColor(Color::Red().full);
-             }
-             else if (power_ <= BATTERY_MEDIUM_THRESHOLD)
-             {
-                 SetViewColor(Color::Yellow().full);
-             }
-             else
-             {
-                 if (batterySetting == BATTERY_DISPLAY_BLACK)
-                 {
-                     SetViewColor(Color::Black().full);
-                 }
-                 else
-                 {
-                     SetViewColor(Color::White().full);
-                 }
-             }
-         }
-     }
- 
-     void MainClockView::SetViewColor(int64_t color)
-     {
-         if (color == color_)
-         {
-             return;
-         }
-         color_ = color;
-         batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, color_);
-     }
- 
-     /*刷新步数*/
-     void MainClockView::RefreshStep(int step)
-     {
-         if (stepLabel == nullptr)
-             return;
- 
-         char stepChar[STEP_CHAR_NUM] = {0};
-         (void)sprintf_s(stepChar, STEP_CHAR_NUM, "%d", step);
-         stepLabel->SetText(stepChar);
-     }
- 
-     /*刷新心率*/
-     void MainClockView::RefreshHeartRate(int value)
-     {
-         if (heartlabel == nullptr)
-             return;
- 
-         if (value == 0)
-         {
-             heartlabel->SetText("--");
-             return;
-         }
-         char heartRateChar[STEP_CHAR_NUM] = {0};
-         (void)sprintf_s(heartRateChar, STEP_CHAR_NUM, "%d", value);
-         heartlabel->SetText(heartRateChar);
-     }
- 
-     /*初始化步数*/
-     void MainClockView::InitStepValue()
-     {
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue");
-         uint32_t stepValue;
-         int weekToday = ActivityModel::GetInstance()->GetWeekToday();
-         ActivityModel::GetInstance()->GetStepData((StepDataDistribute)weekToday, &stepValue);
-         char stepChar[STEP_CHAR_NUM] = {0};
-         if (sprintf_s(stepChar, STEP_CHAR_NUM, "%d", stepValue) == -1)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue error");
-             return;
-         }
-         if (stepLabel == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue nullptr");
-             return;
-         }
-         stepLabel->SetText(stepChar);
-     }
-     /*初始化指针图片*/
-     bool MainClockView::InitCenterCircleView(void)
-     {
- 
-         bigCircle = new Image();
-         if (bigCircle == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bigCircle new fail");
-             return false;
-         }
-         if (LoadClockImage(bigCircle, CLOCK_CLASSIC_GEOMETRY) == false)
-         {
-             return false;
-         }
- 
-         medCircle = new Image();
-         if (medCircle == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "medCircle new fail");
-             return false;
-         }
-         if (LoadClockImage(medCircle, CLOCK_CLASSIC_GEOMETRY) == false)
-         {
-             return false;
-         }
- 
-         smallCircle = new Image();
-         if (smallCircle == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "smallCircle new fail");
-             return false;
-         }
-         if (LoadClockImage(smallCircle, CLOCK_CLASSIC_GEOMETRY) == false)
-         {
-             return false;
-         }
- 
-         return true;
-     }
- 
-     bool MainClockView::InitHandView(void)
-     {
-         secondHand = new Image();
-         if (secondHand == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "secondHand new fail");
-             return false;
-         }
-         if (LoadClockImage(secondHand, CLOCK_CLOCK_SECOND) == false)
-         {
-             return false;
-         }
- 
-         minuteHand = new Image();
-         if (minuteHand == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "minuteHand new fail");
-             return false;
-         }
-         if (LoadClockImage(minuteHand, CLOCK_CLOCK_MINUTE) == false)
-         {
-             return false;
-         }
-         hourHand = new Image();
-         if (hourHand == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hourHand new fail");
-             return false;
-         }
-         if (LoadClockImage(hourHand, CLOCK_CLOCK_HOUR) == false)
-         {
-             return false;
-         }
- 
-         hand24Hour = new Image();
-         if (hand24Hour == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hand24Hour new fail");
-             return false;
-         }
-         if (LoadClockImage(hand24Hour, CLOCK_CLASSIC_GEOMETRY) == false)
-         {
-             return false;
-         }
- 
-         return true;
-     }
- 
-     bool MainClockView::LoadClockImage(Image *view, uint32_t resId)
-     {
- 
-         std::string file = CLOCK_IAMGES;
-         ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file);
-         if (image == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId);
-             return false;
-         }
-         view->SetSrc(image);
- 
-         return true;
-     }
+
+#define TIMEVIEW_UP 0
+#define TIMEVIEW_DOWN 1
+#define SECONDTEST 0
+#define TIMEFORMAT 1
+
+std::string Enweekdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+std::string Cnweekdays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+static constexpr const char *CHAGE_BATTERY = "/user/res/Battery/Icon.bin";
+static constexpr const char *WHITE_BATTERY = "/user/res/Battery/Battery_White.bin";
+static constexpr const char *BLACK_BATTERY = "/user/res/Battery/Battery_Black.bin";
+
+static constexpr const char *DISTURBICON = "user/res/dial_state/disturbicon.bin";
+static constexpr const char *MESSAGEICON = "user/res/dial_state/unread.bin";
+static constexpr const char *SLEEPICON = "user/res/dial_state/sleep.bin";
+static constexpr const char *LOCKICON = "user/res/dial_state/lock.bin";
+
+// 定义一些常量
+constexpr int HOURS_IN_DAY = 24;
+constexpr int MINUTES_IN_HOUR = 60;
+constexpr int HOUR_FORMAT_12 = 12;
+constexpr int BATTERY_LOW_THRESHOLD = 10;
+constexpr int BATTERY_MEDIUM_THRESHOLD = 20;
+
+namespace OHOS
+{
+#if 0
+    static constexpr uint16_t FONT_DEFAULT_SIZE = 25;
+    static constexpr uint16_t FONT_TEXT_SIZE = 24;
+    static constexpr uint16_t STEP_LABEL_X = 100;
+    static constexpr uint16_t STEP_LABEL_Y = 230;
+    static constexpr uint16_t BATTERYP_LABEL_X = 315;
+    static constexpr uint16_t BATTERYP_LABEL_Y = 230;
+    static constexpr uint16_t TEXT_WIDTH = 60;
+    static constexpr uint16_t TEXT_HEIGHT = 35;
+    static constexpr uint16_t POINT_POSITION_X = 202;
+    static constexpr uint16_t POINT_POSITION_Y = 16;
+    static constexpr uint16_t SECOND_POINT_POSITION_Y = 16;
+    static constexpr uint16_t POINT_CENTER_X = 25;
+    static constexpr uint16_t POINT_CENTER_Y = 211;
+    static constexpr int16_t STEP_LABLE_WIDTH = 75;
+    static constexpr int16_t STEP_LABLE_SIZE = 35;
+    static constexpr uint16_t WEEKLABEL_POSITION_X = 181;
+    static constexpr uint16_t WEEKLABEL_POSITION_Y = 365;
+    static constexpr uint16_t HEARTRATELABEL_POSITION_X = 198;
+    static constexpr uint16_t HEARTRATELABEL_POSITION_Y = 330;
+    static constexpr uint16_t HEARTRATE_POSITION_X = 156;
+    static constexpr uint16_t HEARTRATE_POSITION_Y = 260;
+    static constexpr uint16_t PROGRESS_POSITION_X = 53;
+    static constexpr uint16_t PROGRESS_POSITION_Y = 54;
+    static constexpr uint16_t BIGCIRCLE_POSITION_X = 202;
+    static constexpr uint16_t BIGCIRCLE_POSITION_Y = 202;
+    static constexpr uint16_t MEDCIRCLE_POSITION_X = 202;
+    static constexpr uint16_t MEDCIRCLE_POSITION_Y = 202;
+    static constexpr uint16_t SMALLCIRCLE_POSITION_X = 202;
+    static constexpr uint16_t SMALLCIRCLE_POSITION_Y = 202;
+    static constexpr uint16_t WEEKDAY_POSITION_X = 193;
+    static constexpr uint16_t WEEKDAY_POSITION_Y = 127;
+    static constexpr int16_t SEC_TO_MILLI = 1000;
+    static constexpr int16_t USEC_TO_MILLI = 1000;
+    static constexpr int16_t MIN_TO_HOUR = 60;
+    static constexpr int16_t HOURLY_SYSTEM = 24;
+    static constexpr int16_t INTERVAL = 30;
+#endif
+    static constexpr uint16_t STEP_CHAR_NUM = 255;
+    static MainClockView *g_pMainClockView = nullptr;
+    static constexpr int16_t JPEG_HEIGHT_DIVISOR = 2;
+    static constexpr int16_t JPEG_WIDTH_BYTE_ALIGNMENT = 128;
+    static constexpr int16_t JPEG_HEIGHT_BYTE_ALIGNMENT = 16;
+    static constexpr int16_t BUFFER_QUEUE_SIZE = 2;
+    static constexpr int16_t STRIDE_ALIGNMENT_VALUE = 128;
+
+    static inline int32_t MediaByteAlign(int16_t value, int16_t align)
+    {
+        return (((value) + (align) - 1) & (~((align) - 1)));
+    }
+
+    MainClockView::MainClockView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::MainClockView");
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        g_pMainClockView = this;
+    }
+
+    MainClockView::~MainClockView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::~MainClockView");
+
+        delete curFace; // 背景
+        curFace = nullptr;
+        delete timerlabel; // 时间
+        timerlabel = nullptr;
+        delete weekLabel; // 星期
+        weekLabel = nullptr;
+        delete datelabel; // 日期
+        datelabel = nullptr;
+        delete batteryiamge; // 电量框
+        batteryiamge = nullptr;
+        delete batteryprogress; // 电量进度条
+        batteryprogress = nullptr;
+        delete batterylabel; // 电量label
+        batterylabel = nullptr;
+        delete batteryicon; // 充电图标
+        batteryicon = nullptr;
+        delete stepLabel; // 步数
+        stepLabel = nullptr;
+        delete heartlabel; // 心率
+        heartlabel = nullptr;
+        if (dialstateicon_ != nullptr) {
+          delete dialstateicon_;
+          dialstateicon_ = nullptr;
+        }
+        if (messageicon_ != nullptr) {
+          delete messageicon_;
+          messageicon_ = nullptr;
+        }
+        if (videoPlayer_ != nullptr) {
+            delete videoPlayer_;
+            videoPlayer_ = nullptr;
+        }
+
+        g_pMainClockView = nullptr;
+    }
+
+    MainClockView *MainClockView::GetInstance(void)
+    {
+        return g_pMainClockView;
+    }
+    /*配置自定义表盘*/
+    void MainClockView::SetCustomId(int Id)
+    {
+        // 默认表盘和异常表盘采用原表盘配置
+        if (Id == DIAL_CLOCK || Id > DIAL_MAX)
+            return;
+
+        //赋值id
+        custom_id = Id;
+
+        DialLayout dialconfig;
+        if (SetDialModel::GetInstance().loadDialConfig(custom_id, dialconfig))
+        {
+            // 设置背景 Id == 2(实际是1) 视频表盘
+            if(Id == 2)
+            {
+                dialFile = SetDialModel::GetInstance().GetSaveDir(custom_id) + "/" + "main_bg.mp4";
+            }
+            else // 图片表盘
+            {
+                dialFile = SetDialModel::GetInstance().GetSaveDir(custom_id) + "/" + "main_bg.bin";
+            }
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialFile is %s", dialFile.c_str());
+
+            // 设置表盘配置
+            timePosition = static_cast<TimeDisplayPosition>(dialconfig.timeDisplay);
+            batterySetting = static_cast<BatteryDisplayType>(dialconfig.batteryDisplay);
+            colorType = static_cast<ColorTypeSet>(dialconfig.colorTypeSet);
+
+            //打印表盘配置
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timePosition is %d", timePosition);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batterySetting is %d", batterySetting);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "colorType is %d", colorType);
+        }
+        else
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_id [%d] file is error! ", Id);
+        }
+    }
+
+    /*设置表盘背景*/
+    void MainClockView::SetDialPath(std::string dialpath)
+    {
+        if (dialpath.empty())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: The specified dial path does not exist:");
+            return;
+        }
+        dialFile.clear();
+        dialFile = dialpath;
+    }
+
+    bool MainClockView::InitClock(void)
+    {
+        InitBackground(dialFile.c_str());
+        InitTimeView(timePosition);
+        InitBatteryView(batterySetting);
+        InitColor(colorType);
+        return true;
+    }
+
+    /*初始化表盘背景 图片 视频*/
+    bool MainClockView::InitBackground(const char *filename) {
+        if (filename == nullptr) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "filename is null");
+            return false;
+        }
+
+        // 判断是否为视频表盘(图片表盘后缀为.bin,视频表盘后缀为.mp4)
+        const char* ext = strrchr(filename, '.');
+        bool isVideo = (ext != nullptr && strcasecmp(ext, ".mp4") == 0);
+
+        if (isVideo) {
+            // 判断文件是否存在
+            if (access(filename, F_OK) == -1) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: The specified video file does not exist: %s", filename);
+                return false;
+            }
+
+            // 检查视频播放器是否已初始化
+            if (videoPlayer_ != nullptr) {
+                GRAPHIC_LOGE("Cannot set video res repeatedly!\n");
+                return false;
+            }
+
+            // 打开视频文件
+            FILE* fp = fopen(filename, "rb");
+            if (fp == nullptr) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open video file: %s", filename);
+                return false;
+            }
+
+            videoPlayer_ = new DialVideoView();
+            videoPlayer_->SetPosition(0 ,0,466, 466);
+            videoPlayer_->SetSurfaceColorkey(Color::GetColorFromRGBA(0xff,0x21,0x23,0x24));
+            videoPlayer_->SetVideoRes(fp, 0);
+            //阅览帧 preview.bin
+            std::string preview_img = SetDialModel::GetInstance().GetSaveDir(custom_id) + "/" + "preview.bin";
+            ImageInfo *image = ImageCacheManager::GetInstance().LoadSingleRes(preview_img.c_str(), false);
+            if (image != nullptr) {
+                videoPlayer_->SetPreview(image);
+            }
+            else
+            {
+              WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail", preview_img.c_str());
+              return false;
+            }
+            Add(videoPlayer_);
+            return true;
+        } else {
+            // 处理图片表盘
+            curFace = new UIImageView();
+            if (curFace == nullptr) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curFace new fail");
+                return false;
+            }
+            curFace->SetPosition(0, 0);
+
+            ImageCacheManager::GetInstance().UnloadSingleRes(filename);
+            ImageInfo *image = ImageCacheManager::GetInstance().LoadSingleRes(filename, false);
+            if (image == nullptr) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail", filename);
+                curFace->SetSrc(DEFAULT_DIALBACK_PATH);
+                Add(curFace);
+                return false;
+            }
+            curFace->SetSrc(image);
+            Add(curFace);
+            return true;
+        }
+    }
+    /*
+        时间显示 [时间 日期 星期]
+        0 显示在表盘上方
+        1 显示在表盘下方
+
+        默认:下方
+    */
+    bool MainClockView::InitTimeView(TimeDisplayPosition type)
+    {
+        // 创建UILabel的助手函数
+        auto createLabel = [](UILabel *&label, const std::string &labelName) -> bool
+        {
+            label = new UILabel();
+            if (label == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s creation failed", labelName.c_str());
+                return false;
+            }
+            label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
+            label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 居中
+            label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);
+            return true;
+        };
+
+        // 创建时间、星期、日期标签
+        if (!createLabel(timerlabel, "timerlabel") ||
+            !createLabel(datelabel, "datelabel"))
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Label creation failed, exiting InitTimeView");
+            return false; // 分配失败
+        }
+
+        // 设置标签的位置和字体大小
+        switch (type)
+        {
+        case TIME_DISPLAY_ABOVE:
+            timerlabel->SetPosition(0, 65, 466, 150);
+            timerlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 100);
+            datelabel->SetPosition(83, 186, 300, 60);
+            datelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
+            // weekLabel->SetPosition(246, 196, 200, 60);
+            // weekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
+            break;
+
+        case TIME_DISPLAY_BELOW:
+        default: // 默认情况下显示在下方
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "type is unknown, defaulting to TIMEVIEW_DOWN");
+            timerlabel->SetPosition(83, 300, 300, 100);
+            timerlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 65);
+            datelabel->SetPosition(137, 380, 200, 60);
+            datelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
+            // weekLabel->SetPosition(252, 390, 200, 60);
+            // weekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
+            break;
+        }
+
+        Add(timerlabel);
+        Add(datelabel);
+        // Add(weekLabel);
+        return true;
+    }
+    /*
+        界面颜色显示
+        0 白
+        1 黑
+        2 灰
+        3 绿
+        4 橙
+        5 蓝
+
+      默认:白
+    */
+    bool MainClockView::InitColor(ColorTypeSet type)
+    {
+        if (!timerlabel ||!datelabel)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is null");
+            return false;
+        }
+
+        // 根据传入的颜色类型设置文本颜色
+        switch (type)
+        {
+        case COLOR_BLACK:
+            SetLabelsColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0xff));
+            break;
+        case COLOR_GRAY:
+            SetLabelsColor(Color::GetColorFromRGBA(0xCC, 0xCC, 0xCC, 0xff));
+            break;
+        case COLOR_GREEN:
+            SetLabelsColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
+            break;
+        case COLOR_ORANGE:
+            SetLabelsColor(Color::GetColorFromRGBA(0xFF, 0x5A, 0x36, 0xff));
+            break;
+        case COLOR_BLUE:
+            SetLabelsColor(Color::GetColorFromRGBA(0x35, 0x49, 0xFF, 0xff));
+            break;
+        case COLOR_WHITE:
+        default: // 默认情况下使用白色
+            SetLabelsColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+            break;
+        }
+        return true;
+    }
+
+    void MainClockView::SetLabelsColor(ColorType color)
+    {
+        timerlabel->SetTextColor(color);
+        datelabel->SetTextColor(color);
+        // weekLabel->SetTextColor(color);
+    }
+
+    /*
+        电量显示 [电池框图片 电池进度条 电池标签]
+        0 不显示图标
+        1 显示黑色
+        2 显示白色
+
+        默认:白色
+    */
+    bool MainClockView::InitBatteryView(BatteryDisplayType type)
+    {
+        // 不显示电池 icon
+        if (type == BATTERY_DISPLAY_NONE)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no show battery");
+            return false;
+        }
+
+        // 创建电池框图像
+        batteryiamge = new UIImageView();
+        if (!batteryiamge)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryiamge creation failed");
+            return false;
+        }
+
+        // 创建电池图标图像
+        batteryicon = new UIImageView();
+        if (!batteryicon)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryicon creation failed");
+            return false;
+        }
+
+        // 创建电池进度条
+        batteryprogress = new UIBoxProgress();
+        if (!batteryprogress)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryprogress creation failed");
+            return false;
+        }
+
+        // 创建电池标签
+        batterylabel = new UILabel();
+        if (!batterylabel)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batterylabel creation failed");
+            return false;
+        }
+
+        // 设置位置
+        batteryicon->SetPosition(186, 52, 100, 100);
+        batteryiamge->SetPosition(176, 52, 100, 100);
+
+        batteryprogress->SetPosition(182, 58, 30, 18);
+        batteryprogress->SetViewId("progress");
+        batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+        batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+        batterylabel->SetPosition(228, 52, 200, 60);
+        batterylabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN , 26);
+
+        // 设置图标和颜色
+        switch (type) {
+        case BATTERY_DISPLAY_BLACK:
+          batteryiamge->SetSrc(BLACK_BATTERY);
+          batterylabel->SetTextColor(Color::Black());
+          batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR,
+                                              0xff000000);
+          break;
+        case BATTERY_DISPLAY_WHITE:
+        default:
+          batteryiamge->SetSrc(WHITE_BATTERY);
+          batterylabel->SetTextColor(Color::White());
+          batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR,
+                                              0xffffffff);
+          break;
+        }
+        batteryicon->SetSrc(CHAGE_BATTERY);
+        batteryicon->SetVisible(false); // 设置不可见
+
+        Add(batteryiamge);
+        Add(batterylabel);
+        Add(batteryprogress);
+        Add(batteryicon);
+        return true;
+    }
+
+    void MainClockView::UpdateStateShow()
+    {
+        if (messageicon_ == nullptr || dialstateicon_ == nullptr)
+            return;
+
+        /*配置未读状态*/
+        messageicon_->SetVisible(MainModel::GetInstance().getMessageActiveState());
+        /*配置表盘状态*/
+        dialstateicon_->SetVisible(true);
+        switch (MainModel::GetInstance().getHighestPriorityActiveState())
+        {
+        case DialState::DO_NOT_DISTURB:
+            dialstateicon_->SetSrc(DISTURBICON);
+            break;
+        case DialState::SLEEP:
+            dialstateicon_->SetSrc(SLEEPICON);
+            break;
+        case DialState::LOCK:
+            dialstateicon_->SetSrc(LOCKICON);
+            break;
+        default:
+            dialstateicon_->SetVisible(false);
+            break;
+        }
+    }
+
+    void MainClockView::PreLoad(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::PreLoad");
+        if (!viewiInitStatus)
+        {
+            InitView();
+          
+            /*增加手表状态图标*/
+            InitImageView(dialstateicon_, 213, 2, 40, 40, "disturbicon", DISTURBICON);
+            // dialstateicon_->SetVisible(false);
+
+            /*增加未读图标*/
+            InitImageView(messageicon_, 223, 444, 20, 20, "messageicon_", MESSAGEICON);
+
+            UpdateStateShow();
+
+            Add(dialstateicon_);
+            Add(messageicon_);
+
+            viewiInitStatus = true;
+        }
+
+        if (!resLoadStatus)
+        {
+            if (PullUpDownView::GetInstance() != nullptr)
+            {
+                PullUpDownView::GetInstance()->PreLoad();
+            }
+            if (MessageControlView::GetInstance() != nullptr)
+            {
+                MessageControlView::GetInstance()->PreLoad();
+            }
+            resLoadStatus = true;
+        }
+    }
+
+    void MainClockView::UnLoad(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::UnLoad");
+
+        if (resLoadStatus)
+        {
+            if (PullUpDownView::GetInstance() != nullptr)
+            {
+                PullUpDownView::GetInstance()->UnLoad();
+            }
+
+            if (MessageControlView::GetInstance() != nullptr)
+            {
+                MessageControlView::GetInstance()->UnLoad();
+            }
+            resLoadStatus = false;
+        }
+    }
+
+    bool MainClockView::InitView(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitView");
+        if (InitClock() == false)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitClock is error");
+            return false;
+        }
+        InitDateTime(); // 初始化数据
+        SetCoverable(true);
+        return true;
+    }
+
+    void MainClockView::InitDateTime(void)
+    {
+        UpdateTime();
+    }
+
+    /* 更新时间 */
+    void MainClockView::UpdateTime(void) {  
+        struct tm local_time = {0};  
+        time_t seconds = time(nullptr);  
+
+        if (localtime_r(&seconds, &local_time) == nullptr) {  
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");  
+            return;  
+        }  
+
+        uint8_t hour = local_time.tm_hour % HOURS_IN_DAY;
+        uint8_t minute = local_time.tm_min % MINUTES_IN_HOUR;
+        char timebuf[64] = {0};  
+        //时间显示样式
+        #if TIMEFORMAT   
+            if (uapi_dev_runtime_get_time_hour_show_model() == HOUR_FORMAT_12) {
+                if (hour > HOUR_FORMAT_12) {
+                    hour -= HOUR_FORMAT_12;
+                }
+            }
+        #endif
+        //是否显示秒
+        #if SECONDTEST  
+            uint8_t second = local_time.tm_sec;
+            sprintf(timebuf, "%02d:%02d:%02d", hour, minute, second);
+        #else
+            sprintf_s(timebuf, sizeof(timebuf), "%02d:%02d", hour, minute);
+        #endif  
+
+        if (timerlabel != nullptr)  
+            timerlabel->SetText(timebuf);  
+
+        
+        std::string weekStr = Cnweekdays[local_time.tm_wday];  
+        std::string dateStr = std::to_string(local_time.tm_mon + 1) + "月" +  
+                            std::to_string(local_time.tm_mday) + "号 " + weekStr;  
+
+        if (datelabel != nullptr)  
+            datelabel->SetText(dateStr.c_str());  
+
+
+        //电量显示配置
+        if (batterySetting == BATTERY_DISPLAY_NONE)  
+            return;  
+     
+
+        UpdateBatteryColor();  
+
+        float voltage = 0.0F;  
+        int power = battery_get_voltage(&voltage);  
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "batteryprogress power_:%d power:%d", power_,power); 
+        if (power == power_)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"power is not");
+            return; 
+        }  
  
-     bool MainClockView::LoadClockImage(UIImageView *view, uint32_t resId)
-     {
-         std::string file = CLOCK_IAMGES;
-         ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file);
-         if (image == nullptr)
-         {
-             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId);
-             return false;
-         }
-         view->SetSrc(image);
-         return true;
-     }
- }
- 
\ No newline at end of file
+
+        power_ = power;  
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "batteryprogress power_:%d", power_);  
+
+        if (batteryprogress != nullptr && batterylabel != nullptr) {  
+            batteryprogress->SetValue(power_);  
+            std::string batteryStr = std::to_string(power_) + "%";  
+            batterylabel->SetText(batteryStr.c_str());  
+        }  
+    }
+
+    void MainClockView::UpdateBatteryColor(void)
+    {
+        bool isCharging = get_charge_stat(); // 获取充电状态
+
+        if (isCharging)
+        {
+            if (!isBatteryIconVisible)
+            {
+                batteryicon->SetVisible(true);
+                isBatteryIconVisible = true;
+            }
+            SetViewColor(Color::Green().full); // 充电状态为绿色
+            return;
+        }
+        else
+        {
+            if (isBatteryIconVisible)
+            {
+                batteryicon->SetVisible(false);
+                isBatteryIconVisible = false;
+            }
+
+            if (power_ <= BATTERY_LOW_THRESHOLD)
+            {
+                SetViewColor(Color::Red().full);
+            }
+            else if (power_ <= BATTERY_MEDIUM_THRESHOLD)
+            {
+                SetViewColor(Color::Yellow().full);
+            }
+            else
+            {
+                if (batterySetting == BATTERY_DISPLAY_BLACK)
+                {
+                    SetViewColor(Color::Black().full);
+                }
+                else
+                {
+                    SetViewColor(Color::White().full);
+                }
+            }
+        }
+    }
+
+    void MainClockView::SetViewColor(int64_t color)
+    {
+        if (color == color_)
+        {
+            return;
+        }
+        color_ = color;
+        batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, color_);
+    }
+
+    /*刷新步数*/
+    void MainClockView::RefreshStep(int step)
+    {
+        if (stepLabel == nullptr)
+            return;
+
+        char stepChar[STEP_CHAR_NUM] = {0};
+        (void)sprintf_s(stepChar, STEP_CHAR_NUM, "%d", step);
+        stepLabel->SetText(stepChar);
+    }
+
+    /*刷新心率*/
+    void MainClockView::RefreshHeartRate(int value)
+    {
+        if (heartlabel == nullptr)
+            return;
+
+        if (value == 0)
+        {
+            heartlabel->SetText("--");
+            return;
+        }
+        char heartRateChar[STEP_CHAR_NUM] = {0};
+        (void)sprintf_s(heartRateChar, STEP_CHAR_NUM, "%d", value);
+        heartlabel->SetText(heartRateChar);
+    }
+
+    /*初始化步数*/
+    void MainClockView::InitStepValue()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue");
+        uint32_t stepValue;
+        int weekToday = ActivityModel::GetInstance()->GetWeekToday();
+        ActivityModel::GetInstance()->GetStepData((StepDataDistribute)weekToday, &stepValue);
+        char stepChar[STEP_CHAR_NUM] = {0};
+        if (sprintf_s(stepChar, STEP_CHAR_NUM, "%d", stepValue) == -1)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue error");
+            return;
+        }
+        if (stepLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue nullptr");
+            return;
+        }
+        stepLabel->SetText(stepChar);
+    }
+    /*初始化指针图片*/
+    bool MainClockView::InitCenterCircleView(void)
+    {
+
+        bigCircle = new Image();
+        if (bigCircle == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bigCircle new fail");
+            return false;
+        }
+        if (LoadClockImage(bigCircle, CLOCK_CLASSIC_GEOMETRY) == false)
+        {
+            return false;
+        }
+
+        medCircle = new Image();
+        if (medCircle == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "medCircle new fail");
+            return false;
+        }
+        if (LoadClockImage(medCircle, CLOCK_CLASSIC_GEOMETRY) == false)
+        {
+            return false;
+        }
+
+        smallCircle = new Image();
+        if (smallCircle == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "smallCircle new fail");
+            return false;
+        }
+        if (LoadClockImage(smallCircle, CLOCK_CLASSIC_GEOMETRY) == false)
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    bool MainClockView::InitHandView(void)
+    {
+        secondHand = new Image();
+        if (secondHand == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "secondHand new fail");
+            return false;
+        }
+        if (LoadClockImage(secondHand, CLOCK_CLOCK_SECOND) == false)
+        {
+            return false;
+        }
+
+        minuteHand = new Image();
+        if (minuteHand == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "minuteHand new fail");
+            return false;
+        }
+        if (LoadClockImage(minuteHand, CLOCK_CLOCK_MINUTE) == false)
+        {
+            return false;
+        }
+        hourHand = new Image();
+        if (hourHand == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hourHand new fail");
+            return false;
+        }
+        if (LoadClockImage(hourHand, CLOCK_CLOCK_HOUR) == false)
+        {
+            return false;
+        }
+
+        hand24Hour = new Image();
+        if (hand24Hour == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hand24Hour new fail");
+            return false;
+        }
+        if (LoadClockImage(hand24Hour, CLOCK_CLASSIC_GEOMETRY) == false)
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    bool MainClockView::LoadClockImage(Image *view, uint32_t resId)
+    {
+
+        std::string file = CLOCK_IAMGES;
+        ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file);
+        if (image == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId);
+            return false;
+        }
+        view->SetSrc(image);
+
+        return true;
+    }
+
+    bool MainClockView::LoadClockImage(UIImageView *view, uint32_t resId)
+    {
+        std::string file = CLOCK_IAMGES;
+        ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file);
+        if (image == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId);
+            return false;
+        }
+        view->SetSrc(image);
+        return true;
+    }
+
+    void MainClockView::ScrollBegin(bool isActive)
+    {
+        if (videoPlayer_ == nullptr)
+        {
+            return;
+        }
+        if (videoPlayer_->IsPlayed())
+        {
+            videoPlayer_->PausePlay();
+        }
+    }
+
+    void MainClockView::ScrollEnd(bool isActive)
+    {
+        if (videoPlayer_ == nullptr)
+        {
+            return;
+        }
+
+        if (isActive)
+        {
+            if (videoPlayer_->IsPaused())
+            {
+                videoPlayer_->ResumePlay();
+            }
+            else if (!videoPlayer_->IsPlayed())
+            {
+                videoPlayer_->StartPlay();
+            }
+        }
+        else
+        {
+            if (videoPlayer_->IsPaused() || videoPlayer_->IsPlayed())
+            {
+                videoPlayer_->StopPlay();
+            }
+            ClearCache();
+        }
+    }
+
+    void MainClockView::CoverBegin(bool isCovered)
+    {
+        if (videoPlayer_ == nullptr)
+        {
+            return;
+        }
+
+        if (videoPlayer_->IsPlayed())
+        {
+            videoPlayer_->PausePlay();
+        }
+    }
+
+    void MainClockView::CoverEnd(bool isCovered)
+    {
+        if (videoPlayer_ == nullptr)
+        {
+            return;
+        }
+        if (isCovered)
+        {
+            return;
+        }
+        else
+        {
+            if (videoPlayer_->IsPaused())
+            {
+                videoPlayer_->ResumePlay();
+            }
+            else if (!videoPlayer_->IsPlayed())
+            {
+                videoPlayer_->StartPlay();
+            }
+        }
+    }
+
+    void MainClockView::OnActive(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnActive");
+        if (videoPlayer_ != nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnActive videoPlayer_");
+            if (videoPlayer_->IsPaused())
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnActive videoPlayer_ resume");
+                videoPlayer_->ResumePlay();
+            }
+            else if (!videoPlayer_->IsPlayed())
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnActive videoPlayer_ start");
+                videoPlayer_->StartPlay();
+            }
+        }
+    }
+
+    void MainClockView::OnInactive(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnInactive");
+        if (videoPlayer_ != nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnInactive videoPlayer_");
+            if (!videoPlayer_->IsStopped())
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnInactive videoPlayer_ stop");
+                videoPlayer_->StopPlay();
+            }
+        }
+    }
+}