Ejemplo n.º 1
0
  /**
   * 从服务器获取相应订单号
   *
   * @param username 用户名
   * @param type 要获取的订单号类型
   * @param onGetOrderIdListener 获取结果回调
   *     <p>* 1.交换秘钥 -----成功例子-----{"code"=200,"data"="key"} 2.注册账号
   *     -----成功例子-----{"code"=200,"data"="注册成功"} 3.登陆账号 -----成功例子-----{"code"=200,"data"="验证通过"}
   *     4.找回密码 -----成功例子-----{"code"=200,"data"="新密码设置成功"} 5.查询余额
   *     -----成功例子-----{"code"=200,"data"="100.25"} 6.插入购票人信息
   *     -----成功例子-----{"code"=200,"data"="数据插入成功"} 7.查询购票人信息 未支付、带出票、待出行、 8.插入订单信息 9.更新车票订单信息表
   *     10.获取全部订单 11.获取未支付订单 12.获取待出票订单 13.获取出票成功的订单
   */
  public static synchronized void getOrderIdFromService(
      String username, int type, final OnGetOrderIdListener onGetOrderIdListener) {
    XXHttpClient httpClient =
        new XXHttpClient(
            Util.url_my,
            true,
            new XXHttpClient.XXHttpResponseListener() {
              @Override
              public void onSuccess(int i, byte[] bytes) {
                RespData_order order = new Gson().fromJson(new String(bytes), RespData_order.class);
                if (order.getCode() == 200) {
                  onGetOrderIdListener.onSucc(order.getOrders());
                } else {
                  onGetOrderIdListener.onError(order.getResult());
                }
              }

              @Override
              public void onError(int i, Throwable throwable) {
                onGetOrderIdListener.onError("网络异常");
              }

              @Override
              public void onProgress(long l, long l1) {}
            });
    httpClient.put("username", username);
    httpClient.put("type", type);
    httpClient.doPost(15000);
  }
Ejemplo n.º 2
0
  public static void getImagesFromInternet(String url, final OnGetImagesListener listener) {
    XXHttpClient client =
        new XXHttpClient(
            url,
            true,
            new XXHttpClient.XXHttpResponseListener() {
              @Override
              public void onSuccess(int i, byte[] bytes) {
                Bitmap bitmap = XXUtils.bytesToBimap(bytes);
                listener.onSucc(bitmap);
              }

              @Override
              public void onError(int i, Throwable throwable) {
                listener.onError("网络错误");
              }

              @Override
              public void onProgress(long l, long l1) {}
            });
    client.doGet(15000);
  }
  public GetSelectTickets(
      String startAdd,
      String stopAdd,
      String time,
      final GetSelectTicketsListener getSelectTicketsListener) {
    XXHttpClient client =
        new XXHttpClient(
            Util.url_ticket2,
            true,
            new XXHttpClient.XXHttpResponseListener() {
              @Override
              public void onSuccess(int i, byte[] bytes) {
                Log.d(TAG, new String(bytes));

                GetSelectTicketsData getSelectTicketsData =
                    new Gson().fromJson(new String(bytes), GetSelectTicketsData.class);
                if (getSelectTicketsData.getError_code() == 0) {
                  for (int j = 0; j < getSelectTicketsData.getResult().getList().length; j++) {
                    //
                    // Log.d(TAG,getSelectTicketsData.getResult().getList()[j].getEnd_station_name());
                    data.add(getSelectTicketsData.getResult().getList()[j]);
                    //                    for (GetSelectTicketsArrDdata
                    // b:((getSelectTicketsData.getResult().getList())[j])){
                    //
                    //                    }
                  }
                }
                if (getSelectTicketsData.getError_code() == 0) {
                  getSelectTicketsListener.onSucc(data);
                } else {
                  getSelectTicketsListener.onError(getSelectTicketsData.getReason());
                }
              }

              @Override
              public void onError(int i, Throwable throwable) {
                Log.e(TAG, "网络异常");
                getSelectTicketsListener.onError("网络错误");
              }

              @Override
              public void onProgress(long l, long l1) {}
            });
    client.put("key", Util.appid_ticket);
    client.put("train_date", time);
    client.put("from_station", startAdd);
    client.put("to_station", stopAdd);
    client.doPost(15000);
  }