Пример #1
0
 public static String encodeParameters(
     final List<HttpParameter> httpParams, final String splitter, final boolean quot) {
   final StringBuffer buf = new StringBuffer();
   for (final HttpParameter param : httpParams) {
     if (!param.isFile()) {
       if (buf.length() != 0) {
         if (quot) {
           buf.append("\"");
         }
         buf.append(splitter);
       }
       buf.append(HttpParameter.encode(param.getName())).append("=");
       if (quot) {
         buf.append("\"");
       }
       buf.append(HttpParameter.encode(param.getValue()));
     }
   }
   if (buf.length() != 0) {
     if (quot) {
       buf.append("\"");
     }
   }
   return buf.toString();
 }
Пример #2
0
  /* package */ HttpParameter[] asHttpParameterArray(final HttpParameter includeEntities) {
    final ArrayList<HttpParameter> params = new ArrayList<HttpParameter>();
    appendParameter("status", status, params);
    if (-1 != inReplyToStatusId) {
      appendParameter("in_reply_to_status_id", inReplyToStatusId, params);
    }
    if (location != null) {
      appendParameter("lat", location.getLatitude(), params);
      appendParameter("long", location.getLongitude(), params);
    }
    appendParameter("place_id", placeId, params);
    if (!displayCoordinates) {
      appendParameter("display_coordinates", "false", params);
    }
    params.add(includeEntities);
    if (null != mediaFile) {
      Log.v("StatusUpdate", "null != mediaFile");
      params.add(new HttpParameter("media[]", mediaFile));
      params.add(new HttpParameter("possibly_sensitive", possiblySensitive));
    } else if (mediaName != null && mediaBody != null) {
      Log.v("StatusUpdate", "mediaName != null && mediaBody != null");
      params.add(new HttpParameter("media[]", mediaName, mediaBody));
      params.add(new HttpParameter("possibly_sensitive", possiblySensitive));
    }

    final HttpParameter[] paramArray = new HttpParameter[params.size()];
    for (HttpParameter param : params) {
      Log.v("StatusUpdate", "name " + param.getName());
      Log.v("StatusUpdate", "name " + param.getValue());
    }

    return params.toArray(paramArray);
  }