@Override
  protected void onPause() {
    super.onPause();

    AnalyticsHelper.sendSearchUpdate(this, query);
    query = "";
  }
  @Override
  protected void onPostExecute(APIResponse.CODE code) {
    super.onPostExecute(code);
    // android gets angry if you modify Views off the UI thread, so we do the actual View
    // manipulation here
    View view = fragment.getView();
    if (view != null && activity != null) {
      ListViewAdapter adapter = new ListViewAdapter(activity, districts);
      TextView noDataText = (TextView) view.findViewById(R.id.no_data);

      // If there's no data in the adapter or if we can't download info
      // off the web, display a message.
      if ((code == APIResponse.CODE.NODATA && !ConnectionDetector.isConnectedToInternet(activity))
          || (!requestParams.forceFromCache && adapter.values.isEmpty())) {
        noDataText.setText(R.string.no_district_list);
        noDataText.setVisibility(View.VISIBLE);
      } else {
        ListView eventList = (ListView) view.findViewById(R.id.list);
        Parcelable state = eventList.onSaveInstanceState();
        eventList.setAdapter(adapter);
        noDataText.setVisibility(View.GONE);
        eventList.onRestoreInstanceState(state);
      }

      if (code == APIResponse.CODE.OFFLINECACHE) {
        activity.showWarningMessage(fragment.getString(R.string.warning_using_cached_data));
      }

      view.findViewById(R.id.progress).setVisibility(View.GONE);
      view.findViewById(R.id.list).setVisibility(View.VISIBLE);

      if (code == APIResponse.CODE.LOCAL && !isCancelled()) {
        /**
         * The data has the possibility of being updated, but we at first loaded what we have cached
         * locally for performance reasons. Thus, fire off this task again with a flag saying to
         * actually load from the web
         */
        requestParams.forceFromCache = false;
        PopulateDistrictList second = new PopulateDistrictList(fragment, requestParams);
        fragment.updateTask(second);
        second.execute(year);
      } else if (activity != null) {
        // Show notification if we've refreshed data.
        Log.d(Constants.REFRESH_LOG, "Event list refresh complete");
        activity.notifyRefreshComplete(fragment);
      }

      AnalyticsHelper.sendTimingUpdate(
          activity,
          System.currentTimeMillis() - startTime,
          "district list",
          Integer.toString(year));
    }
  }