fe9cd72c0952bbbcfe3febe11582dfaa9ae74ae5
[mirrors/FD230.git] /
1 /***
2  * @Author: Caisking 3449750381@qq.com
3  * @Date: 2024-03-19 17:37:19
4  * @LastEditors: Caisking 3449750381@qq.com
5  * @LastEditTime: 2024-03-26 19:51:06
6  * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDancePresenter.cpp
7  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8  */
9 /***
10  * @Author: Caisking 3449750381@qq.com
11  * @Date: 2024-03-19 17:37:19
12  * @LastEditors: Caisking 3449750381@qq.com
13  * @LastEditTime: 2024-03-26 14:23:32
14  * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/src/TraingDancePresenter.cpp
15  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
16  */
17
18 #include "AppViewIDs.h"
19 #include "NativeAbility.h"
20
21 #include <iostream>
22 #include <chrono>
23 #include <thread>
24 #include "traing/training_list_dance/include/TraingDanceItemView.h"
25 #include "traing/training_list_dance/include/TraingDancePresenter.h"
26 #include "traing/training_list_dance/include/TraingDanceView.h"
27 // #include "TraingDanceView.h"
28
29 namespace OHOS
30 {
31     extern const char *Dance_buttons[];
32     extern char *Dance_text[];
33
34     // 当前Presenter属性实例化的内存指针
35     static TraingDancePresenter *g_pTraingDancePresenter = nullptr;
36
37     TraingDancePresenter::TraingDancePresenter()
38     {
39         p_TraingDanceModel = &TraingDanceModel::GetInstance();
40         g_pTraingDancePresenter = this;
41     }
42
43     TraingDancePresenter::~TraingDancePresenter()
44     {
45
46         g_pTraingDancePresenter = nullptr;
47     }
48
49     TraingDancePresenter *TraingDancePresenter::GetInstance()
50     {
51
52         return g_pTraingDancePresenter;
53     }
54
55     void TraingDancePresenter::OnStart()
56     {
57         p_TraingDanceModel->InitTraingDanceListItem();
58         Presenter<TraingDanceView>::OnStart();
59     }
60
61     void TraingDancePresenter::OnPause(void)
62     {
63         Presenter<TraingDanceView>::OnPause();
64     }
65
66     void TraingDancePresenter::OnResume(void)
67     {
68         if (view_ == nullptr)
69         {
70             return;
71         }
72         const TraingDanceItem *itemInfo = p_TraingDanceModel->GetTraingDancelistItems();
73         for (int i = 0; i < p_TraingDanceModel->GetTraingDanceListNum(); i++)
74         {
75             view_->AddToTraingDanceList(itemInfo[i]);
76         }
77         Presenter<TraingDanceView>::OnResume();
78     }
79
80     void TraingDancePresenter::OnStop(void)
81     {
82
83         Presenter<TraingDanceView>::OnStop();
84     }
85     bool TraingDancePresenter::OnDrag(UIView &view, const DragEvent &event)
86     {
87         return true;
88     }
89     bool TraingDancePresenter::OnDragEnd(UIView &view, const DragEvent &event)
90     {
91         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
92         {
93             NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);
94         }
95         UNUSED(view);
96         return true;
97     }
98
99     bool TraingDancePresenter::OnClick(UIView &view, const ClickEvent &event)
100     {
101         UNUSED(event);
102         TraingDanceItemView *itemView = static_cast<TraingDanceItemView *>(&view);
103         AppViewId viewId = itemView->GetTraingDanceIndex();
104         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
105         if (viewId < VIEW_MAX_INTER_APP)
106         {
107             NativeAbility::GetInstance().ChangeSlice(viewId);
108             return true;
109         }
110         return false;
111     }
112
113 }