Ejemplo n.º 1
0
  public void postCreateOrder(
      final String customerId, String parkingId, String orderPlanBegin, String order_img_count) {
    ApiTask apiTask = ApiTask.build(this.getActivity(), TAG);
    apiTask.setMethod("GET");
    apiTask.setUrl(
        ApiContants.instance(getActivity()).getActionUrl(ApiContants.API_CUSTOMER_CREATEORDER));
    apiTask.setParams(
        ApiContants.instance(getActivity())
            .userCreateOrder(customerId, parkingId, orderPlanBegin, order_img_count));
    apiTask.setRoot("orderInfo");
    apiTask.execute(
        new OnDataLoader<OrderInfo>() {
          LoadingDialog loadingDialog;

          @Override
          public void onStart() {
            if (isEnable()) {
              loadingDialog = LoadingDialog.show(getActivity());
            }
          }

          @Override
          public void onSuccess(OrderInfo orderInfos) {
            if (isEnable()) {
              mStopLinearLayout.setVisibility(View.GONE);
              mCancelButton.setVisibility(View.VISIBLE);
              mOrderTextLinearLayout.setVisibility(View.VISIBLE);
              order_id = orderInfos.getOrder_id();
              mOrderTextView.setText("正在为你搭配代泊员...");
              mOrderCountDownTextView.starTimeByMillisInFuture(3 * 60 * 1000);
              loadingDialog.dismiss();
              PollingUnfinishedOrder(customerId);

              mCB_WashCar.setClickable(false);
              mAppointmentTimeRelativeLayout.setClickable(false);

              mOrderCountDownTextView.setOnCountDownListener(
                  new CountDownTextView.OnCountDownListener() {
                    @Override
                    public void onFinish() {
                      pollingHttpClient.cancelRequests(getActivity(), true);
                      postCancelOrder(order_id);
                      mOrderTextView.setText("代泊员正忙,未接单,订单取消");
                      mOrderCountDownTextView.setText("");
                    }
                  });
            }
          }

          @Override
          public void onFailure(String code, String message) {
            if (isEnable()) {
              Log.e(TAG, "请求数据失败");
              loadingDialog.dismiss();
            }
          }
        });
  }
Ejemplo n.º 2
0
  public void PollingUnfinishedOrder(final String customerId) {

    pollingHttpClient = new PollingHttpClient();
    PollingUnfinishedOrderHandler pollingUnfinishedOrderHandler =
        new PollingUnfinishedOrderHandler();
    pollingHttpClient.send(
        getActivity(),
        ApiContants.instance(getActivity()).getActionUrl(ApiContants.API_CUSTOMER_UNFINISHEDORDER),
        ApiContants.instance(getActivity()).unFinishedOrder(customerId),
        pollingUnfinishedOrderHandler,
        18,
        10000);
  }
Ejemplo n.º 3
0
  public void postUnfinishedOrder(String customerId) {

    ApiTask apiTask = ApiTask.build(this.getActivity(), TAG);
    apiTask.setMethod("GET");
    apiTask.setUrl(
        ApiContants.instance(getActivity()).getActionUrl(ApiContants.API_CUSTOMER_UNFINISHEDORDER));
    apiTask.setParams(ApiContants.instance(getActivity()).unFinishedOrder(customerId));
    apiTask.setRoot("orderInfo");
    apiTask.execute(
        new OnDataLoader<List<UnfinishedOrderInfo>>() {
          LoadingDialog loadingDialog;

          @Override
          public void onStart() {
            if (isEnable()) {
              loadingDialog = LoadingDialog.show(getActivity());
            }
          }

          @Override
          public void onSuccess(List<UnfinishedOrderInfo> unfinishedOrderInfos) {
            if (isEnable()) {
              Log.e(TAG, unfinishedOrderInfos.size() + "");
              listSize = unfinishedOrderInfos.size();
              getSession().put("unfinishedOrderInfos", unfinishedOrderInfos);

              if (listSize > 0) {
                setButtonEnable(false);
              } else {
                setButtonEnable(true);
              }
              loadingDialog.dismiss();
            }
          }

          @Override
          public void onFailure(String code, String message) {
            if (isEnable()) {
              loadingDialog.dismiss();
            }
          }
        });
  }
Ejemplo n.º 4
0
  public void postCancelOrder(String orderSn) {
    ApiTask apiTask = ApiTask.build(this.getActivity(), TAG);
    apiTask.setMethod("GET");
    apiTask.setUrl(
        ApiContants.instance(getActivity()).getActionUrl(ApiContants.API_CUSTOMER_CANCELORDER));
    apiTask.setParams(ApiContants.instance(getActivity()).userCancelOrder(orderSn));
    apiTask.execute(
        new OnDataLoader<UserAuth>() {

          LoadingDialog loadingDialog;

          @Override
          public void onStart() {
            if (isEnable()) {
              loadingDialog = LoadingDialog.show(getActivity());
            }
          }

          @Override
          public void onSuccess(UserAuth auth) {
            if (isEnable()) {
              listSize = 0;
              mStopLinearLayout.setVisibility(View.VISIBLE);
              mCancelButton.setVisibility(View.GONE);
              mOrderTextLinearLayout.setVisibility(View.GONE);

              setButtonEnable(true);
              mCB_WashCar.setClickable(true);
              mAppointmentTimeRelativeLayout.setClickable(true);
              loadingDialog.dismiss();
            }
          }

          @Override
          public void onFailure(String code, String message) {
            if (isEnable()) {
              mobi.cangol.mobile.logging.Log.d(TAG, "code=:" + code + ",message=" + message);
              loadingDialog.dismiss();
            }
          }
        });
  }