Exemplo n.º 1
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.tv_confirm:
       if (Global.getInstance(mContext).isOuterNet()) {
         XMPPClient xmppClient = Global.getInstance(mContext).getXMPPClient();
         if (xmppClient != null && xmppClient.isConnected()) {
           xmppClient.deleteUser(
               Settings.getMacAddress(mContext), Settings.getRouteMacAddress(mContext), userName);
           dismiss();
           confirmInterface.opration(true);
         }
       } else {
         shareCircleClient = Global.getInstance(mContext).getShareCircleClient();
         if (shareCircleClient.isConnected()) {
           UserMessage message = new UserMessage();
           PdmClientMessage clientMsg = new PdmClientMessage(userName, null);
           message.messageType = PdmClientMessageType.DEL_USER.intValue();
           message.messageData = clientMsg;
           shareCircleClient.sendMessage(message);
           dismiss();
           confirmInterface.opration(true);
         } else {
           Toast.makeText(mContext, R.string.network_disconnect, Toast.LENGTH_SHORT).show();
         }
       }
       break;
     case R.id.tv_cancel:
       dismiss();
       break;
   }
 }
Exemplo n.º 2
0
 private void updateQosRule(int uploadSpeed, int downloadSpeed, String ip) {
   QosObj qosObj = new QosObj(uploadSpeed, downloadSpeed, ip, qosRule.getIndex());
   String ssid = WifiManagerUtil.getWifiName(mContext);
   boolean is5 = (ssid != null && ssid.equals(Settings.getNetName5(mContext)));
   if (Global.getInstance(mContext).isOuterNet()) {
     XMPPClient xmppClient = Global.getInstance(mContext).getXMPPClient();
     if (xmppClient != null && xmppClient.isConnected()) {
       if (is5)
         xmppClient.updateQosRule5(
             Settings.getMacAddress(mContext),
             Settings.getRouteMacAddress(mContext),
             uploadSpeed + "-" + downloadSpeed + "-" + qosObj.getClass() + "-" + ip);
       else
         xmppClient.updateQosRule2(
             Settings.getMacAddress(mContext),
             Settings.getRouteMacAddress(mContext),
             uploadSpeed + "-" + downloadSpeed + "-" + qosObj.getClass() + "-" + ip);
     }
   } else {
     shareCircleClient = Global.getInstance(mContext).getShareCircleClient();
     if (shareCircleClient.isConnected()) {
       UserMessage message = new UserMessage();
       PdmClientMessage clientMsg = new PdmClientMessage(qosObj, null);
       if (is5) {
         message.messageType = PdmClientMessageType.SET_DEVICE_QOSRULE_5.intValue();
       } else {
         message.messageType = PdmClientMessageType.SET_DEVICE_QOSRULE_2.intValue();
       }
       message.messageData = clientMsg;
       shareCircleClient.sendMessage(message);
     } else {
       Toast.makeText(mContext, R.string.network_disconnect, Toast.LENGTH_SHORT).show();
     }
   }
 }