private void loadCouriersHistoryFromServer() {
   List<NameValuePair> nameValuePairs = new ArrayList<>();
   nameValuePairs.add(
       new BasicNameValuePair(
           "userId", SdcsCommon.getValueFromAppSharedPreferences(getActivity(), "customerId")));
   SdcsPostWebServiceAsyncTask postWebServiceAsyncTask =
       new SdcsPostWebServiceAsyncTask(mContext, nameValuePairs, this);
   postWebServiceAsyncTask.execute(SdcsConstants.COURIER_HISTORY);
 }
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   //        view.setBackgroundColor(getResources().getColor(R.color.colorBtnNormal));
   SdcsCommon.setSdcsSelectedHistory(_mHistory.get(position));
   FragmentManager mFragmentManager = getFragmentManager();
   mFragmentManager
       .beginTransaction()
       .replace(R.id.fragmentContainer, new SdcsCourierHistoryDetailsFragment())
       .commit();
 }
  private void parseCourierHistoryJsonArray(JSONArray historyData) {
    if (historyData != null) {
      _mHistory = new ArrayList<>();

      String historyFor =
          SdcsCommon.getValueFromAppSharedPreferences(
              getActivity(),
              "historyFor"); // We have local storage value to find out for which purpose history
                             // details are displayed

      for (int index = 0; index < historyData.length(); index++) {

        JSONObject historyJson = historyData.optJSONObject(index);
        if (historyJson != null) {

          // Only un dispatched couriers can be changed to another office.
          if (historyFor != null
              && historyFor.equals("forChangingOffice")
              && historyJson.optString("delivery_taken").equals("0")) {
            _mHistory.add(
                new SdcsHistory(
                    historyJson.optString("courier_content"),
                    historyJson.optString("office_address").trim(),
                    historyJson.optString("sender_name").trim(),
                    historyJson.optString("sender_address").trim(),
                    historyJson.optString("sender_landmark").trim(),
                    historyJson.optString("sender_pincode").trim(),
                    historyJson.optString("sender_phone").trim(),
                    historyJson.optString("sender_email").trim(),
                    historyJson.optString("receiver_name").trim(),
                    historyJson.optString("receiver_address").trim(),
                    historyJson.optString("receiver_landmark").trim(),
                    historyJson.optString("receiver_pincode").trim(),
                    historyJson.optString("receiver_phone").trim(),
                    historyJson.optString("receiver_email").trim(),
                    historyJson.optString("office_id").trim(),
                    historyJson.optString("date_of_booking").trim(),
                    historyJson.optString("booking_id").trim(),
                    historyJson.optString("delivery_taken").trim(),
                    historyJson.optString("landmark").trim(),
                    historyJson.optString("office_name").trim()));
          } else {
            _mHistory.add(
                new SdcsHistory(
                    historyJson.optString("courier_content"),
                    historyJson.optString("office_address").trim(),
                    historyJson.optString("sender_name").trim(),
                    historyJson.optString("sender_address").trim(),
                    historyJson.optString("sender_landmark").trim(),
                    historyJson.optString("sender_pincode").trim(),
                    historyJson.optString("sender_phone").trim(),
                    historyJson.optString("sender_email").trim(),
                    historyJson.optString("receiver_name").trim(),
                    historyJson.optString("receiver_address").trim(),
                    historyJson.optString("receiver_landmark").trim(),
                    historyJson.optString("receiver_pincode").trim(),
                    historyJson.optString("receiver_phone").trim(),
                    historyJson.optString("receiver_email").trim(),
                    historyJson.optString("office_id").trim(),
                    historyJson.optString("date_of_booking").trim(),
                    historyJson.optString("booking_id").trim(),
                    historyJson.optString("delivery_taken").trim(),
                    historyJson.optString("landmark").trim(),
                    historyJson.optString("office_name").trim()));
          }
        }
      }
      if (_mHistory.size() > 0) {
        _mLblEmptyCourierHistory.setVisibility(View.GONE);
        _mLstCourierHistory.setVisibility(View.VISIBLE);
        showCourierHistoryList();
      } else {
        _mLblEmptyCourierHistory.setVisibility(View.VISIBLE);
        _mLstCourierHistory.setVisibility(View.GONE);
      }
    }
  }