コード例 #1
0
 @Override
 protected void onHandleWorkMessage(Message msgWork) {
   // TODO Auto-generated method stub
   // 用于代替此类中的工作线程而设置的消息处理器
   switch (msgWork.what) {
     case MESSAGE_REQUEST_ASYN_TESTDATA:
       sendOnWaitBegin(null);
       try {
         List<ExampleBean> list = mModel.getAsynTestData();
         if (list.size() == 0) {
           sendOnDefault();
           sendOnWaitEnd(null);
         } else {
           Message msg = Message.obtain();
           msg.what = IExampleView.MESSAGE_ASYN_TESTDATA;
           List<String> result = getStringListByExampleBeanList(list);
           msg.obj = result;
           getViewHandler().sendMessage(msg);
           sendOnWaitEnd(null);
         }
       } catch (Exception e) {
         // TODO: handle exception
         // 如果有错误,则通知界面回调onError
         sendOnError();
         sendOnWaitEnd(null);
       }
       break;
     default:
       break;
   }
 }
コード例 #2
0
 /** 请求同步数据范例 */
 private void requestSynData() {
   // TODO Auto-generated method stub
   try {
     List<ExampleBean> list = mModel.getSynTestData();
     if (list.size() == 0) {
       mView.onDefault(null);
     } else {
       List<String> result = getStringListByExampleBeanList(list);
       mView.onSetSynTestData(result);
     }
   } catch (Exception e) {
     // TODO: handle exception
     mView.onError(null);
   }
 }