public void logout() {
   DialogUtils.showLoading(mContext, EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_OUT);
   AndroidEventManager.getInstance()
       .addEventListener(EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_OUT, this, true);
   AndroidEventManager.getInstance()
       .postEvent(
           EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_OUT,
           0,
           URLUtils.URL_SHOPMANAGERACCOUNT_LOGIN_OUT);
 }
 /**
  * @param username
  * @param pwd
  */
 public void login(String username, String pwd) {
   loginForCashierAppUp = new LoginForCashierAppUp(username, pwd);
   DialogUtils.showLoading(mContext, EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_IN);
   AndroidEventManager.getInstance()
       .addEventListener(EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_IN, this, true);
   AndroidEventManager.getInstance()
       .postEvent(
           EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_IN,
           0,
           URLUtils.URL_SHOPMANAGERACCOUNT_LOGIN_IN,
           loginForCashierAppUp);
 }
  @Override
  public void onEventRunEnd(MobileCashBaseEvent event) {
    // TODO Auto-generated method stub
    if (isFinishing()) {
      return;
    }
    eventCode = event.getEventCode();

    if (event instanceof HttpEvent) {
      if ((!((HttpEvent) event).isNetSuccess())
          || (((HttpEvent) event).isServerIsServerNotArrabile())
          || (((HttpEvent) event).isUnAuthorized())
          || (((HttpEvent) event).isServerIsNotArrabileNOTKonwnREson())) {
        DialogUtils.dissMissLoading(eventCode);
        toastManager.show(R.string.http502badgetawayShowing);
        return;
      }
    }
    if (EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_IN == event.getEventCode()) {
      DialogUtils.dissMissLoading(EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_IN);
      final MoblieCashLoginUpEvent loginUpEvent = (MoblieCashLoginUpEvent) event;
      if (loginUpEvent.isNetSuccess()) {
        if (loginUpEvent.isOk()) {
          if (loginUpEvent.getResult() > 0) {
            BaseApplication.getLocalManager().setRoleType(loginUpEvent.getResult());
            BaseApplication.getLocalManager()
                .saveLoginForCashierAppUp(
                    loginForCashierAppUp.getUsername(), loginForCashierAppUp.getPassword());
            BaseApplication.setisLogined(true);
            if (this.getClass().getName().equals(LoginActivity.class.getName())
                || this.getClass().getName().equals(RegisterActivity.class.getName())) {
              MainActivity.launch(this);
            }
          }
        } else {
          if (loginUpEvent.getErrorObject() == null) {
            toastManager.show(loginUpEvent.getStrHttpResult());
          } else {
            toastManager.show(ErrorObject.formatError(loginUpEvent.getErrorObject()));
          }
        }
      }
      return;
    } else if (EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_OUT == event.getEventCode()) {
      DialogUtils.dissMissLoading(EventCode.HTTP_POST_SHOPMANAGERACCOUNT_LOGIN_OUT);
      final MoblieCashLogOutEvent moblieCashLogOutEvent = (MoblieCashLogOutEvent) event;
      if (moblieCashLogOutEvent.isNetSuccess()) {
        if (moblieCashLogOutEvent.isOk()) {
          if (moblieCashLogOutEvent.getResult() != null
              && moblieCashLogOutEvent.getResult().equals("ok")) {
            BaseApplication.logout();
            if (!this.getClass().getName().equals(LoginActivity.class.getName())) {
              LoginActivity.launch(this);
            }
          }
        } else {
          BaseApplication.logout();
          if (!this.getClass().getName().equals(LoginActivity.class.getName())) {
            LoginActivity.launch(this);
          }
        }
      }
      return;
    } else if (eventCode == EventCode.CALLBACK_APPLICATION_NOTIFICATION_TO_ACTIVITY) {
      DialogUtils.dissMissLoading();
      MobileCashBaseCallbackEvent applicationCallbackEvent = (MobileCashBaseCallbackEvent) event;
      Object object = applicationCallbackEvent.getReturnParam();
      if (object instanceof HttpEvent) {
        HttpEvent event2 = (HttpEvent) object;
        if (!((HttpEvent) event2).isNetSuccess()) {
          toastManager.show("服务器" + URLUtils.HOST + "\n" + getString(R.string.no_net));
          return;
        } else if (((HttpEvent) event2).isServerIsServerNotArrabile()) {
          toastManager.show(R.string.http502badgetawayShowing);
          return;
        } else if (((HttpEvent) event2).isUnAuthorized()) {
          toastManager.show(R.string.http401unAuthorizedShowing);
          return;
        } else if (((HttpEvent) event2).isServerIsNotArrabileNOTKonwnREson()) {
          toastManager.show(R.string.httpsNotArrabileNOTKonwnREsonShowing);
          return;
        } else if (((HttpEvent) event2).isMethodNotAllowed()) {
          if (((HttpEvent) event2).getErrorObject() != null) {
            if (((HttpEvent) event2).getErrorObject().getCode() == 4) // 未登录退出重登
            {
              showMessageAndJumpToLogin("你的账号还未登陆,请重登!");
            }
          } else if (((HttpEvent) event).getErrorObject().getCode() == 45) // 被踢掉退出重登
          {
            showMessageAndJumpToLogin("你的账号在其他设备登陆,你已经被迫下线!");
            return;
          }
        } else {
          toastManager.show(applicationCallbackEvent.getReturnParam().toString());
        }
      } else {
        toastManager.show(applicationCallbackEvent.getReturnParam().toString());
      }
      return;
    } else if (eventCode == EventCode.CALLBACK_SAME_ACCOUNT_ANOTHER_PLACE_LOGIN) {
      showMessageAndJumpToLogin("你的账号在其他设备登陆,你已经被迫下线!");
      return;
    } else if (eventCode == EventCode.CALLBACK_IN_FRAGMENT_TASK_ACTIVITY_THAT_NET_ERROR) {
      showMessageAndJumpToLogin("网络异常,你已经被迫下线!");
      return;
    }
  }