#pragma once #include "uart/ProtocolSender.h" #include "service/BusinessConfig.h" #include "restclient-cpp/restclient.h" /* *此文件由GUI工具生成 *文件功能:用于处理用户的逻辑相应代码 *功能说明: *========================onButtonClick_XXXX 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称, 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK. *========================onSlideWindowItemClick_XXXX(int index) 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称, 如slideWindow1;index 代表按下图标的偏移值 *========================onSeekBarChange_XXXX(int progress) 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称, 如SeekBar1;progress 代表当前的进度值 *========================ogetListItemCount_XXXX() 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称, 如List1;返回值为当前列表的总条数 *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index) 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称, 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明 *========================常用接口=============== *LOGD(...) 打印调试信息的接口 *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字**** *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色 *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12 *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用 *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度 * * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示 */ Json::Value deviceMenus; static std::string deviceInfoPic = "/more/shebi.png"; void setDeviceMenuTheme() { int deviceMenuThemeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt); if (deviceMenuThemeInt == 1) { deviceInfoPic = "/more/shebi.png"; } else if (deviceMenuThemeInt == 2) { deviceInfoPic = "/more/shebi-pink.png"; } else if (deviceMenuThemeInt == 3) { deviceInfoPic = "/more/shebi-green.png"; } deviceMenus[0]["icon_src"] = deviceInfoPic; mDeviceMenuListViewPtr->refreshListView(); } void getDeviceMenu() { std::string url = getHttpGateway() + "/deviceBed/get_device_menu_list/" + StoragePreferences::getString(STORE_PARTID, "") + "/4"; LOGD("请求设备菜单列表. url = %s", url.c_str()); //发起HTTP POST请求 RestClient::Response r = RestClient::get(url); if (r.code != 200) { LOGD("请求设备菜单列表-> 错误代码: %d", r.code); return; } LOGD("请求设备菜单列表. result = %s", r.body.c_str()); //解析json Json::Reader reader; Json::Value root; if(reader.parse(r.body, root, false)) { if (root.size() > 0) { int count = 0; deviceMenus.clear(); for (int i = 0; i < root.size(); i++) { if (root[i]["act_name"].asString() == "deviceInfoActivity") { count += 1; root[i]["icon_src"] = "/more/shebi.png"; deviceMenus.append(root[i]); } else if (root[i]["act_name"].asString() == "callBedActivity") { count += 1; root[i]["icon_src"] = deviceInfoPic; deviceMenus.append(root[i]); } } if (count == 0) { Json::Value deviceInfo; deviceInfo["icon_src"] = "/more/shebi.png"; deviceInfo["name"] = "设备信息"; deviceInfo["introduction"] = "查看信息和设置"; deviceInfo["act_name"] = "deviceInfoActivity"; deviceMenus.append(deviceInfo); } } } } /** * 注册定时器 * 填充数组用于注册定时器 * 注意:id不能重复 */ static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = { //{0, 6000}, //定时器id=0, 时间间隔6秒 //{1, 1000}, }; /** * 当界面构造时触发 */ static void onUI_init(){ //Tips :添加 UI初始化的显示代码到这里,如:mText1Ptr->setText("123"); deviceMenus[0]["icon_src"] = deviceInfoPic; deviceMenus[0]["name"] = "设备信息"; deviceMenus[0]["introduction"] = "查看信息和设置"; deviceMenus[0]["act_name"] = "deviceInfoActivity"; deviceMenus[1]["icon_src"] ="/more/keshi.png"; deviceMenus[1]["name"] = "呼叫床位"; deviceMenus[1]["introduction"] = "呼叫床位分机"; deviceMenus[0]["act_name"] = "callBedActivity"; // deviceMenus[1]["icon_src"] ="/more/keshi.png"; // deviceMenus[1]["name"] = "科室介绍"; // deviceMenus[1]["introduction"] = "科室详细介绍"; // // deviceMenus[2]["icon_src"] ="/more/yiyuan.png"; // deviceMenus[2]["name"] = "医院简介"; // deviceMenus[2]["introduction"] = "医院详细介绍"; // // deviceMenus[3]["icon_src"] ="/more/yiyuan.png"; // deviceMenus[3]["name"] = "医院简介"; // deviceMenus[3]["introduction"] = "医院详细介绍"; mDeviceMenuListViewPtr->refreshListView(); } /** * 当切换到该界面时触发 */ static void onUI_intent(const Intent *intentPtr) { if (intentPtr != NULL) { //TODO } } /* * 当界面显示时触发 */ static void onUI_show() { EASYUICONTEXT->showStatusBar(); EASYUICONTEXT->showNaviBar(); setDeviceMenuTheme(); } /* * 当界面隐藏时触发 */ static void onUI_hide() { } /* * 当界面完全退出时触发 */ static void onUI_quit() { } /** * 串口数据回调接口 */ static void onProtocolDataUpdate(const SProtocolData &data) { } /** * 定时器触发函数 * 不建议在此函数中写耗时操作,否则将影响UI刷新 * 参数: id * 当前所触发定时器的id,与注册时的id相同 * 返回值: true * 继续运行当前定时器 * false * 停止运行当前定时器 */ static bool onUI_Timer(int id){ switch (id) { default: break; } return true; } /** * 有新的触摸事件时触发 * 参数:ev * 新的触摸事件 * 返回值:true * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上 * false * 触摸事件将继续传递到控件上 */ static bool onmoreActivityTouchEvent(const MotionEvent &ev) { switch (ev.mActionStatus) { case MotionEvent::E_ACTION_DOWN://触摸按下 //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY); break; case MotionEvent::E_ACTION_MOVE://触摸滑动 break; case MotionEvent::E_ACTION_UP: //触摸抬起 break; default: break; } return false; } static int getListItemCount_DeviceMenuListView(const ZKListView *pListView) { //LOGD("getListItemCount_DeviceMenuListView !\n"); return deviceMenus.size(); } static void obtainListItemData_DeviceMenuListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) { //LOGD(" obtainListItemData_ DeviceMenuListView !!!\n"); pListItem->setText(deviceMenus[index]["name"].asCString()); // pListItem->findSubItemByID(ID_MORE_IntroductionSubItem)->setText(deviceMenus[index]["introduction"].asCString()); pListItem->findSubItemByID(ID_MORE_DeviceMenuPicSubItem)->setBackgroundPic(deviceMenus[index]["icon_src"].asCString()); } static void onListItemClick_DeviceMenuListView(ZKListView *pListView, int index, int id) { //LOGD(" onListItemClick_ DeviceMenuListView !!!\n"); string name = deviceMenus[index]["name"].asString(); if (name == "设备信息") { EASYUICONTEXT->openActivity("deviceInfoActivity"); } else if (name == "呼叫床位") { Intent* intent = new Intent(); intent->putExtra(functionWindows, "callBed"); EASYUICONTEXT->openActivity("functionActivity", intent); } }