123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- /***********************************************
- /gen auto by zuitools
- ***********************************************/
- #include "deviceInfoActivity.h"
- /*TAG:GlobalVariable全局变量*/
- static ZKTextView* mScanQRCodeTextViewPtr;
- static ZKPainter* mQRCodePicPainterPtr;
- static ZKQRCode* mQRCodePtr;
- static ZKPainter* mQRCodePainterPtr;
- static ZKTextView* mDeviceInfoTextViewPtr;
- static ZKPainter* mDeviceInfoPicPainterPtr;
- static ZKPainter* mDeviceInfoPainterPtr;
- static ZKPainter* mRestartPainterPtr;
- static ZKButton* mRestartButtonPtr;
- static ZKPainter* mVersionPainterPtr;
- static ZKButton* mVersionButtonPtr;
- static ZKPainter* mSettingPainterPtr;
- static ZKButton* mNetworkButtonPtr;
- static ZKPainter* mServerPicPainterPtr;
- static ZKButton* mServerButtonPtr;
- static ZKPainter* mNetworkPainterPtr;
- static ZKTextView* mDebugTextViewPtr;
- static ZKPainter* mDebugPicPainterPtr;
- static ZKPainter* mDebugPainterPtr;
- static ZKButton* mSettingButtonPtr;
- static ZKTextView* mServerIPPtr;
- static ZKTextView* mServerIpTextViewPtr;
- static ZKTextView* mVersionPtr;
- static ZKTextView* mVersionTextViewPtr;
- static ZKTextView* mVoiceDomainPtr;
- static ZKTextView* mVoiceDomainTextViewPtr;
- static ZKTextView* mVoiceIdPtr;
- static ZKTextView* mVoiceIdTextViewPtr;
- static ZKTextView* mGatewayPtr;
- static ZKTextView* mGatewayTextViewPtr;
- static ZKTextView* mNetMaskPtr;
- static ZKTextView* mNetMaskTextViewPtr;
- static ZKTextView* mDeviceIpPtr;
- static ZKTextView* mDeviceIpTextViewPtr;
- static ZKTextView* mDeviceMacPtr;
- static ZKTextView* mMACTextViewPtr;
- static ZKTextView* mDeviceCodePtr;
- static ZKTextView* mDeviceSignTextViewPtr;
- static ZKTextView* mDeviceIdPtr;
- static ZKTextView* mDeviceIdTextViewPtr;
- static deviceInfoActivity* mActivityPtr;
- /*register activity*/
- REGISTER_ACTIVITY(deviceInfoActivity);
- typedef struct {
- int id; // 定时器ID , 不能重复
- int time; // 定时器 时间间隔 单位 毫秒
- }S_ACTIVITY_TIMEER;
- #include "logic/deviceInfoLogic.cc"
- /***********/
- typedef struct {
- int id;
- const char *pApp;
- } SAppInfo;
- /**
- *点击跳转window
- */
- static SAppInfo sAppInfoTab[] = {
- // { ID_MAIN_TEXT, "TextViewActivity" },
- };
- /***************/
- typedef bool (*ButtonCallback)(ZKButton *pButton);
- /**
- * button onclick表
- */
- typedef struct {
- int id;
- ButtonCallback callback;
- }S_ButtonCallback;
- /*TAG:ButtonCallbackTab按键映射表*/
- static S_ButtonCallback sButtonCallbackTab[] = {
- ID_DEVICEINFO_RestartButton, onButtonClick_RestartButton,
- ID_DEVICEINFO_VersionButton, onButtonClick_VersionButton,
- ID_DEVICEINFO_NetworkButton, onButtonClick_NetworkButton,
- ID_DEVICEINFO_ServerButton, onButtonClick_ServerButton,
- ID_DEVICEINFO_SettingButton, onButtonClick_SettingButton,
- };
- /***************/
- typedef void (*SeekBarCallback)(ZKSeekBar *pSeekBar, int progress);
- typedef struct {
- int id;
- SeekBarCallback callback;
- }S_ZKSeekBarCallback;
- /*TAG:SeekBarCallbackTab*/
- static S_ZKSeekBarCallback SZKSeekBarCallbackTab[] = {
- };
- typedef int (*ListViewGetItemCountCallback)(const ZKListView *pListView);
- typedef void (*ListViewobtainListItemDataCallback)(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index);
- typedef void (*ListViewonItemClickCallback)(ZKListView *pListView, int index, int id);
- typedef struct {
- int id;
- ListViewGetItemCountCallback getListItemCountCallback;
- ListViewobtainListItemDataCallback obtainListItemDataCallback;
- ListViewonItemClickCallback onItemClickCallback;
- }S_ListViewFunctionsCallback;
- /*TAG:ListViewFunctionsCallback*/
- static S_ListViewFunctionsCallback SListViewFunctionsCallbackTab[] = {
- };
- typedef void (*SlideWindowItemClickCallback)(ZKSlideWindow *pSlideWindow, int index);
- typedef struct {
- int id;
- SlideWindowItemClickCallback onSlideItemClickCallback;
- }S_SlideWindowItemClickCallback;
- /*TAG:SlideWindowFunctionsCallbackTab*/
- static S_SlideWindowItemClickCallback SSlideWindowItemClickCallbackTab[] = {
- };
- typedef void (*EditTextInputCallback)(const std::string &text);
- typedef struct {
- int id;
- EditTextInputCallback onEditTextChangedCallback;
- }S_EditTextInputCallback;
- /*TAG:EditTextInputCallback*/
- static S_EditTextInputCallback SEditTextInputCallbackTab[] = {
- };
- typedef void (*VideoViewCallback)(ZKVideoView *pVideoView, int msg);
- typedef struct {
- int id; //VideoView ID
- bool loop; // 是否是轮播类型
- int defaultvolume;//轮播类型时,默认视频音量
- VideoViewCallback onVideoViewCallback;
- }S_VideoViewCallback;
- /*TAG:VideoViewCallback*/
- static S_VideoViewCallback SVideoViewCallbackTab[] = {
- };
- deviceInfoActivity::deviceInfoActivity() {
- //todo add init code here
- mVideoLoopIndex = -1;
- mVideoLoopErrorCount = 0;
- }
- deviceInfoActivity::~deviceInfoActivity() {
- //todo add init file here
- // 退出应用时需要反注册
- EASYUICONTEXT->unregisterGlobalTouchListener(this);
- unregisterProtocolDataUpdateListener(onProtocolDataUpdate);
- onUI_quit();
- mActivityPtr = NULL;
- mScanQRCodeTextViewPtr = NULL;
- mQRCodePicPainterPtr = NULL;
- mQRCodePtr = NULL;
- mQRCodePainterPtr = NULL;
- mDeviceInfoTextViewPtr = NULL;
- mDeviceInfoPicPainterPtr = NULL;
- mDeviceInfoPainterPtr = NULL;
- mRestartPainterPtr = NULL;
- mRestartButtonPtr = NULL;
- mVersionPainterPtr = NULL;
- mVersionButtonPtr = NULL;
- mSettingPainterPtr = NULL;
- mNetworkButtonPtr = NULL;
- mServerPicPainterPtr = NULL;
- mServerButtonPtr = NULL;
- mNetworkPainterPtr = NULL;
- mDebugTextViewPtr = NULL;
- mDebugPicPainterPtr = NULL;
- mDebugPainterPtr = NULL;
- mSettingButtonPtr = NULL;
- mServerIPPtr = NULL;
- mServerIpTextViewPtr = NULL;
- mVersionPtr = NULL;
- mVersionTextViewPtr = NULL;
- mVoiceDomainPtr = NULL;
- mVoiceDomainTextViewPtr = NULL;
- mVoiceIdPtr = NULL;
- mVoiceIdTextViewPtr = NULL;
- mGatewayPtr = NULL;
- mGatewayTextViewPtr = NULL;
- mNetMaskPtr = NULL;
- mNetMaskTextViewPtr = NULL;
- mDeviceIpPtr = NULL;
- mDeviceIpTextViewPtr = NULL;
- mDeviceMacPtr = NULL;
- mMACTextViewPtr = NULL;
- mDeviceCodePtr = NULL;
- mDeviceSignTextViewPtr = NULL;
- mDeviceIdPtr = NULL;
- mDeviceIdTextViewPtr = NULL;
- }
- const char* deviceInfoActivity::getAppName() const{
- return "deviceInfo.ftu";
- }
- //TAG:onCreate
- void deviceInfoActivity::onCreate() {
- Activity::onCreate();
- mScanQRCodeTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_ScanQRCodeTextView);
- mQRCodePicPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_QRCodePicPainter);
- mQRCodePtr = (ZKQRCode*)findControlByID(ID_DEVICEINFO_QRCode);
- mQRCodePainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_QRCodePainter);
- mDeviceInfoTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceInfoTextView);
- mDeviceInfoPicPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_DeviceInfoPicPainter);
- mDeviceInfoPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_DeviceInfoPainter);
- mRestartPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_RestartPainter);
- mRestartButtonPtr = (ZKButton*)findControlByID(ID_DEVICEINFO_RestartButton);
- mVersionPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_VersionPainter);
- mVersionButtonPtr = (ZKButton*)findControlByID(ID_DEVICEINFO_VersionButton);
- mSettingPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_SettingPainter);
- mNetworkButtonPtr = (ZKButton*)findControlByID(ID_DEVICEINFO_NetworkButton);
- mServerPicPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_ServerPicPainter);
- mServerButtonPtr = (ZKButton*)findControlByID(ID_DEVICEINFO_ServerButton);
- mNetworkPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_NetworkPainter);
- mDebugTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DebugTextView);
- mDebugPicPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_DebugPicPainter);
- mDebugPainterPtr = (ZKPainter*)findControlByID(ID_DEVICEINFO_DebugPainter);
- mSettingButtonPtr = (ZKButton*)findControlByID(ID_DEVICEINFO_SettingButton);
- mServerIPPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_ServerIP);
- mServerIpTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_ServerIpTextView);
- mVersionPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_Version);
- mVersionTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_VersionTextView);
- mVoiceDomainPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_VoiceDomain);
- mVoiceDomainTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_VoiceDomainTextView);
- mVoiceIdPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_VoiceId);
- mVoiceIdTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_VoiceIdTextView);
- mGatewayPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_Gateway);
- mGatewayTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_GatewayTextView);
- mNetMaskPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_NetMask);
- mNetMaskTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_NetMaskTextView);
- mDeviceIpPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceIp);
- mDeviceIpTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceIpTextView);
- mDeviceMacPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceMac);
- mMACTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_MACTextView);
- mDeviceCodePtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceCode);
- mDeviceSignTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceSignTextView);
- mDeviceIdPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceId);
- mDeviceIdTextViewPtr = (ZKTextView*)findControlByID(ID_DEVICEINFO_DeviceIdTextView);
- mActivityPtr = this;
- onUI_init();
- registerProtocolDataUpdateListener(onProtocolDataUpdate);
- rigesterActivityTimer();
- }
- void deviceInfoActivity::onClick(ZKBase *pBase) {
- //TODO: add widget onClik code
- int buttonTablen = sizeof(sButtonCallbackTab) / sizeof(S_ButtonCallback);
- for (int i = 0; i < buttonTablen; ++i) {
- if (sButtonCallbackTab[i].id == pBase->getID()) {
- if (sButtonCallbackTab[i].callback((ZKButton*)pBase)) {
- return;
- }
- break;
- }
- }
- int len = sizeof(sAppInfoTab) / sizeof(sAppInfoTab[0]);
- for (int i = 0; i < len; ++i) {
- if (sAppInfoTab[i].id == pBase->getID()) {
- EASYUICONTEXT->openActivity(sAppInfoTab[i].pApp);
- return;
- }
- }
- Activity::onClick(pBase);
- }
- void deviceInfoActivity::onResume() {
- Activity::onResume();
- EASYUICONTEXT->registerGlobalTouchListener(this);
- startVideoLoopPlayback();
- onUI_show();
- }
- void deviceInfoActivity::onPause() {
- Activity::onPause();
- EASYUICONTEXT->unregisterGlobalTouchListener(this);
- stopVideoLoopPlayback();
- onUI_hide();
- }
- void deviceInfoActivity::onIntent(const Intent *intentPtr) {
- Activity::onIntent(intentPtr);
- onUI_intent(intentPtr);
- }
- bool deviceInfoActivity::onTimer(int id) {
- return onUI_Timer(id);
- }
- void deviceInfoActivity::onProgressChanged(ZKSeekBar *pSeekBar, int progress){
- int seekBarTablen = sizeof(SZKSeekBarCallbackTab) / sizeof(S_ZKSeekBarCallback);
- for (int i = 0; i < seekBarTablen; ++i) {
- if (SZKSeekBarCallbackTab[i].id == pSeekBar->getID()) {
- SZKSeekBarCallbackTab[i].callback(pSeekBar, progress);
- break;
- }
- }
- }
- int deviceInfoActivity::getListItemCount(const ZKListView *pListView) const{
- int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
- return SListViewFunctionsCallbackTab[i].getListItemCountCallback(pListView);
- break;
- }
- }
- return 0;
- }
- void deviceInfoActivity::obtainListItemData(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index){
- int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
- SListViewFunctionsCallbackTab[i].obtainListItemDataCallback(pListView, pListItem, index);
- break;
- }
- }
- }
- void deviceInfoActivity::onItemClick(ZKListView *pListView, int index, int id){
- int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
- SListViewFunctionsCallbackTab[i].onItemClickCallback(pListView, index, id);
- break;
- }
- }
- }
- void deviceInfoActivity::onSlideItemClick(ZKSlideWindow *pSlideWindow, int index) {
- int tablen = sizeof(SSlideWindowItemClickCallbackTab) / sizeof(S_SlideWindowItemClickCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SSlideWindowItemClickCallbackTab[i].id == pSlideWindow->getID()) {
- SSlideWindowItemClickCallbackTab[i].onSlideItemClickCallback(pSlideWindow, index);
- break;
- }
- }
- }
- bool deviceInfoActivity::onTouchEvent(const MotionEvent &ev) {
- return ondeviceInfoActivityTouchEvent(ev);
- }
- void deviceInfoActivity::onTextChanged(ZKTextView *pTextView, const std::string &text) {
- int tablen = sizeof(SEditTextInputCallbackTab) / sizeof(S_EditTextInputCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SEditTextInputCallbackTab[i].id == pTextView->getID()) {
- SEditTextInputCallbackTab[i].onEditTextChangedCallback(text);
- break;
- }
- }
- }
- void deviceInfoActivity::rigesterActivityTimer() {
- int tablen = sizeof(REGISTER_ACTIVITY_TIMER_TAB) / sizeof(S_ACTIVITY_TIMEER);
- for (int i = 0; i < tablen; ++i) {
- S_ACTIVITY_TIMEER temp = REGISTER_ACTIVITY_TIMER_TAB[i];
- registerTimer(temp.id, temp.time);
- }
- }
- void deviceInfoActivity::onVideoPlayerMessage(ZKVideoView *pVideoView, int msg) {
- int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SVideoViewCallbackTab[i].id == pVideoView->getID()) {
- if (SVideoViewCallbackTab[i].loop) {
- //循环播放
- videoLoopPlayback(pVideoView, msg, i);
- } else if (SVideoViewCallbackTab[i].onVideoViewCallback != NULL){
- SVideoViewCallbackTab[i].onVideoViewCallback(pVideoView, msg);
- }
- break;
- }
- }
- }
- void deviceInfoActivity::videoLoopPlayback(ZKVideoView *pVideoView, int msg, size_t callbackTabIndex) {
- switch (msg) {
- case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED:
- LOGD("ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED\n");
- if (callbackTabIndex >= (sizeof(SVideoViewCallbackTab)/sizeof(S_VideoViewCallback))) {
- break;
- }
- pVideoView->setVolume(SVideoViewCallbackTab[callbackTabIndex].defaultvolume / 10.0);
- mVideoLoopErrorCount = 0;
- break;
- case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_ERROR:
- /**错误处理 */
- ++mVideoLoopErrorCount;
- if (mVideoLoopErrorCount > 100) {
- LOGD("video loop error counts > 100, quit loop playback !");
- break;
- } //不用break, 继续尝试播放下一个
- case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED:
- LOGD("ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED\n");
- std::vector<std::string> videolist;
- std::string fileName(getAppName());
- if (fileName.size() < 4) {
- LOGD("getAppName size < 4, ignore!");
- break;
- }
- fileName = fileName.substr(0, fileName.length() - 4) + "_video_list.txt";
- fileName = "/mnt/extsd/" + fileName;
- if (!parseVideoFileList(fileName.c_str(), videolist)) {
- LOGD("parseVideoFileList failed !");
- break;
- }
- if (pVideoView && !videolist.empty()) {
- mVideoLoopIndex = (mVideoLoopIndex + 1) % videolist.size();
- pVideoView->play(videolist[mVideoLoopIndex].c_str());
- }
- break;
- }
- }
- void deviceInfoActivity::startVideoLoopPlayback() {
- int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SVideoViewCallbackTab[i].loop) {
- ZKVideoView* videoView = (ZKVideoView*)findControlByID(SVideoViewCallbackTab[i].id);
- if (!videoView) {
- return;
- }
- //循环播放
- videoLoopPlayback(videoView, ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED, i);
- return;
- }
- }
- }
- void deviceInfoActivity::stopVideoLoopPlayback() {
- int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
- for (int i = 0; i < tablen; ++i) {
- if (SVideoViewCallbackTab[i].loop) {
- ZKVideoView* videoView = (ZKVideoView*)findControlByID(SVideoViewCallbackTab[i].id);
- if (!videoView) {
- return;
- }
- if (videoView->isPlaying()) {
- videoView->stop();
- }
- return;
- }
- }
- }
- bool deviceInfoActivity::parseVideoFileList(const char *pFileListPath, std::vector<string>& mediaFileList) {
- mediaFileList.clear();
- if (NULL == pFileListPath || 0 == strlen(pFileListPath)) {
- LOGD("video file list is null!");
- return false;
- }
- ifstream is(pFileListPath, ios_base::in);
- if (!is.is_open()) {
- LOGD("cann't open file %s \n", pFileListPath);
- return false;
- }
- char tmp[1024] = {0};
- while (is.getline(tmp, sizeof(tmp))) {
- string str = tmp;
- removeCharFromString(str, '\"');
- removeCharFromString(str, '\r');
- removeCharFromString(str, '\n');
- if (str.size() > 1) {
- mediaFileList.push_back(str.c_str());
- }
- }
- LOGD("(f:%s, l:%d) parse fileList[%s], get [%d]files", __FUNCTION__,
- __LINE__, pFileListPath, int(mediaFileList.size()));
- for (std::vector<string>::size_type i = 0; i < mediaFileList.size(); i++) {
- LOGD("file[%u]:[%s]", ::size_t(i), mediaFileList[i].c_str());
- }
- is.close();
- return true;
- }
- int deviceInfoActivity::removeCharFromString(string& nString, char c) {
- string::size_type pos;
- while(1) {
- pos = nString.find(c);
- if(pos != string::npos) {
- nString.erase(pos, 1);
- } else {
- break;
- }
- }
- return (int)nString.size();
- }
- void deviceInfoActivity::registerUserTimer(int id, int time) {
- registerTimer(id, time);
- }
- void deviceInfoActivity::unregisterUserTimer(int id) {
- unregisterTimer(id);
- }
- void deviceInfoActivity::resetUserTimer(int id, int time) {
- resetTimer(id, time);
- }
|