예제 #1
0
  public int getErrorCode(String response) {
    if (TextUtils.isEmpty(response)) return 0;
    try {
      AppLog.Log("TAG", response);
      JSONObject jsonObject = new JSONObject(response);
      return jsonObject.getInt(KEY_ERROR_CODE);

    } catch (JSONException e) {
      e.printStackTrace();
    }
    return 0;
  }
예제 #2
0
    @Override
    public void run() {
      // isContinueRequest = false;
      AppLog.Log(TAG, "In elapsed time timer");
      mapActivity.runOnUiThread(
          new Runnable() {

            @Override
            public void run() {
              if (isVisible()) {
                if (preferenceHelper.getRequestTime() == AndyConstants.NO_TIME) {
                  preferenceHelper.putRequestTime(System.currentTimeMillis());
                }
                time =
                    String.valueOf(
                        (Calendar.getInstance().getTimeInMillis()
                                - preferenceHelper.getRequestTime())
                            / (1000 * 60));
                tvJobTime.setText(
                    time + " " + mapActivity.getResources().getString(R.string.text_mins));
              }
            }
          });
    }
예제 #3
0
  public RequestDetail parseRequestStatus(String response) {
    if (TextUtils.isEmpty(response)) {
      return null;
    }
    RequestDetail requestDetail = null;
    try {
      JSONObject jsonObject = new JSONObject(response);
      if (jsonObject.getBoolean(KEY_SUCCESS)) {
        requestDetail = new RequestDetail();
        requestDetail.setJobStatus(AndyConstants.IS_ASSIGNED);
        JSONObject object = jsonObject.getJSONObject(AndyConstants.Params.REQUEST);

        if (object.getInt(IS_WALKER_STARTED) == 0) {
          requestDetail.setJobStatus(AndyConstants.IS_WALKER_STARTED);
          // status = AndyConstants.IS_WALKER_STARTED;
        } else if (object.getInt(IS_WALKER_ARRIVED) == 0) {
          requestDetail.setJobStatus(AndyConstants.IS_WALKER_ARRIVED);
          // status = AndyConstants.IS_WALKER_ARRIVED;
        } else if (object.getInt(IS_WALK_STARTED) == 0) {
          requestDetail.setJobStatus(AndyConstants.IS_WALK_STARTED);
          // status = AndyConstants.IS_WALK_STARTED;
        } else if (object.getInt(IS_WALK_COMPLETED) == 0) {
          preferenceHelper.putIsTripStart(true);
          requestDetail.setJobStatus(AndyConstants.IS_WALK_COMPLETED);
          // status = AndyConstants.IS_WALK_COMPLETED;
        } else if (object.getInt(IS_DOG_RATED) == 0) {
          requestDetail.setJobStatus(AndyConstants.IS_DOG_RATED);
          // status = AndyConstants.IS_DOG_RATED;
        }

        String time = object.optString(AndyConstants.Params.START_TIME);
        // "start_time": "2014-11-20 03:27:37"
        if (!TextUtils.isEmpty(time)) {
          try {
            TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
            Date date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.ENGLISH).parse(time);
            AppLog.Log("TAG", "START DATE---->" + date.toString() + " month:" + date.getMonth());
            preferenceHelper.putRequestTime(date.getTime());
            requestDetail.setStartTime(date.getTime());
          } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }

        JSONObject ownerDetailObject = object.getJSONObject(AndyConstants.Params.OWNER);
        requestDetail.setClientName(ownerDetailObject.getString(AndyConstants.Params.NAME));
        requestDetail.setClientProfile(ownerDetailObject.getString(AndyConstants.Params.PICTURE));
        requestDetail.setClientPhoneNumber(ownerDetailObject.getString(AndyConstants.Params.PHONE));
        requestDetail.setClientRating(
            (float) ownerDetailObject.optDouble(AndyConstants.Params.RATING));
        requestDetail.setClientLatitude(ownerDetailObject.getString(AndyConstants.Params.LATITUDE));
        requestDetail.setClientLongitude(
            ownerDetailObject.getString(AndyConstants.Params.LONGITUDE));
        requestDetail.setClientAddress(ownerDetailObject.getString(AndyConstants.Params.ADDRESS));

        requestDetail.setUnit(object.getString("unit"));
        JSONObject jsonObjectBill = jsonObject.optJSONObject("bill");
        if (jsonObjectBill != null) {
          requestDetail.setTime(jsonObjectBill.getString("time"));
          requestDetail.setDistance(jsonObjectBill.getString("distance"));
        }
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return requestDetail;
  }
예제 #4
0
  @Override
  public void onTaskCompleted(String response, int serviceCode) {
    AndyUtils.removeCustomProgressDialog();
    switch (serviceCode) {
      case AndyConstants.ServiceCode.WALKER_STARTED:
        AppLog.Log(TAG, "walker started response " + response);
        if (parseContent.isSuccess(response)) {
          jobStatus = AndyConstants.IS_WALKER_ARRIVED;
          setjobStatus(jobStatus);
        }

        break;
      case AndyConstants.ServiceCode.WALKER_ARRIVED:
        AppLog.Log(TAG, "walker arrived response " + response);
        if (parseContent.isSuccess(response)) {
          jobStatus = AndyConstants.IS_WALK_STARTED;
          setjobStatus(jobStatus);
        }
        break;
      case AndyConstants.ServiceCode.WALK_STARTED:
        AppLog.Log(TAG, "walk started response " + response);
        Log.d("amal", response);
        if (parseContent.isSuccess(response)) {
          preferenceHelper.putIsTripStart(true);
          jobStatus = AndyConstants.IS_WALK_COMPLETED;
          setjobStatus(jobStatus);
          // getDistance();
          preferenceHelper.putRequestTime(Calendar.getInstance().getTimeInMillis());
          if (markerClientLocation != null) {
            markerClientLocation.setTitle(
                mapActivity.getResources().getString(R.string.job_start_location));
            markerClientLocation.remove();
          }
          startElapsedTimer();
        }

        break;
      case AndyConstants.ServiceCode.WALK_COMPLETED:
        AppLog.Log(TAG, "walk completed response" + response);
        Log.d("mahi", "response done" + response);
        if (parseContent.isSuccess(response)) {
          FeedbackFrament feedbackFrament = new FeedbackFrament();
          Bundle bundle = new Bundle();
          bundle.putSerializable(AndyConstants.REQUEST_DETAIL, requestDetail);
          Bill bill = parseContent.parsebillwhenwalkcomplete(response);
          bundle.putSerializable("bill", bill);
          // bundle.putString(
          // AndyConstants.Params.TIME,
          // time
          // + " "
          // + mapActivity.getResources().getString(
          // R.string.text_mins));
          // bundle.putString(
          // AndyConstants.Params.DISTANCE,
          // decimalFormat.format(preferenceHelper.getDistance())
          // // / (1000 * 1.62))
          // + " "
          // + mapActivity.getResources().getString(
          // R.string.text_miles));

          requestDetail.setTime(time);
          requestDetail.setDistance(" " + preferenceHelper.getDistance());
          requestDetail.setUnit(preferenceHelper.getUnit());
          feedbackFrament.setArguments(bundle);
          preferenceHelper.clearRequestData();
          mapActivity.addFragment(
              new ClientRequestFragment(), false, AndyConstants.CLIENT_REQUEST_TAG, true);

          // removing feedback
          // mapActivity.addFragment(feedbackFrament, false,
          //		AndyConstants.FEEDBACK_FRAGMENT_TAG, true);
        }
        break;

      case AndyConstants.ServiceCode.GET_ROUTE:
        // if (parseContent.isSuccess(response)) {
        // jobStatus = AndyConstants.;
        // setjobStatus(jobStatus);
        // }
      case AndyConstants.ServiceCode.PATH_REQUEST:
        AppLog.Log(TAG, "Path request :" + response);
        if (parseContent.isSuccess(response)) {
          parseContent.parsePathRequest(response, points);
          initPreviousDrawPath();
        }
        break;
      default:
        break;
    }
  }