Beispiel #1
0
  public void exec(HttpsCb cb) {

    try {
      if (!NetUtil.isConnected()) {
        ViewInject.toast("找不到网络了...");
        return;
      }
    } catch (Exception e) {
      return;
    }
    if (mSslContext == null) {
      try {
        mSslContext = initCertificate();
      } catch (Exception e) {
        e.printStackTrace();
        ViewInject.toast("init ssl failed");
        return;
      }
    }
    try {
      HttpsURLConnection conn = openConnection();
      int code = conn.getResponseCode();
      MLoger.debug("httpcode-->" + code);

      if (code == 200 || code == 201) { // 网络请求成功
        String data = parseResponse(conn.getInputStream());
        MLoger.debug("response data-->" + data);
        if (cb != null) cb.onResponse(data);
      } else {
        MLoger.debug("error httpcode-->" + code);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #2
0
  @Override
  public void onConnectState(ECConnectState state, ECError error) {
    if (state == ECDevice.ECConnectState.CONNECT_FAILED
        && error.errorCode == SdkErrorCode.SDK_KICKED_OFF) {

    } else if (ECConnectState.CONNECT_SUCCESS.equals(state)) {
      ViewInject.toast("connect success");
      Object obj = ActivityStack.create().topActivity();
      if (obj instanceof MActivity) {
        MActivity act = (MActivity) obj;
        act.skipActivity(act, MyFriendsUI.class);
      }
    }
  }
Beispiel #3
0
  @Override
  public void onInitialized() {
    ECInitParams params = SDKHelper.getInstance().getParams();

    if (!params.validate()) {
      ViewInject.toast("error");
      // Intent intent = new Intent(ACTION_SDK_CONNECT);
      // intent.putExtra("error", -1);
      // mContext.sendBroadcast(intent);
      return;
    }

    if (params.validate()) {
      ECDevice.login(params);
    }
  }
Beispiel #4
0
 @Override
 public void onDisconnect(ECError error) {
   if (100 == error.errorCode) ViewInject.toast("connecting communication server");
   //		ViewInject.toast(error.toString());
 }