Exemplo n.º 1
0
 @SuppressWarnings("unchecked")
 @Override
 public void handleMessage(Message msg) {
   // TODO Auto-generated method stub
   super.handleMessage(msg);
   switch (msg.what) {
     case IS_REQUSTING:
       mDialog = Utils.createLoadingDialog(mContext, "正在请求设备周围WiFi列表...");
       mDialog.show();
       break;
     case REQUST_TIMEOUT:
       if (mDialog != null) mDialog.dismiss();
       if (handler.hasMessages(REQUST_TIMEOUT)) {
         handler.removeMessages(REQUST_TIMEOUT);
       }
       Toast.makeText(mContext, "请求WiFi列表失败,请重试! ", Toast.LENGTH_SHORT).show();
       break;
     case R.id.requst_wifi_list_id:
       if (handler.hasMessages(REQUST_TIMEOUT)) {
         handler.removeMessages(REQUST_TIMEOUT);
         if (mDialog != null) mDialog.dismiss();
         int resultCode = msg.arg1;
         if (resultCode == 0) {
           showWiFiListDialog((ArrayList<HashMap<String, Object>>) msg.obj);
         } else {
           Toast.makeText(mContext, "设备附近暂时没有WiFi信号! ", Toast.LENGTH_SHORT).show();
         }
       } else {
         handler.removeMessages(R.id.requst_wifi_list_id);
       }
       break;
     case IS_SETTING:
       mDialog = Utils.createLoadingDialog(mContext, "正在配置设备WiFi网络...");
       mDialog.show();
       break;
     case SET_TIMEOUT:
       if (mDialog != null) mDialog.dismiss();
       if (handler.hasMessages(SET_TIMEOUT)) {
         handler.removeMessages(SET_TIMEOUT);
       }
       Toast.makeText(mContext, "配置设备WiFi网络超时,请重试! ", Toast.LENGTH_SHORT).show();
       break;
     case R.id.set_term_wifi_id:
       if (handler.hasMessages(SET_TIMEOUT)) {
         handler.removeMessages(SET_TIMEOUT);
         if (mDialog != null) mDialog.dismiss();
         int resultCode = msg.arg1;
         if (resultCode == 1) {
           Toast.makeText(mContext, "配置设备WiFi网络成功! ", Toast.LENGTH_SHORT).show();
         } else {
           Toast.makeText(mContext, "配置设备WiFi网络失败,请重试! ", Toast.LENGTH_SHORT).show();
         }
       } else {
         handler.removeMessages(R.id.set_term_wifi_id);
       }
       break;
   }
 }
Exemplo n.º 2
0
        @Override
        public void handleMessage(Message msg) {
          // TODO Auto-generated method stub
          super.handleMessage(msg);
          switch (msg.what) {
            case IS_REQUESTING:
              mDialog = Utils.createLoadingDialog(mContext, "正在提交修改...");
              mDialog.show();
              break;
            case REQUEST_TIMEOUT:
              if (mDialog != null) mDialog.dismiss();
              if (handler.hasMessages(REQUEST_TIMEOUT)) {
                handler.removeMessages(REQUEST_TIMEOUT);
              }
              Value.isNeedReqTermListFlag = false;
              Toast.makeText(mContext, "修改终端名称失败,网络超时!", Toast.LENGTH_SHORT).show();
              break;
            case R.id.modify_device_name_id:
              if (handler.hasMessages(REQUEST_TIMEOUT)) {
                handler.removeMessages(REQUEST_TIMEOUT);
                if (mDialog != null) mDialog.dismiss();
                int resultCode = msg.arg1;
                if (resultCode == 0) {
                  Toast.makeText(mContext, "修改终端名称成功!", Toast.LENGTH_SHORT).show();
                  xmlData.updateItemName(mDeviceId, mDeviceName);

                  Bundle bundle = new Bundle();
                  bundle.putString("deviceId", mDeviceId);
                  bundle.putString("deviceName", mDeviceName);
                  Intent intent = new Intent();
                  intent.putExtras(bundle);
                  setResult(1, intent);
                  finish();
                  overridePendingTransition(0, R.anim.down_out);
                } else {
                  Toast.makeText(
                          mContext,
                          "修改终端名称失败," + Utils.getErrorReason(resultCode) + "!",
                          Toast.LENGTH_SHORT)
                      .show();
                }
              } else {
                handler.removeMessages(R.id.modify_device_name_id);
              }
              break;
          }
        }
Exemplo n.º 3
0
 public void clickAddDeviceEvent() {
   if (Utils.isNetworkAvailable(mContext)) {
     if (checkModifyDeviceData()) {
       Handler sendHandler = HandlerApplication.getInstance().getMyHandler();
       String data = generateModifyTermNameJson();
       sendHandlerMsg(IS_REQUESTING);
       sendHandlerMsg(REQUEST_TIMEOUT, Value.requestTimeout);
       sendHandlerMsg(sendHandler, R.id.zmq_send_data_id, data);
     }
   } else {
     Toast.makeText(mContext, "没有可用的网络连接,请确认后重试!", Toast.LENGTH_SHORT).show();
   }
 }
Exemplo n.º 4
0
  private void initImageViewDataSource() {
    imagesPath = new ArrayList<String>();
    count = 0;
    File file = new File(imageFile);
    File[] files = file.listFiles();
    int filesCount = files.length;

    for (int i = 0; i < filesCount; i++) {
      if (Utils.isImageFile(files[i].getName())) {
        count++;
        imagesPath.add(files[i].getPath());
        if (imagePath.equals(files[i].getPath())) {
          index = i;
        }
      }
    }
    sendHandlerMsg(INIT_FINISH);
  }