functionActivity.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. /***********************************************
  2. /gen auto by zuitools
  3. ***********************************************/
  4. #include "functionActivity.h"
  5. /*TAG:GlobalVariable全局变量*/
  6. static ZKButton* mServerCancelButtonPtr;
  7. static ZKButton* mServerConfirmButtonPtr;
  8. static ZKTextView* mServerPromptTextViewPtr;
  9. static ZKTextView* mServerTextViewPtr;
  10. static ZKEditText* mServerPortEditTextPtr;
  11. static ZKEditText* mServerIpEditTextPtr;
  12. static ZKPainter* mServerPainterPtr;
  13. static ZKWindow* mServerWindowPtr;
  14. static ZKButton* mPwdBackButtonPtr;
  15. static ZKButton* mPwdConfirmButtonPtr;
  16. static ZKEditText* mPwdEditTextPtr;
  17. static ZKTextView* mPwdPromptTextViewPtr;
  18. static ZKTextView* mPwdTextViewPtr;
  19. static ZKPainter* mPwdPainterPtr;
  20. static ZKWindow* mPwdWindowPtr;
  21. static ZKButton* mCancelLogoutButtonPtr;
  22. static ZKButton* mConfirmLogoutButtonPtr;
  23. static ZKTextView* mLogoutTextViewPtr;
  24. static ZKPainter* mLogoutPicPainterPtr;
  25. static ZKWindow* mLogoutWindowPtr;
  26. static ZKButton* mFunctionButtonPtr;
  27. static ZKTextView* mStateTextViewPtr;
  28. static ZKTextView* mFunctionTextViewPtr;
  29. static ZKPainter* mIconPainterPtr;
  30. static ZKWindow* mFunctionWindowPtr;
  31. static ZKWindow* mWarnWindowPtr;
  32. static ZKButton* mbackButtonPtr;
  33. static ZKTextView* mWarnTextViewPtr;
  34. static ZKButton* mCancelCallButtonPtr;
  35. static ZKButton* mConfirmCallButtonPtr;
  36. static ZKListView* mCallBedListViewPtr;
  37. static ZKTextView* mCallBedTextViewPtr;
  38. static ZKPainter* mCallBedPicPainterPtr;
  39. static ZKWindow* mCallBedWindowPtr;
  40. static ZKPainter* mFunctionPainterPtr;
  41. static functionActivity* mActivityPtr;
  42. /*register activity*/
  43. REGISTER_ACTIVITY(functionActivity);
  44. typedef struct {
  45. int id; // 定时器ID , 不能重复
  46. int time; // 定时器 时间间隔 单位 毫秒
  47. }S_ACTIVITY_TIMEER;
  48. #include "logic/functionLogic.cc"
  49. /***********/
  50. typedef struct {
  51. int id;
  52. const char *pApp;
  53. } SAppInfo;
  54. /**
  55. *点击跳转window
  56. */
  57. static SAppInfo sAppInfoTab[] = {
  58. // { ID_MAIN_TEXT, "TextViewActivity" },
  59. };
  60. /***************/
  61. typedef bool (*ButtonCallback)(ZKButton *pButton);
  62. /**
  63. * button onclick表
  64. */
  65. typedef struct {
  66. int id;
  67. ButtonCallback callback;
  68. }S_ButtonCallback;
  69. /*TAG:ButtonCallbackTab按键映射表*/
  70. static S_ButtonCallback sButtonCallbackTab[] = {
  71. ID_FUNCTION_ServerCancelButton, onButtonClick_ServerCancelButton,
  72. ID_FUNCTION_ServerConfirmButton, onButtonClick_ServerConfirmButton,
  73. ID_FUNCTION_PwdBackButton, onButtonClick_PwdBackButton,
  74. ID_FUNCTION_PwdConfirmButton, onButtonClick_PwdConfirmButton,
  75. ID_FUNCTION_CancelLogoutButton, onButtonClick_CancelLogoutButton,
  76. ID_FUNCTION_ConfirmLogoutButton, onButtonClick_ConfirmLogoutButton,
  77. ID_FUNCTION_FunctionButton, onButtonClick_FunctionButton,
  78. ID_FUNCTION_backButton, onButtonClick_backButton,
  79. ID_FUNCTION_CancelCallButton, onButtonClick_CancelCallButton,
  80. ID_FUNCTION_ConfirmCallButton, onButtonClick_ConfirmCallButton,
  81. };
  82. /***************/
  83. typedef void (*SeekBarCallback)(ZKSeekBar *pSeekBar, int progress);
  84. typedef struct {
  85. int id;
  86. SeekBarCallback callback;
  87. }S_ZKSeekBarCallback;
  88. /*TAG:SeekBarCallbackTab*/
  89. static S_ZKSeekBarCallback SZKSeekBarCallbackTab[] = {
  90. };
  91. typedef int (*ListViewGetItemCountCallback)(const ZKListView *pListView);
  92. typedef void (*ListViewobtainListItemDataCallback)(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index);
  93. typedef void (*ListViewonItemClickCallback)(ZKListView *pListView, int index, int id);
  94. typedef struct {
  95. int id;
  96. ListViewGetItemCountCallback getListItemCountCallback;
  97. ListViewobtainListItemDataCallback obtainListItemDataCallback;
  98. ListViewonItemClickCallback onItemClickCallback;
  99. }S_ListViewFunctionsCallback;
  100. /*TAG:ListViewFunctionsCallback*/
  101. static S_ListViewFunctionsCallback SListViewFunctionsCallbackTab[] = {
  102. ID_FUNCTION_CallBedListView, getListItemCount_CallBedListView, obtainListItemData_CallBedListView, onListItemClick_CallBedListView,
  103. };
  104. typedef void (*SlideWindowItemClickCallback)(ZKSlideWindow *pSlideWindow, int index);
  105. typedef struct {
  106. int id;
  107. SlideWindowItemClickCallback onSlideItemClickCallback;
  108. }S_SlideWindowItemClickCallback;
  109. /*TAG:SlideWindowFunctionsCallbackTab*/
  110. static S_SlideWindowItemClickCallback SSlideWindowItemClickCallbackTab[] = {
  111. };
  112. typedef void (*EditTextInputCallback)(const std::string &text);
  113. typedef struct {
  114. int id;
  115. EditTextInputCallback onEditTextChangedCallback;
  116. }S_EditTextInputCallback;
  117. /*TAG:EditTextInputCallback*/
  118. static S_EditTextInputCallback SEditTextInputCallbackTab[] = {
  119. ID_FUNCTION_ServerPortEditText, onEditTextChanged_ServerPortEditText,
  120. ID_FUNCTION_ServerIpEditText, onEditTextChanged_ServerIpEditText,
  121. ID_FUNCTION_PwdEditText, onEditTextChanged_PwdEditText,
  122. };
  123. typedef void (*VideoViewCallback)(ZKVideoView *pVideoView, int msg);
  124. typedef struct {
  125. int id; //VideoView ID
  126. bool loop; // 是否是轮播类型
  127. int defaultvolume;//轮播类型时,默认视频音量
  128. VideoViewCallback onVideoViewCallback;
  129. }S_VideoViewCallback;
  130. /*TAG:VideoViewCallback*/
  131. static S_VideoViewCallback SVideoViewCallbackTab[] = {
  132. };
  133. functionActivity::functionActivity() {
  134. //todo add init code here
  135. mVideoLoopIndex = -1;
  136. mVideoLoopErrorCount = 0;
  137. }
  138. functionActivity::~functionActivity() {
  139. //todo add init file here
  140. // 退出应用时需要反注册
  141. EASYUICONTEXT->unregisterGlobalTouchListener(this);
  142. unregisterProtocolDataUpdateListener(onProtocolDataUpdate);
  143. onUI_quit();
  144. mActivityPtr = NULL;
  145. mServerCancelButtonPtr = NULL;
  146. mServerConfirmButtonPtr = NULL;
  147. mServerPromptTextViewPtr = NULL;
  148. mServerTextViewPtr = NULL;
  149. mServerPortEditTextPtr = NULL;
  150. mServerIpEditTextPtr = NULL;
  151. mServerPainterPtr = NULL;
  152. mServerWindowPtr = NULL;
  153. mPwdBackButtonPtr = NULL;
  154. mPwdConfirmButtonPtr = NULL;
  155. mPwdEditTextPtr = NULL;
  156. mPwdPromptTextViewPtr = NULL;
  157. mPwdTextViewPtr = NULL;
  158. mPwdPainterPtr = NULL;
  159. mPwdWindowPtr = NULL;
  160. mCancelLogoutButtonPtr = NULL;
  161. mConfirmLogoutButtonPtr = NULL;
  162. mLogoutTextViewPtr = NULL;
  163. mLogoutPicPainterPtr = NULL;
  164. mLogoutWindowPtr = NULL;
  165. mFunctionButtonPtr = NULL;
  166. mStateTextViewPtr = NULL;
  167. mFunctionTextViewPtr = NULL;
  168. mIconPainterPtr = NULL;
  169. mFunctionWindowPtr = NULL;
  170. mWarnWindowPtr = NULL;
  171. mbackButtonPtr = NULL;
  172. mWarnTextViewPtr = NULL;
  173. mCancelCallButtonPtr = NULL;
  174. mConfirmCallButtonPtr = NULL;
  175. mCallBedListViewPtr = NULL;
  176. mCallBedTextViewPtr = NULL;
  177. mCallBedPicPainterPtr = NULL;
  178. mCallBedWindowPtr = NULL;
  179. mFunctionPainterPtr = NULL;
  180. }
  181. const char* functionActivity::getAppName() const{
  182. return "function.ftu";
  183. }
  184. //TAG:onCreate
  185. void functionActivity::onCreate() {
  186. Activity::onCreate();
  187. mServerCancelButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_ServerCancelButton);
  188. mServerConfirmButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_ServerConfirmButton);
  189. mServerPromptTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_ServerPromptTextView);
  190. mServerTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_ServerTextView);
  191. mServerPortEditTextPtr = (ZKEditText*)findControlByID(ID_FUNCTION_ServerPortEditText);if(mServerPortEditTextPtr!= NULL){mServerPortEditTextPtr->setTextChangeListener(this);}
  192. mServerIpEditTextPtr = (ZKEditText*)findControlByID(ID_FUNCTION_ServerIpEditText);if(mServerIpEditTextPtr!= NULL){mServerIpEditTextPtr->setTextChangeListener(this);}
  193. mServerPainterPtr = (ZKPainter*)findControlByID(ID_FUNCTION_ServerPainter);
  194. mServerWindowPtr = (ZKWindow*)findControlByID(ID_FUNCTION_ServerWindow);
  195. mPwdBackButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_PwdBackButton);
  196. mPwdConfirmButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_PwdConfirmButton);
  197. mPwdEditTextPtr = (ZKEditText*)findControlByID(ID_FUNCTION_PwdEditText);if(mPwdEditTextPtr!= NULL){mPwdEditTextPtr->setTextChangeListener(this);}
  198. mPwdPromptTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_PwdPromptTextView);
  199. mPwdTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_PwdTextView);
  200. mPwdPainterPtr = (ZKPainter*)findControlByID(ID_FUNCTION_PwdPainter);
  201. mPwdWindowPtr = (ZKWindow*)findControlByID(ID_FUNCTION_PwdWindow);
  202. mCancelLogoutButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_CancelLogoutButton);
  203. mConfirmLogoutButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_ConfirmLogoutButton);
  204. mLogoutTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_LogoutTextView);
  205. mLogoutPicPainterPtr = (ZKPainter*)findControlByID(ID_FUNCTION_LogoutPicPainter);
  206. mLogoutWindowPtr = (ZKWindow*)findControlByID(ID_FUNCTION_LogoutWindow);
  207. mFunctionButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_FunctionButton);
  208. mStateTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_StateTextView);
  209. mFunctionTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_FunctionTextView);
  210. mIconPainterPtr = (ZKPainter*)findControlByID(ID_FUNCTION_IconPainter);
  211. mFunctionWindowPtr = (ZKWindow*)findControlByID(ID_FUNCTION_FunctionWindow);
  212. mWarnWindowPtr = (ZKWindow*)findControlByID(ID_FUNCTION_WarnWindow);
  213. mbackButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_backButton);
  214. mWarnTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_WarnTextView);
  215. mCancelCallButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_CancelCallButton);
  216. mConfirmCallButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_ConfirmCallButton);
  217. mCallBedListViewPtr = (ZKListView*)findControlByID(ID_FUNCTION_CallBedListView);if(mCallBedListViewPtr!= NULL){mCallBedListViewPtr->setListAdapter(this);mCallBedListViewPtr->setItemClickListener(this);}
  218. mCallBedTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_CallBedTextView);
  219. mCallBedPicPainterPtr = (ZKPainter*)findControlByID(ID_FUNCTION_CallBedPicPainter);
  220. mCallBedWindowPtr = (ZKWindow*)findControlByID(ID_FUNCTION_CallBedWindow);
  221. mFunctionPainterPtr = (ZKPainter*)findControlByID(ID_FUNCTION_FunctionPainter);
  222. mActivityPtr = this;
  223. onUI_init();
  224. registerProtocolDataUpdateListener(onProtocolDataUpdate);
  225. rigesterActivityTimer();
  226. }
  227. void functionActivity::onClick(ZKBase *pBase) {
  228. //TODO: add widget onClik code
  229. int buttonTablen = sizeof(sButtonCallbackTab) / sizeof(S_ButtonCallback);
  230. for (int i = 0; i < buttonTablen; ++i) {
  231. if (sButtonCallbackTab[i].id == pBase->getID()) {
  232. if (sButtonCallbackTab[i].callback((ZKButton*)pBase)) {
  233. return;
  234. }
  235. break;
  236. }
  237. }
  238. int len = sizeof(sAppInfoTab) / sizeof(sAppInfoTab[0]);
  239. for (int i = 0; i < len; ++i) {
  240. if (sAppInfoTab[i].id == pBase->getID()) {
  241. EASYUICONTEXT->openActivity(sAppInfoTab[i].pApp);
  242. return;
  243. }
  244. }
  245. Activity::onClick(pBase);
  246. }
  247. void functionActivity::onResume() {
  248. Activity::onResume();
  249. EASYUICONTEXT->registerGlobalTouchListener(this);
  250. startVideoLoopPlayback();
  251. onUI_show();
  252. }
  253. void functionActivity::onPause() {
  254. Activity::onPause();
  255. EASYUICONTEXT->unregisterGlobalTouchListener(this);
  256. stopVideoLoopPlayback();
  257. onUI_hide();
  258. }
  259. void functionActivity::onIntent(const Intent *intentPtr) {
  260. Activity::onIntent(intentPtr);
  261. onUI_intent(intentPtr);
  262. }
  263. bool functionActivity::onTimer(int id) {
  264. return onUI_Timer(id);
  265. }
  266. void functionActivity::onProgressChanged(ZKSeekBar *pSeekBar, int progress){
  267. int seekBarTablen = sizeof(SZKSeekBarCallbackTab) / sizeof(S_ZKSeekBarCallback);
  268. for (int i = 0; i < seekBarTablen; ++i) {
  269. if (SZKSeekBarCallbackTab[i].id == pSeekBar->getID()) {
  270. SZKSeekBarCallbackTab[i].callback(pSeekBar, progress);
  271. break;
  272. }
  273. }
  274. }
  275. int functionActivity::getListItemCount(const ZKListView *pListView) const{
  276. int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
  277. for (int i = 0; i < tablen; ++i) {
  278. if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
  279. return SListViewFunctionsCallbackTab[i].getListItemCountCallback(pListView);
  280. break;
  281. }
  282. }
  283. return 0;
  284. }
  285. void functionActivity::obtainListItemData(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index){
  286. int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
  287. for (int i = 0; i < tablen; ++i) {
  288. if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
  289. SListViewFunctionsCallbackTab[i].obtainListItemDataCallback(pListView, pListItem, index);
  290. break;
  291. }
  292. }
  293. }
  294. void functionActivity::onItemClick(ZKListView *pListView, int index, int id){
  295. int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
  296. for (int i = 0; i < tablen; ++i) {
  297. if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
  298. SListViewFunctionsCallbackTab[i].onItemClickCallback(pListView, index, id);
  299. break;
  300. }
  301. }
  302. }
  303. void functionActivity::onSlideItemClick(ZKSlideWindow *pSlideWindow, int index) {
  304. int tablen = sizeof(SSlideWindowItemClickCallbackTab) / sizeof(S_SlideWindowItemClickCallback);
  305. for (int i = 0; i < tablen; ++i) {
  306. if (SSlideWindowItemClickCallbackTab[i].id == pSlideWindow->getID()) {
  307. SSlideWindowItemClickCallbackTab[i].onSlideItemClickCallback(pSlideWindow, index);
  308. break;
  309. }
  310. }
  311. }
  312. bool functionActivity::onTouchEvent(const MotionEvent &ev) {
  313. return onfunctionActivityTouchEvent(ev);
  314. }
  315. void functionActivity::onTextChanged(ZKTextView *pTextView, const std::string &text) {
  316. int tablen = sizeof(SEditTextInputCallbackTab) / sizeof(S_EditTextInputCallback);
  317. for (int i = 0; i < tablen; ++i) {
  318. if (SEditTextInputCallbackTab[i].id == pTextView->getID()) {
  319. SEditTextInputCallbackTab[i].onEditTextChangedCallback(text);
  320. break;
  321. }
  322. }
  323. }
  324. void functionActivity::rigesterActivityTimer() {
  325. int tablen = sizeof(REGISTER_ACTIVITY_TIMER_TAB) / sizeof(S_ACTIVITY_TIMEER);
  326. for (int i = 0; i < tablen; ++i) {
  327. S_ACTIVITY_TIMEER temp = REGISTER_ACTIVITY_TIMER_TAB[i];
  328. registerTimer(temp.id, temp.time);
  329. }
  330. }
  331. void functionActivity::onVideoPlayerMessage(ZKVideoView *pVideoView, int msg) {
  332. int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
  333. for (int i = 0; i < tablen; ++i) {
  334. if (SVideoViewCallbackTab[i].id == pVideoView->getID()) {
  335. if (SVideoViewCallbackTab[i].loop) {
  336. //循环播放
  337. videoLoopPlayback(pVideoView, msg, i);
  338. } else if (SVideoViewCallbackTab[i].onVideoViewCallback != NULL){
  339. SVideoViewCallbackTab[i].onVideoViewCallback(pVideoView, msg);
  340. }
  341. break;
  342. }
  343. }
  344. }
  345. void functionActivity::videoLoopPlayback(ZKVideoView *pVideoView, int msg, size_t callbackTabIndex) {
  346. switch (msg) {
  347. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED:
  348. LOGD("ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED\n");
  349. if (callbackTabIndex >= (sizeof(SVideoViewCallbackTab)/sizeof(S_VideoViewCallback))) {
  350. break;
  351. }
  352. pVideoView->setVolume(SVideoViewCallbackTab[callbackTabIndex].defaultvolume / 10.0);
  353. mVideoLoopErrorCount = 0;
  354. break;
  355. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_ERROR:
  356. /**错误处理 */
  357. ++mVideoLoopErrorCount;
  358. if (mVideoLoopErrorCount > 100) {
  359. LOGD("video loop error counts > 100, quit loop playback !");
  360. break;
  361. } //不用break, 继续尝试播放下一个
  362. case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED:
  363. LOGD("ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED\n");
  364. std::vector<std::string> videolist;
  365. std::string fileName(getAppName());
  366. if (fileName.size() < 4) {
  367. LOGD("getAppName size < 4, ignore!");
  368. break;
  369. }
  370. fileName = fileName.substr(0, fileName.length() - 4) + "_video_list.txt";
  371. fileName = "/mnt/extsd/" + fileName;
  372. if (!parseVideoFileList(fileName.c_str(), videolist)) {
  373. LOGD("parseVideoFileList failed !");
  374. break;
  375. }
  376. if (pVideoView && !videolist.empty()) {
  377. mVideoLoopIndex = (mVideoLoopIndex + 1) % videolist.size();
  378. pVideoView->play(videolist[mVideoLoopIndex].c_str());
  379. }
  380. break;
  381. }
  382. }
  383. void functionActivity::startVideoLoopPlayback() {
  384. int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
  385. for (int i = 0; i < tablen; ++i) {
  386. if (SVideoViewCallbackTab[i].loop) {
  387. ZKVideoView* videoView = (ZKVideoView*)findControlByID(SVideoViewCallbackTab[i].id);
  388. if (!videoView) {
  389. return;
  390. }
  391. //循环播放
  392. videoLoopPlayback(videoView, ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED, i);
  393. return;
  394. }
  395. }
  396. }
  397. void functionActivity::stopVideoLoopPlayback() {
  398. int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
  399. for (int i = 0; i < tablen; ++i) {
  400. if (SVideoViewCallbackTab[i].loop) {
  401. ZKVideoView* videoView = (ZKVideoView*)findControlByID(SVideoViewCallbackTab[i].id);
  402. if (!videoView) {
  403. return;
  404. }
  405. if (videoView->isPlaying()) {
  406. videoView->stop();
  407. }
  408. return;
  409. }
  410. }
  411. }
  412. bool functionActivity::parseVideoFileList(const char *pFileListPath, std::vector<string>& mediaFileList) {
  413. mediaFileList.clear();
  414. if (NULL == pFileListPath || 0 == strlen(pFileListPath)) {
  415. LOGD("video file list is null!");
  416. return false;
  417. }
  418. ifstream is(pFileListPath, ios_base::in);
  419. if (!is.is_open()) {
  420. LOGD("cann't open file %s \n", pFileListPath);
  421. return false;
  422. }
  423. char tmp[1024] = {0};
  424. while (is.getline(tmp, sizeof(tmp))) {
  425. string str = tmp;
  426. removeCharFromString(str, '\"');
  427. removeCharFromString(str, '\r');
  428. removeCharFromString(str, '\n');
  429. if (str.size() > 1) {
  430. mediaFileList.push_back(str.c_str());
  431. }
  432. }
  433. LOGD("(f:%s, l:%d) parse fileList[%s], get [%d]files", __FUNCTION__,
  434. __LINE__, pFileListPath, int(mediaFileList.size()));
  435. for (std::vector<string>::size_type i = 0; i < mediaFileList.size(); i++) {
  436. LOGD("file[%u]:[%s]", ::size_t(i), mediaFileList[i].c_str());
  437. }
  438. is.close();
  439. return true;
  440. }
  441. int functionActivity::removeCharFromString(string& nString, char c) {
  442. string::size_type pos;
  443. while(1) {
  444. pos = nString.find(c);
  445. if(pos != string::npos) {
  446. nString.erase(pos, 1);
  447. } else {
  448. break;
  449. }
  450. }
  451. return (int)nString.size();
  452. }
  453. void functionActivity::registerUserTimer(int id, int time) {
  454. registerTimer(id, time);
  455. }
  456. void functionActivity::unregisterUserTimer(int id) {
  457. unregisterTimer(id);
  458. }
  459. void functionActivity::resetUserTimer(int id, int time) {
  460. resetTimer(id, time);
  461. }