예제 #1
0
  @Override
  public LoaderResult<ArrayList<ExtendedHashMap>> loadInBackground() {
    if (mListRequestHandler == null) {
      throw new UnsupportedOperationException(
          "Method doInBackground not re-implemented while no ListRequestHandler has been given");
    }

    if (mRequireLocsAndTags) {
      if (DreamDroid.getLocations().size() <= 1) {
        if (!DreamDroid.loadLocations(mShc)) {
          Log.e(DreamDroid.LOG_TAG, "ERROR loading locations");
        }
      }

      if (DreamDroid.getTags().size() <= 1) {
        if (!DreamDroid.loadTags(mShc)) {
          Log.e(DreamDroid.LOG_TAG, "ERROR loading tags");
        }
      }
    }

    mList = new ArrayList<>();
    LoaderResult<ArrayList<ExtendedHashMap>> result = new LoaderResult<>();

    String xml = mListRequestHandler.getList(mShc, mParams);
    if (xml != null) {
      mList.clear();
      if (mListRequestHandler.parseList(xml, mList)) result.set(mList);
      else result.set(getContext().getString(R.string.error_parsing));
    } else {
      if (mShc.hasError()) result.set(mShc.getErrorText(getContext()));
      else result.set(getContext().getString(R.string.error));
    }
    return result;
  }
예제 #2
0
 protected SimpleHttpClient getHttpClient() {
   if (mShc == null) mShc = SimpleHttpClient.getInstance();
   return mShc;
 }