Example #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;
   }
 }
 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();
     }
   }
 }
Example #3
0
  @Override
  public boolean onTouchEvent(MotionEvent motionevent) {
    boolean flag = true;
    float f = motionevent.getX() - downX;
    int left = sourceLeft + (int) f;
    switch (motionevent.getAction()) {
      case MotionEvent.ACTION_DOWN:
        break;
      case MotionEvent.ACTION_MOVE:
        if (Math.abs(motionevent.getX() - downX) <= 20) {
          isMove = false;
        } else {
          isMove = true;
        }
        if (motionevent.getX() > downX) {
          isMoveLeft = false;
        } else {
          isMoveLeft = true;
          isFistLeft = true;
        }
        if (left <= 0) {
          View preView = Global.getInstance(mContext).getPreView();
          if (preView != null && !preView.equals(source)) {
            viewToInitPlace(preView, animationTime, preView.getLeft(), false);
            Global.getInstance(mContext).setPreView(null);
          }
          source.layout(left, sourceTop, left + source.getWidth(), sourceTop + source.getHeight());
        }
        flag = true;
        break;
      default:
      case MotionEvent.ACTION_UP:
        if (isFistLeft) {
          if (isMoveLeft) {
            viewToSpecifiedPlace(animationTime, left);
            Global.getInstance(mContext).setPreView(source);
          } else {
            viewToInitPlace(source, animationTime, left, true);
          }
        }
        if (!isMove) {
          flag = false;
        }

        break;
    }
    return flag;
  }