-#include "UiConfig.h"\r
-\r
#include "secondaryfunction/include/QuickAccessView.h"\r
-#include "secondaryfunction/include/QuickAccessPresenter.h"\r
+#include "secondaryfunction/include/SecondaryFunctionPresenter.h"\r
namespace OHOS\r
{\r
\r
\r
QuickAccessView::QuickAccessView()\r
{\r
-\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessView");\r
g_pQuickAccessView = this;\r
}\r
\r
QuickAccessView::~QuickAccessView()\r
{\r
- DeInitView();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::~QuickAccessView");\r
+ ClearAll();\r
g_pQuickAccessView = nullptr;\r
}\r
\r
QuickAccessView *QuickAccessView::GetInstance()\r
{\r
-\r
return g_pQuickAccessView;\r
}\r
\r
- void QuickAccessView::InitView(void)\r
+ void QuickAccessView::ClearAll(void)\r
{\r
- if (container_ == nullptr)\r
+ if (initViewStatus == true)\r
{\r
- container_ = new UIViewGroup();\r
- container_->SetPosition(0, 0, 466, 466);\r
- container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(QuickAccessPresenter::GetInstance());\r
- if (draglistener == nullptr)\r
+ QuickAccessScrollView->RemoveAll();\r
+\r
+ // 循环删除 UILabel 指针数组\r
+ for (int i = 0; i < 4; i++)\r
{\r
- return;\r
+ delete QuickAccessLabel[i];\r
+ QuickAccessLabel[i] = nullptr;\r
}\r
- container_->SetOnDragListener(draglistener);\r
- container_->SetTouchable(true);\r
- container_->SetDraggable(true);\r
- }\r
- /***********************************************************************************************************/\r
- // Add QuickAccessScrollView to App\r
- if (QuickAccessScrollView == nullptr)\r
- {\r
- QuickAccessScrollView = new UIScrollView();\r
+\r
+ // 循环删除 UIImageView 和 UIRadioButton指针数组\r
+ for (int i = 0; i < 2; i++)\r
+ {\r
+ delete QuickAccessImageView[i];\r
+ QuickAccessImageView[i] = nullptr;\r
+\r
+ delete ChangeLister[i];\r
+ ChangeLister[i] = nullptr;\r
+\r
+ delete QuickAccessRadioButton[i];\r
+ QuickAccessRadioButton[i] = nullptr;\r
+ }\r
+\r
+ delete QuickAccessScrollView;\r
+ QuickAccessScrollView = nullptr;\r
}\r
- QuickAccessScrollView->SetPosition(0, 0);\r
- QuickAccessScrollView->Resize(466, 466);\r
- QuickAccessScrollView->SetViewId("QuickAccessScrollView");\r
- QuickAccessScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- // Add to rootView\r
- container_->Add(QuickAccessScrollView);\r
- QuickAccessScrollView->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add Label to App\r
- if (QuickAccessLabel == nullptr)\r
+ }\r
+\r
+ UIRadioButton *QuickAccessView::GetRadioButton(int i)\r
+ {\r
+ return QuickAccessRadioButton[i];\r
+ }\r
+\r
+ // 设置图片\r
+ UIImageView *QuickAccessView::SetUpImageView(ImageConfig &imageconfig)\r
+ {\r
+ UIImageView *Image = new UIImageView();\r
+ if (Image == nullptr)\r
{\r
- QuickAccessLabel = new UILabel();\r
+ return nullptr;\r
}\r
- QuickAccessLabel->SetPosition(173, 52);\r
- QuickAccessLabel->Resize(120, 35);\r
- QuickAccessLabel->SetViewId("QuickAccessLabel");\r
- QuickAccessLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
- QuickAccessLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- // Set additional property\r
- QuickAccessLabel->SetText("快速访问");\r
- QuickAccessLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- QuickAccessLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- QuickAccessLabel->SetRollSpeed(6);\r
- QuickAccessLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(QuickAccessLabel);\r
- QuickAccessLabel->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add Label to App\r
+ Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);\r
+ Image->SetSrc(imageconfig.ImageSrc);\r
+ return Image;\r
+ }\r
+\r
+ // 设置标签\r
+ UILabel *QuickAccessView::SetUpLabel(LabelConfig &labelconfig)\r
+ {\r
+ UILabel *label = new UILabel();\r
if (label == nullptr)\r
{\r
- label = new UILabel();\r
+ return nullptr;\r
}\r
- label->SetPosition(86, 126);\r
- label->Resize(286, 60);\r
- label->SetViewId("label");\r
- label->SetStyle(STYLE_TEXT_FONT, 26);\r
- label->SetStyle(STYLE_LINE_HEIGHT, 30);\r
- // Set additional property\r
- label->SetText("此功能可设置右下方按钮\n快速访问的APP");\r
- label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label->SetTextColor(Color::GetColorFromRGBA(0xbb, 0xbb, 0xbb, 0xff));\r
+ label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小\r
+ label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小\r
+ label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高\r
+ label->SetText(labelconfig.text); // 内容\r
+ label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。\r
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label->SetRollSpeed(6);\r
- label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(label);\r
- label->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ImageView to App\r
- if (HeartRateDetectionImage == nullptr)\r
- {\r
- HeartRateDetectionImage = new UIImageView();\r
- }\r
- HeartRateDetectionImage->SetPosition(43, 220); // widget's left position and top position\r
- HeartRateDetectionImage->Resize(380, 100); // widget's width and height\r
- HeartRateDetectionImage->SetViewId("HeartRateDetectionImage"); // Set style\r
- HeartRateDetectionImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
- HeartRateDetectionImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(HeartRateDetectionImage);\r
- HeartRateDetectionImage->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add Label to App\r
- if (HeartRateDetectionLabel == nullptr)\r
- {\r
- HeartRateDetectionLabel = new UILabel();\r
- }\r
- HeartRateDetectionLabel->SetPosition(103, 253);\r
- HeartRateDetectionLabel->Resize(120, 35);\r
- HeartRateDetectionLabel->SetViewId("HeartRateDetectionLabel");\r
- HeartRateDetectionLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
- HeartRateDetectionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- // Set additional property\r
- HeartRateDetectionLabel->SetText("心率监测");\r
- HeartRateDetectionLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- HeartRateDetectionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- HeartRateDetectionLabel->SetRollSpeed(6);\r
- HeartRateDetectionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(HeartRateDetectionLabel);\r
- HeartRateDetectionLabel->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add CheckBox to App\r
- if (HeartRateDetectionCheckBox == nullptr)\r
- {\r
- HeartRateDetectionCheckBox = new UICheckBox();\r
- }\r
- HeartRateDetectionCheckBox->SetPosition(343, 250);\r
- HeartRateDetectionCheckBox->Resize(40, 40);\r
- HeartRateDetectionCheckBox->SetViewId(HEART_RATE_DETECTION);\r
- HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- // Set additional property\r
- HeartRateDetectionCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
- // Add the CallBack about events\r
- UIView::OnClickListener *HeartRateDetectionCheckBoxClick = static_cast<UIView::OnClickListener *>(QuickAccessPresenter::GetInstance());\r
- HeartRateDetectionCheckBox->SetOnClickListener(HeartRateDetectionCheckBoxClick);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(HeartRateDetectionCheckBox);\r
- HeartRateDetectionCheckBox->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ImageView to App\r
- if (BloodOxygenMonitoringImage == nullptr)\r
- {\r
- BloodOxygenMonitoringImage = new UIImageView();\r
- }\r
- BloodOxygenMonitoringImage->SetPosition(43, 340);\r
- BloodOxygenMonitoringImage->Resize(380, 100);\r
- BloodOxygenMonitoringImage->SetViewId("BloodOxygenMonitoringImage");\r
- BloodOxygenMonitoringImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
- // Set additional property\r
- BloodOxygenMonitoringImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(BloodOxygenMonitoringImage);\r
- BloodOxygenMonitoringImage->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add CheckBox to App\r
- if (BloodOxygenMonitoringCheckBox == nullptr)\r
- {\r
- BloodOxygenMonitoringCheckBox = new UICheckBox();\r
- }\r
- BloodOxygenMonitoringCheckBox->SetPosition(343, 370);\r
- BloodOxygenMonitoringCheckBox->Resize(50, 50);\r
- BloodOxygenMonitoringCheckBox->SetViewId(BLOOD_OXYGEN_MONITOR);\r
- BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- BloodOxygenMonitoringCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
- // Add the CallBack about events\r
- UIView::OnClickListener *BloodOxygenMonitoringCheckBoxClick = static_cast<UIView::OnClickListener *>(QuickAccessPresenter::GetInstance());\r
- BloodOxygenMonitoringCheckBox->SetOnClickListener(BloodOxygenMonitoringCheckBoxClick);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(BloodOxygenMonitoringCheckBox);\r
- BloodOxygenMonitoringCheckBox->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add Label to App\r
- if (BloodOxygenMonitoringLabel == nullptr)\r
- {\r
- BloodOxygenMonitoringLabel = new UILabel();\r
- }\r
- BloodOxygenMonitoringLabel->SetPosition(103, 373);\r
- BloodOxygenMonitoringLabel->Resize(120, 35);\r
- BloodOxygenMonitoringLabel->SetViewId("BloodOxygenMonitoringLabel");\r
- BloodOxygenMonitoringLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
- BloodOxygenMonitoringLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- // Set additional property\r
- BloodOxygenMonitoringLabel->SetText("血氧监测");\r
- BloodOxygenMonitoringLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- BloodOxygenMonitoringLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- BloodOxygenMonitoringLabel->SetRollSpeed(6);\r
- BloodOxygenMonitoringLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to scrollView3\r
- QuickAccessScrollView->Add(BloodOxygenMonitoringLabel);\r
- BloodOxygenMonitoringLabel->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ImageView to App\r
- if (image1 == nullptr)\r
- {\r
- image1 = new UIImageView();\r
- }\r
- image1->SetPosition(183, 23);\r
- image1->Resize(100, 100);\r
- image1->SetViewId("image1");\r
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
+ return label;\r
+ }\r
\r
- QuickAccessScrollView->Add(image1);\r
- image1->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ImageView to App\r
- if (image2 == nullptr)\r
+ // 设置单选框\r
+ UIRadioButton *QuickAccessView::SetUpRadioButton(RadioButtonConfig &radiobuttonconfig)\r
+ {\r
+ UIRadioButton *radiobutton = new UIRadioButton("QuickAccess");\r
+ if (nullptr == radiobutton)\r
{\r
- image2 = new UIImageView();\r
+ return nullptr;\r
}\r
- image2->SetPosition(183, 423);\r
- image2->Resize(100, 100);\r
- image2->SetViewId("image2");\r
- QuickAccessScrollView->Add(image2);\r
- image2->SetVisible(true);\r
+ radiobutton->SetPosition(radiobuttonconfig.x, radiobuttonconfig.y, radiobuttonconfig.w, radiobuttonconfig.h);\r
+ radiobutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+ radiobutton->SetImages(radiobuttonconfig.select, radiobuttonconfig.unselect);\r
+ return radiobutton;\r
}\r
\r
- void QuickAccessView::DeInitView(void)\r
+ bool QuickAccessView::QuickAccessScrollViewInit(void)\r
{\r
- if (container_ != nullptr)\r
- {\r
- container_->RemoveAll();\r
- delete container_;\r
- container_ = nullptr;\r
- }\r
- if (QuickAccessScrollView != nullptr)\r
- {\r
- delete QuickAccessScrollView;\r
- QuickAccessScrollView = nullptr;\r
- }\r
- if (image1 != nullptr)\r
- {\r
- delete image1;\r
- image1 = nullptr;\r
- }\r
- if (QuickAccessLabel != nullptr)\r
- {\r
- delete QuickAccessLabel;\r
- QuickAccessLabel = nullptr;\r
- }\r
- if (image2 != nullptr)\r
- {\r
- delete image2;\r
- image2 = nullptr;\r
- }\r
- if (label != nullptr)\r
- {\r
- delete label;\r
- label = nullptr;\r
- }\r
- if (HeartRateDetectionImage != nullptr)\r
- {\r
- delete HeartRateDetectionImage;\r
- HeartRateDetectionImage = nullptr;\r
- }\r
- if (HeartRateDetectionCheckBox != nullptr)\r
- {\r
- delete HeartRateDetectionCheckBox;\r
- HeartRateDetectionCheckBox = nullptr;\r
- }\r
- if (HeartRateDetectionLabel != nullptr)\r
- {\r
- delete HeartRateDetectionLabel;\r
- HeartRateDetectionLabel = nullptr;\r
- }\r
- if (BloodOxygenMonitoringImage != nullptr)\r
- {\r
- delete BloodOxygenMonitoringImage;\r
- BloodOxygenMonitoringImage = nullptr;\r
- }\r
- if (BloodOxygenMonitoringCheckBox != nullptr)\r
+ QuickAccessScrollView = new UIScrollView();\r
+ if (QuickAccessScrollView == nullptr)\r
{\r
- delete BloodOxygenMonitoringCheckBox;\r
- BloodOxygenMonitoringCheckBox = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessScrollView new fail!");\r
+ return false;\r
}\r
- if (BloodOxygenMonitoringLabel != nullptr)\r
+ QuickAccessScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+ QuickAccessScrollView->SetScrollBlankSize(35);\r
+ QuickAccessScrollView->SetReboundSize(50);\r
+ QuickAccessScrollView->SetDirection(1);\r
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SecondaryFunctionPresenter::GetInstance());\r
+ if (draglistener == nullptr)\r
{\r
- delete BloodOxygenMonitoringLabel;\r
- BloodOxygenMonitoringLabel = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::draglistener can not be nullptr!");\r
+ return false;\r
}\r
+ QuickAccessScrollView->SetOnDragListener(draglistener);\r
+ QuickAccessScrollView->SetTouchable(true);\r
+ QuickAccessScrollView->SetDraggable(true);\r
+ return true;\r
}\r
\r
- void QuickAccessView::OnStart()\r
+ bool QuickAccessView::QuickAccessLabelInit(void)\r
{\r
- View<QuickAccessPresenter>::OnStart();\r
- InitView();\r
- RootView::GetInstance()->Add(container_);\r
+ LabelConfig labelInfos[] = {\r
+ {173, 52, 120, 35, 30, 35, "快速访问", UILabel::LINE_BREAK_ADAPT},\r
+ {86, 126, 286, 60, 26, 30, "此功能可设置右下方按钮\n快速访问的APP", UILabel::LINE_BREAK_ADAPT},\r
+ {103, 253, 120, 35, 30, 35, "心率监测", UILabel::LINE_BREAK_ADAPT},\r
+ {103, 373, 120, 35, 30, 35, "血氧监测", UILabel::LINE_BREAK_ADAPT}};\r
+\r
+ for (int i = 0; i < 4; i++)\r
+ {\r
+ LabelConfig labelconfig = {\r
+ .left = labelInfos[i].left,\r
+ .top = labelInfos[i].top,\r
+ .width = labelInfos[i].width,\r
+ .height = labelInfos[i].height,\r
+ .fontSize = labelInfos[i].fontSize,\r
+ .lineHeigh = labelInfos[i].lineHeigh,\r
+ .text = labelInfos[i].text,\r
+ .lineBreakMode = labelInfos[i].lineBreakMode};\r
+\r
+ QuickAccessLabel[i] = SetUpLabel(labelconfig);\r
+ if (nullptr == QuickAccessLabel[i])\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessLabel[%d] is nullptr!", i);\r
+ return false;\r
+ }\r
+ QuickAccessScrollView->Add(QuickAccessLabel[i]);\r
+ }\r
+\r
+ return true;\r
}\r
\r
- void QuickAccessView::OnSetUpView()\r
+ bool QuickAccessView::QuickAccessImageViewInit(void)\r
{\r
-\r
- View<QuickAccessPresenter>::OnSetUpView();\r
- Draw();\r
+ ImageConfig imageconfig = {\r
+ .x = 43,\r
+ .y = 220,\r
+ .w = 380,\r
+ .h = 100,\r
+ .ImageSrc = "/user/res/SETTING_BACKGROUND.bin",\r
+ };\r
+\r
+ for (int i = 0; i < 2; i++)\r
+ {\r
+ imageconfig.y = 220 + (i * 120);\r
+ QuickAccessImageView[i] = SetUpImageView(imageconfig);\r
+ if (QuickAccessImageView[i] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessImageView[%d] is nullptr!", i);\r
+ return false;\r
+ }\r
+ QuickAccessScrollView->Add(QuickAccessImageView[i]);\r
+ }\r
+ return true;\r
}\r
\r
- void QuickAccessView::OnTearDownView()\r
+ bool QuickAccessView::QuickAccessRadioButtonInit(void)\r
{\r
-\r
- View<QuickAccessPresenter>::OnTearDownView();\r
- return;\r
+ RadioButtonConfig radiobuttonconfig = {\r
+ .x = 300,\r
+ .y = 230,\r
+ .w = 80,\r
+ .h = 80,\r
+ .select = "/user/res/CHECKBOX_ON.bin",\r
+ .unselect = "/user/res/CHECKBOX_OFF.bin",\r
+ };\r
+\r
+ for (int i = 0; i < 2; i++)\r
+ {\r
+ radiobuttonconfig.y = 230 + (i * 120);\r
+ QuickAccessRadioButton[i] = SetUpRadioButton(radiobuttonconfig);\r
+ if (QuickAccessRadioButton[i] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessRadioButton[%d] is nullptr!", i);\r
+ return false;\r
+ }\r
+ ChangeLister[i] = static_cast<UICheckBox::OnChangeListener *>(new QuickAccessRadioButtonChangeLister(QuickAccessRadioButton[i]));\r
+ QuickAccessRadioButton[i]->SetOnChangeListener(ChangeLister[i]);\r
+ QuickAccessScrollView->Add(QuickAccessRadioButton[i]);\r
+ }\r
+ return true;\r
}\r
\r
- void QuickAccessView::OnStop()\r
+ UIScrollView *QuickAccessView::QuickAccessViewInit(void)\r
{\r
+ if (!QuickAccessScrollViewInit())\r
+ {\r
+ return nullptr;\r
+ }\r
\r
- View<QuickAccessPresenter>::OnStop();\r
- RootView::GetInstance()->RemoveAll();\r
- return;\r
+ if (!QuickAccessImageViewInit())\r
+ {\r
+ return nullptr;\r
+ }\r
+\r
+ if (!QuickAccessLabelInit())\r
+ {\r
+ return nullptr;\r
+ }\r
+\r
+ if (!QuickAccessRadioButtonInit())\r
+ {\r
+ return nullptr;\r
+ }\r
+\r
+ initViewStatus = true;\r
+ return QuickAccessScrollView;\r
}\r
+\r
}
\ No newline at end of file
{\r
if (initViewStatus == true)\r
{\r
- SecondaryFunctionScrollView->RemoveAll();\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->RemoveAll();\r
\r
delete SecondaryFunctionScrollTitleLabel;\r
SecondaryFunctionScrollTitleLabel = nullptr;\r
Image[i] = nullptr;\r
}\r
\r
- delete SecondaryFunctionScrollView;\r
- SecondaryFunctionScrollView = nullptr;\r
+ delete p_QuickAccessView;\r
+ p_QuickAccessView = nullptr;\r
+\r
+ delete SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW];\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW] = nullptr;\r
}\r
}\r
\r
\r
bool SecondaryFunctionView::SecondaryFunctionScrollViewInit(void)\r
{\r
- SecondaryFunctionScrollView = new UIScrollView();\r
- if (SecondaryFunctionScrollView == nullptr)\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW] = new UIScrollView();\r
+ if (SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW] == nullptr)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::SecondaryFunctionScrollView new fail!");\r
return false;\r
}\r
- SecondaryFunctionScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetScrollBlankSize(35);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetReboundSize(50);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetDirection(1);\r
UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SecondaryFunctionPresenter::GetInstance());\r
if (draglistener == nullptr)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::draglistener can not be nullptr!");\r
return false;\r
}\r
- SecondaryFunctionScrollView->SetOnDragListener(draglistener);\r
- SecondaryFunctionScrollView->SetTouchable(true);\r
- SecondaryFunctionScrollView->SetDraggable(true);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetOnDragListener(draglistener);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetTouchable(true);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetDraggable(true);\r
return true;\r
}\r
\r
\r
bool SecondaryFunctionView::SecondaryFunctionScrollLabelInit(void)\r
{\r
- // 创建ScreenDurationTitleLabel\r
LabelConfig labelconfig = {\r
.left = 173,\r
.top = 52,\r
initViewStatus = true;\r
}\r
\r
+ QuickAccessView *SecondaryFunctionView::GetQuickAccessView(void)\r
+ {\r
+ return p_QuickAccessView;\r
+ }\r
+\r
+ UIScrollView *SecondaryFunctionView::GetSecondaryFunctionScrollView(int i)\r
+ {\r
+ return SecondaryFunctionScrollView[i];\r
+ }\r
+\r
+ // 切换到辅助功能视图\r
+ bool SecondaryFunctionView::ChangeSecondaryFunctionView(int16_t thisView)\r
+ {\r
+ if (SecondaryFunctionScrollView[thisView] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::ChangeSecondaryFunctionView");\r
+ RootView::GetInstance()->Add(SecondaryFunctionScrollView[thisView]);\r
+ }\r
+ return true;\r
+ }\r
+\r
+ // 切换到快速访问视图\r
+ bool SecondaryFunctionView::ChangeQuickAccessView(int16_t thisView)\r
+ {\r
+ if (SecondaryFunctionScrollView[thisView] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::ChangeQuickAccessView");\r
+ p_QuickAccessView = new QuickAccessView();\r
+ if (p_QuickAccessView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView:: new scrollView[%d] fail", thisView);\r
+ return false;\r
+ }\r
+ SecondaryFunctionScrollView[thisView] = p_QuickAccessView->QuickAccessViewInit();\r
+ RootView::GetInstance()->Add(SecondaryFunctionScrollView[thisView]);\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /* -------------------------------------------------------------------------- */\r
+ // 1.SecondaryFunctionViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。\r
+ struct SecondaryFunctionViewMapper\r
+ {\r
+ const int16_t viewId;\r
+ bool (SecondaryFunctionView::*func)(int16_t thisView);\r
+ };\r
+\r
+ // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与SecondaryFunctionView类中的特定成员函数指针进行了绑定。\r
+ static const SecondaryFunctionViewMapper ViewMapper[] = {\r
+ {SECONDARYFUNCTIONVIEW, &SecondaryFunctionView::ChangeSecondaryFunctionView},\r
+ {QUICKACCESSVIEW, &SecondaryFunctionView::ChangeQuickAccessView},\r
+ };\r
+\r
+ // 3.根据传入的interface参数执行相应视图ID关联的成员函数。\r
+ bool SecondaryFunctionView::ClickFunc(int16_t interface)\r
+ {\r
+ int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);\r
+ for (int i = 0; i < funcSize; i++)\r
+ {\r
+ if (interface == ViewMapper[i].viewId)\r
+ {\r
+ bool jug = (this->*(ViewMapper[i].func))(interface);\r
+ if (jug == false)\r
+ {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ // 4.切换视图\r
+ void SecondaryFunctionView::ChangeView(int16_t hideView, int16_t showView)\r
+ {\r
+ if (hideView > MAX_SECONDARYFUNCTIONVIEWID)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView:: SECONDARYFUNCTIONVIEWID Overstep ones bounds");\r
+ return;\r
+ }\r
+ SecondaryFunctionScrollView[hideView]->SetVisible(false);\r
+ ClickFunc(showView);\r
+ SecondaryFunctionScrollView[showView]->SetVisible(true);\r
+ Draw();\r
+ }\r
+ /* -------------------------------------------------------------------------- */\r
+\r
void SecondaryFunctionView::OnStart()\r
{\r
View<SecondaryFunctionPresenter>::OnStart();\r
void SecondaryFunctionView::OnSetUpView()\r
{\r
View<SecondaryFunctionPresenter>::OnSetUpView();\r
- SecondaryFunctionScrollView->Add(SecondaryFunctionScrollTitleLabel);\r
- SecondaryFunctionScrollView->Add(QuickAccessButton);\r
- SecondaryFunctionScrollView->Add(FastTrainingButton);\r
- SecondaryFunctionScrollView->Add(QuickAccessLabel);\r
- SecondaryFunctionScrollView->Add(FastTrainingLabel);\r
- SecondaryFunctionScrollView->Add(Image[0]);\r
- SecondaryFunctionScrollView->Add(Image[1]);\r
- RootView::GetInstance()->Add(SecondaryFunctionScrollView);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(SecondaryFunctionScrollTitleLabel);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(QuickAccessButton);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(FastTrainingButton);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(QuickAccessLabel);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(FastTrainingLabel);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(Image[0]);\r
+ SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(Image[1]);\r
+ RootView::GetInstance()->Add(SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]);\r
Draw();\r
}\r
\r