extern addressbook addressbook_t;\r
PhoneDirView::PhoneDirView()\r
{\r
-\r
g_pPhoneDirView = this;\r
}\r
\r
{\r
return g_pPhoneDirView;\r
}\r
- static char *number_str[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};\r
+ static char *number_str[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"};\r
UILabelButtonExt *PhoneDirView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener)\r
{\r
UILabelButtonExt *button = new UILabelButtonExt();\r
}\r
button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);\r
button->SetViewId(buttonconfig.ViewId);\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---",buttonconfig.ViewId);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---", buttonconfig.ViewId);\r
button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
\r
- if(buttonconfig.ImageSrc)\r
- button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc);\r
+ if (buttonconfig.ImageSrc)\r
+ button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc);\r
\r
- //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED);\r
- if(clickListener!=NULL)\r
- button->SetOnClickListener(clickListener);\r
+ // button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED);\r
+ if (clickListener != NULL)\r
+ button->SetOnClickListener(clickListener);\r
\r
button->SetText(buttonconfig.str);\r
button->SetAlign(TEXT_ALIGNMENT_LEFT);\r
- button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );\r
+ button->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y);\r
button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize);\r
button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED);\r
\r
return button;\r
}\r
\r
- \r
- void PhoneDirView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc)\r
+ void PhoneDirView::initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc)\r
{\r
/* -------------------------------------------------------------------------- */\r
UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
buttonconfig.w = w;\r
buttonconfig.h = h;\r
\r
- int len =addressbook_t.num;\r
+ int len = addressbook_t.num;\r
\r
- for(int i=0;i<len;i++)\r
+ for (int i = 0; i < len; i++)\r
{\r
- buttonconfig.str="";\r
+ buttonconfig.str = "";\r
label[i] = new UILabelExt();\r
- label[i]->SetPosition(x+107, buttonconfig.y+33); // widget's left position and top position\r
- label[i]->Resize(210, 35); // widget's width and height\r
- label[i]->SetViewId("label1");// Set style\r
+ label[i]->SetPosition(x + 107, buttonconfig.y + 33); \r
+ label[i]->Resize(210, 35); \r
+ label[i]->SetViewId("label1"); \r
label[i]->SetStyle(STYLE_TEXT_FONT, 30);\r
\r
// Set additional property\r
label[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
label[i]->SetVisible(true);\r
\r
- //char buf[32]={0};\r
- //sprintf(buf,"1",i);\r
- //buf[0]=i+48;\r
- buttonconfig.ViewId =number_str[i];\r
- \r
- buttonconfig.ImageSrc = addressbook_t.Contact_t[i].sex==1 ? PHONE_DIR_BOY:PHONE_DIR_GIRL;\r
- buttonconfig.label_x=107;\r
- buttonconfig.label_y=0;\r
- buttonconfig.Fontsize=30;\r
- buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
+ // char buf[32]={0};\r
+ // sprintf(buf,"1",i);\r
+ // buf[0]=i+48;\r
+ buttonconfig.ViewId = number_str[i];\r
+\r
+ buttonconfig.ImageSrc = addressbook_t.Contact_t[i].sex == 1 ? PHONE_DIR_BOY : PHONE_DIR_GIRL;\r
+ buttonconfig.label_x = 107;\r
+ buttonconfig.label_y = 0;\r
+ buttonconfig.Fontsize = 30;\r
+ buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT;\r
button[i] = SetTheButton_ext(buttonconfig, clickListener);\r
\r
- buttonconfig.y+=interval;\r
+ buttonconfig.y += interval;\r
scrollview_->Add(button[i]);\r
scrollview_->Add(label[i]);\r
}\r
onepage_address_init();\r
- /* -------------------------------------------------------------------------- */ \r
+ /* -------------------------------------------------------------------------- */\r
}\r
\r
- void PhoneDirView :: onepage_address_init(void)\r
+ void PhoneDirView ::onepage_address_init(void)\r
{\r
- if (container_one_page == nullptr) {\r
- container_one_page = new UIScrollView();\r
- container_one_page->SetPosition(0, 0,Screen::GetInstance().GetWidth(),Screen::GetInstance().GetHeight());\r
- //container_one_page->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+ if (container_one_page == nullptr)\r
+ {\r
+ container_one_page = new UIScrollView();\r
+ if(container_one_page == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: container new fail!");\r
+ return;\r
+ }\r
+ }\r
+ container_one_page->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
container_one_page->SetViewId("container_one_page");\r
container_one_page->SetScrollBlankSize(35);\r
- //container_one_page->SetReboundSize(50);\r
container_one_page->SetDirection(1);\r
- }\r
- \r
- // Add Label to App\r
- if (label1_phone_name == nullptr) {\r
+ container_one_page->SetOnDragListener(presenter_);\r
+ container_one_page->SetVisible(false);\r
+ container_one_page->SetDraggable(true);\r
+ container_one_page->SetTouchable(true);\r
+ AddViewToRootContainer(container_one_page);\r
+ /* -------------------------------------------------------------------------- */\r
+ if (label1_phone_name == nullptr)\r
+ {\r
label1_phone_name = new UILabelExt();\r
+ if(label1_phone_name == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: label1_phone_name new fail!");\r
+ return;\r
+ }\r
}\r
- label1_phone_name->SetPosition(128, 52); // widget's left position and top position\r
- label1_phone_name->Resize(210, 30); // widget's width and height\r
- label1_phone_name->SetViewId("label1");// Set style\r
+ label1_phone_name->SetPosition(128, 52); \r
+ label1_phone_name->Resize(210, 30); \r
label1_phone_name->SetStyle(STYLE_TEXT_FONT, 30);\r
-\r
- // Set additional property\r
label1_phone_name->SetText(addressbook_t.Contact_t[0].name);\r
label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
label1_phone_name->SetRollSpeed(23);\r
label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
- // Add to rootView\r
container_one_page->Add(label1_phone_name);\r
label1_phone_name->SetVisible(true);\r
- \r
- // Add ImageView to App\r
- if (phone_name == nullptr) {\r
+ /* -------------------------------------------------------------------------- */\r
+ if (phone_name == nullptr)\r
+ {\r
phone_name = new UIImageView();\r
+ if(phone_name == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: phone_name new fail!");\r
+ return;\r
+ }\r
}\r
- phone_name->SetPosition(158, 107); // widget's left position and top position\r
- // phone_name->Resize(150, 150); // widget's width and height\r
- phone_name->SetViewId("phone_sex");// Set style\r
-\r
+ phone_name->SetPosition(158, 107); \r
+ phone_name->SetViewId("phone_sex");\r
+ phone_name->SetVisible(true);\r
image_boy = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_BOY_1);\r
-\r
image_girl = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_GIRL_1);\r
-\r
- phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl);\r
-\r
-\r
-\r
+ phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy : image_girl);\r
container_one_page->Add(phone_name);\r
- phone_name->SetVisible(true);\r
- container_one_page->SetVisible(false);\r
- container_one_page->SetDraggable(true);\r
- container_one_page->SetTouchable(true);\r
- \r
-\r
-\r
-\r
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
/* -------------------------------------------------------------------------- */\r
ButtonConfig_ext_t buttonconfig;\r
buttonconfig.x = 43;\r
buttonconfig.w = 380;\r
buttonconfig.h = 100;\r
\r
- int len =addressbook_t.Contact_t[0].phone_num;\r
-\r
- for(int i=0;i<2;i++)\r
+ int len = addressbook_t.Contact_t[0].phone_num;\r
+ for (int i = 0; i < 2; i++)\r
{\r
- buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number;\r
- buttonconfig.ViewId =addressbook_t.Contact_t[0].phone_number_t[0].number;\r
- buttonconfig.ImageSrc=nullptr;\r
- buttonconfig.label_x=50;\r
- buttonconfig.label_y=0;\r
- buttonconfig.Fontsize=30;\r
- buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
- number_button[i] = SetTheButton_ext(buttonconfig,clickListener);\r
- buttonconfig.y+=120;\r
+ buttonconfig.str = addressbook_t.Contact_t[0].phone_number_t[0].number;\r
+ buttonconfig.ViewId = addressbook_t.Contact_t[0].phone_number_t[0].number;\r
+ buttonconfig.ImageSrc = nullptr;\r
+ buttonconfig.label_x = 50;\r
+ buttonconfig.label_y = 0;\r
+ buttonconfig.Fontsize = 30;\r
+ buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT;\r
+ number_button[i] = SetTheButton_ext(buttonconfig, presenter_);\r
+ buttonconfig.y += 120;\r
container_one_page->Add(number_button[i]);\r
}\r
-\r
-\r
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(PhoneDirPresenter::GetInstance());\r
- if (draglistener == nullptr)\r
+ /* -------------------------------------------------------------------------- */\r
+ if (phone_name_ == nullptr)\r
{\r
- return;\r
- }\r
- container_one_page->SetOnDragListener(draglistener);\r
-\r
- if (phone_name_ == nullptr) {\r
phone_name_ = new UIImageView();\r
+ if(phone_name_ == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::phone_name_ new fail");\r
+ return;\r
+ }\r
}\r
- phone_name_->SetPosition(0, 520); // widget's left position and top position\r
- phone_name_->Resize(466, 30); // widget's width and height\r
- phone_name_->SetViewId("phone_sex");// Set style\r
-\r
- container_one_page->Add(phone_name_);\r
-\r
+ phone_name_->SetPosition(0, 520); \r
+ phone_name_->Resize(466, 30); \r
+ phone_name_->SetViewId("phone_sex");\r
phone_name_->SetVisible(true);\r
-\r
- \r
+ container_one_page->Add(phone_name_);\r
return;\r
- \r
}\r
\r
bool PhoneDirView::get_container_one_page_is_Visible()\r
return container_one_page->IsVisible();\r
}\r
\r
-\r
void PhoneDirView::Set_onepage_address(const char *idstr)\r
{\r
- if(strcmp("container_one_page",idstr)==0)\r
+ if (strcmp("container_one_page", idstr) == 0)\r
{\r
scrollview_->SetVisible(true);\r
container_one_page->SetVisible(false);\r
return;\r
-\r
}\r
container_one_page->ScrollBy(0, 100);\r
scrollview_->SetVisible(false);\r
container_one_page->SetVisible(true);\r
- uint8_t id= atoi(idstr);//idstr[16];\r
- if(id>=20)\r
+ uint8_t id = atoi(idstr); // idstr[16];\r
+ if (id >= 20)\r
{\r
return;\r
}\r
\r
- if(addressbook_t.Contact_t[id].name) \r
- label1_phone_name->SetText(addressbook_t.Contact_t[id].name);\r
+ if (addressbook_t.Contact_t[id].name)\r
+ label1_phone_name->SetText(addressbook_t.Contact_t[id].name);\r
\r
label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
\r
- phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl);\r
+ phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy : image_girl);\r
\r
- int len =addressbook_t.Contact_t[id].phone_num;\r
+ int len = addressbook_t.Contact_t[id].phone_num;\r
\r
- for(int i=0;i<len;i++)\r
+ for (int i = 0; i < len; i++)\r
{\r
number_button[i]->SetVisible(true);\r
- if(addressbook_t.Contact_t[id].phone_number_t[i].number)\r
+ if (addressbook_t.Contact_t[id].phone_number_t[i].number)\r
{\r
number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number);\r
number_button[i]->SetViewId(addressbook_t.Contact_t[id].phone_number_t[i].number);\r
}\r
}\r
\r
- if(len<2)\r
+ if (len < 2)\r
{\r
number_button[1]->SetVisible(false);\r
}\r
- RootView::GetInstance()->Invalidate();\r
+ RootView::GetInstance()->Invalidate();\r
return;\r
}\r
- \r
-\r
\r
void PhoneDirView::DeInit()\r
{\r
scrollview_->ClearFocus();\r
delete scrollview_;\r
scrollview_ = nullptr;\r
- \r
- if(label1_)\r
+\r
+ if (label1_)\r
{\r
delete label1_;\r
label1_ = nullptr;\r
}\r
- for(int i=0;i<addressbook_t.num;i++)\r
- { \r
- if( button[i])\r
+ for (int i = 0; i < addressbook_t.num; i++)\r
+ {\r
+ if (button[i])\r
{\r
- delete button[i];\r
+ delete button[i];\r
button[i] = nullptr;\r
}\r
}\r
\r
- for(int i=0;i<addressbook_t.num;i++)\r
- { \r
- if( label[i])\r
+ for (int i = 0; i < addressbook_t.num; i++)\r
+ {\r
+ if (label[i])\r
{\r
- delete label[i];\r
+ delete label[i];\r
label[i] = nullptr;\r
}\r
}\r
- \r
\r
- if(container_one_page)\r
+ if (container_one_page)\r
{\r
container_one_page->RemoveAll();\r
delete container_one_page;\r
container_one_page = nullptr;\r
\r
- if(phone_name)\r
+ if (phone_name)\r
{\r
delete phone_name;\r
phone_name = nullptr;\r
}\r
- if(phone_name_)\r
+ if (phone_name_)\r
{\r
delete phone_name_;\r
phone_name_ = nullptr;\r
}\r
\r
-\r
- \r
ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_BOY_1);\r
-\r
ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_GIRL_1);\r
\r
- if(label1_phone_name)\r
+ if (label1_phone_name)\r
{\r
delete label1_phone_name;\r
label1_phone_name = nullptr;\r
}\r
\r
- for(int i=0;i<2;i++)\r
- { \r
- if( number_button[i])\r
+ for (int i = 0; i < 2; i++)\r
+ {\r
+ if (number_button[i])\r
{\r
- delete number_button[i];\r
+ delete number_button[i];\r
number_button[i] = nullptr;\r
}\r
}\r
-\r
}\r
- \r
- if(label1_no)\r
+\r
+ if (label1_no)\r
{\r
delete label1_no;\r
- label1_no=nullptr;\r
+ label1_no = nullptr;\r
}\r
- if(label2_no)\r
+ if (label2_no)\r
{\r
delete label2_no;\r
- label2_no=nullptr;\r
+ label2_no = nullptr;\r
}\r
- if(image1_no)\r
+ if (image1_no)\r
{\r
delete image1_no;\r
- image1_no=nullptr;\r
+ image1_no = nullptr;\r
}\r
}\r
}\r
\r
-\r
UIView *PhoneDirView::GetView()\r
{\r
if (label1_no == nullptr)\r
{\r
label1_no = new UILabelExt();\r
}\r
- label1_no->SetPosition(158, 52); // widget's left position and top position\r
- label1_no->Resize(200, 60); // widget's width and height\r
- label1_no->SetViewId("label1"); // Set style\r
+ label1_no->SetPosition(158, 52); \r
+ label1_no->Resize(200, 60); \r
+ label1_no->SetViewId("label1"); \r
label1_no->SetStyle(STYLE_TEXT_FONT, 30);\r
\r
// Set additional property\r
{\r
label2_no = new UILabelExt();\r
}\r
- label2_no->SetPosition(76, 310); // widget's left position and top position\r
- label2_no->Resize(312, 70); // widget's width and height\r
- label2_no->SetViewId("label2"); // Set style\r
+ label2_no->SetPosition(76, 310); \r
+ label2_no->Resize(312, 70); \r
+ label2_no->SetViewId("label2"); \r
label2_no->SetStyle(STYLE_TEXT_FONT, 26);\r
\r
// Set additional property\r
{\r
image1_no = new UIImageView();\r
}\r
- image1_no->SetPosition(158, 120); // widget's left position and top position\r
- image1_no->Resize(150, 150); // widget's width and height\r
- image1_no->SetViewId("image1"); // Set style\r
+ image1_no->SetPosition(158, 120); \r
+ image1_no->Resize(150, 150); \r
+ image1_no->SetViewId("image1"); \r
\r
// Set additional property\r
\r
}\r
void PhoneDirView::OnStart()\r
{\r
- scrollview_ = new UIScrollView();\r
- if (scrollview_ == nullptr)\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::OnStart");\r
+ if(scrollview_ == nullptr)\r
{\r
- return;\r
+ scrollview_ = new UIScrollView();\r
+ if (scrollview_ == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::scrollview_ new fail");\r
+ return;\r
+ }\r
}\r
scrollview_->SetPosition(0, 0);\r
scrollview_->SetWidth(Screen::GetInstance().GetWidth());\r
scrollview_->SetHeight(Screen::GetInstance().GetHeight());\r
-\r
scrollview_->SetScrollBlankSize(35);\r
scrollview_->SetReboundSize(35);\r
scrollview_->SetDirection(1);\r
scrollview_->SetMaxScrollDistance(500);\r
scrollview_->SetThrowDrag(true);\r
scrollview_->RequestFocus();\r
- // 创建 draglistener 实例并设置为拖动监听器\r
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(PhoneDirPresenter::GetInstance());\r
- if (draglistener == nullptr)\r
- {\r
- return;\r
- }\r
- scrollview_->SetOnDragListener(draglistener);\r
-\r
+ scrollview_->SetOnDragListener(presenter_);\r
scrollview_->SetTouchable(true);\r
scrollview_->SetDraggable(true);\r
- //read_addressbook_bin_file();\r
-\r
+ AddViewToRootContainer(scrollview_);\r
\r
- if (label1_ == nullptr) {\r
- label1_ = new UILabelExt();\r
+ if (label1_ == nullptr)\r
+ {\r
+ label1_ = new UILabelExt();\r
+ if(label1_ == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::label1_ new fail");\r
+ return;\r
+ }\r
}\r
- label1_->SetPosition(0, 18); // widget's left position and top position\r
- label1_->Resize(466, 88); // widget's width and height\r
- label1_->SetViewId("label1");// Set style\r
+ label1_->SetPosition(0, 18); \r
+ label1_->Resize(466, 88); \r
label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
-\r
label1_->SetTextId(STR_FRE_CONTACT);\r
label1_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
label1_->SetTextId(STR_FAVORITE_CONTACTS);\r
- //label1_->SetTextColor(Color::GetColorFromRGBA(0xac, 0xa4, 0xa4, 0xff));\r
label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
label1_->SetRollSpeed(0);\r
label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
scrollview_->Add(label1_);\r
\r
- if(addressbook_t.num<=0 ||addressbook_t.num>20)\r
+ if (addressbook_t.num <= 0 || addressbook_t.num > 20)\r
{\r
GetView();\r
}\r
else\r
{\r
- initView_ext(43,123,380,100,120,NULL);\r
- }\r
- \r
-\r
- \r
-\r
- AddViewToRootContainer(scrollview_);\r
- if(container_one_page)\r
- {\r
- if (draglistener == nullptr)\r
- {\r
- return;\r
- }\r
- container_one_page->SetOnDragListener(draglistener);\r
+ initView_ext(43, 123, 380, 100, 120, NULL);\r
}\r
- AddViewToRootContainer(container_one_page);\r
-\r
- \r
-\r
- // 增加按键监听\r
- RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneDirPresenter::GetInstance();\r
- RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
+ RootView::GetInstance()->SetOnKeyActListener(presenter_);\r
}\r
\r
- \r
}\r