Beispiel #1
0
 @Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   switch (v.getId()) {
     case R.id.ib_wifi_back:
       finish();
       overridePendingTransition(R.anim.fragment_nochange, R.anim.right_out);
       break;
     case R.id.btn_wifi_term_list:
       onlineTermList = xmlData.getOnlineList();
       if (onlineTermList == null) {
         Toast.makeText(mContext, "没有在线设备! ", Toast.LENGTH_SHORT).show();
       } else {
         showOnlineTermList();
         System.out.println("MyDebug: dealerName:" + onlineDealerName);
       }
       break;
     case R.id.btn_wifi_password_del:
       et_wifi_pwd.setText("");
       break;
     case R.id.btn_wifi_submit:
       if (onlineTermList == null) {
         Toast.makeText(mContext, "设备不在线,无法配置网络! ", Toast.LENGTH_SHORT).show();
       } else {
         String pwd = et_wifi_pwd.getText().toString().trim();
         if (pwd.length() == 0) {
           showSetTermWiFiTip();
         } else {
           setTermWiFiInfoEvent(pwd);
         }
       }
       break;
   }
 }
        @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;
          }
        }
Beispiel #3
0
  private void initData() {
    mContext = WiFiActivity.this;
    ZmqHandler.mHandler = handler;
    xmlData = new XmlDevice(mContext);
    onlineTermList = xmlData.getOnlineList();
    if (onlineTermList == null) {
      button_wifi_term_select.setText("没有在线设备");
    } else {
      button_wifi_term_select.setText((CharSequence) onlineTermList.get(0).get("deviceName"));
      onlineDealerName = "" + onlineTermList.get(0).get("dealerName");
    }

    WifiManager wifiManager = (WifiManager) this.getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo.getBSSID() != null) {
      String ssid = wifiInfo.getSSID();
      if (ssid != null) {
        ssid = ssid.replace("\"", "");
        et_wifi_name.setText(ssid);
      }
    }
  }