Example usage for android.os Bundle keySet

List of usage examples for android.os Bundle keySet

Introduction

In this page you can find the example usage for android.os Bundle keySet.

Prototype

public Set<String> keySet() 

Source Link

Document

Returns a Set containing the Strings used as keys in this Bundle.

Usage

From source file:ee.ioc.phon.android.speak.Utils.java

private static List<String> ppBundle(String bundleName, Bundle bundle) {
    List<String> strings = new ArrayList<String>();
    for (String key : bundle.keySet()) {
        Object value = bundle.get(key);
        String name = bundleName + key;
        if (value instanceof Bundle) {
            strings.addAll(ppBundle(name + "/", (Bundle) value));
        } else {//w ww.  ja va2  s. c  o  m
            if (value instanceof Object[]) {
                strings.add(name + ": " + Arrays.toString((Object[]) value));
            } else if (value instanceof float[]) {
                strings.add(name + ": " + Arrays.toString((float[]) value));
            } else {
                strings.add(name + ": " + value);
            }
        }
    }
    return strings;
}

From source file:com.eyekabob.util.facebook.Util.java

/**
 * Generate the multi-part post body providing the parameters and boundary
 * string//from w  w  w  .  j  av  a 2 s .c  o m
 * 
 * @param parameters the parameters need to be posted
 * @param boundary the random string as boundary
 * @return a string of the post body
 */
// COFFBR01 MODIFIED.
public static String encodePostBody(Bundle parameters, String boundary) {
    if (parameters == null)
        return "";
    StringBuilder sb = new StringBuilder();

    for (String key : parameters.keySet()) {
        Object value = parameters.get(key);
        if (value instanceof byte[]) {
            continue;
        }

        sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + value);
        sb.append("\r\n" + "--" + boundary + "\r\n");
    }

    return sb.toString();
}

From source file:com.facebook.android.library.Util.java

/**
 * Generate the multi-part post body providing the parameters and boundary
 * string/*from   w w w  .ja va 2 s  .  c  o m*/
 * 
 * @param parameters
 *            the parameters need to be posted
 * @param boundary
 *            the random string as boundary
 * @return a string of the post body
 */
public static String encodePostBody(Bundle parameters, String boundary) {
    if (parameters == null)
        return "";
    StringBuilder sb = new StringBuilder();

    for (String key : parameters.keySet()) {
        if (parameters.get(key) instanceof byte[]) {
            continue;
        }

        sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + parameters.getString(key));
        sb.append("\r\n" + "--" + boundary + "\r\n");
    }

    return sb.toString();
}

From source file:com.captix.scan.social.facebook.Util.java

@SuppressWarnings("deprecation")
public static String encodeUrl(Bundle parameters) {
    if (parameters == null) {
        return "";
    }/*from  w  ww.j  a va2s  .c om*/

    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (String key : parameters.keySet()) {
        if (first)
            first = false;
        else
            sb.append("&");
        sb.append(URLEncoder.encode(key) + "=" + URLEncoder.encode(parameters.getString(key)));
    }
    return sb.toString();
}

From source file:com.antew.redditinpictures.library.service.RESTService.java

private static List<BasicNameValuePair> paramsToList(Bundle params) {
    ArrayList<BasicNameValuePair> formList = new ArrayList<BasicNameValuePair>(params.size());

    for (String key : params.keySet()) {
        Object value = params.get(key);

        // We can only put Strings in a form entity, so we call the toString()
        // method to enforce. We also probably don't need to check for null here
        // but we do anyway because Bundle.get() can return null.
        if (value != null) {
            formList.add(new BasicNameValuePair(key, value.toString()));
        }//from   w ww  .  java 2 s .  c om
    }

    return formList;
}

From source file:de.geeksfactory.opacclient.OpacClient.java

public static Map<String, String> bundleToMap(Bundle bundle) {
    if (bundle == null) {
        return null;
    }// www. j  a  va 2 s.c o  m
    Map<String, String> map = new HashMap<>();
    for (String e : bundle.keySet()) {
        map.put(e, (String) bundle.get(e));
    }
    return map;
}

From source file:com.wareninja.android.opensource.oauth2login.common.Utils.java

/**
 * Generate the multi-part post body providing the parameters and boundary
 * string//from w w w.j ava2s . c  o  m
 * 
 * @param parameters the parameters need to be posted
 * @param boundary the random string as boundary
 * @return a string of the post body
 */
public static String encodePostBody(Bundle parameters, String boundary) {
    if (parameters == null)
        return "";
    StringBuilder sb = new StringBuilder();

    for (String key : parameters.keySet()) {

        /*//YG:removed this from sdk
        try{
         if (parameters.getByteArray(key) != null) {
            continue;
         }
        }catch(Exception ex){}
        */

        sb.append("Content-Disposition: form-data; name=\"" + key +
        //"\"\r\n\r\n" + parameters.getString(key));
                "\"\r\n\r\n" + parameters.get(key));//to avoid type clash
        sb.append("\r\n" + "--" + boundary + "\r\n");
    }

    return sb.toString();
}

From source file:de.geeksfactory.opacclient.OpacClient.java

public static List<SearchQuery> bundleToQuery(Bundle bundle) {
    if (bundle == null) {
        return null;
    }/*ww  w .  j  a  v  a2s. c  o m*/
    List<SearchQuery> query = new ArrayList<>();
    for (String e : bundle.keySet()) {
        try {
            query.add(new SearchQuery(SearchField.fromJSON(new JSONObject(e)), bundle.getString(e)));
        } catch (JSONException e1) {
            e1.printStackTrace();
        }
    }
    return query;
}

From source file:com.permpings.utils.facebook.sdk.Util.java

public static String encodeUrl(Bundle parameters) {
    if (parameters == null) {
        return "";
    }/*from w  w w. ja v  a 2s.  c om*/

    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (String key : parameters.keySet()) {
        Object parameter = parameters.get(key);
        if (!(parameter instanceof String)) {
            continue;
        }

        if (first)
            first = false;
        else
            sb.append("&");
        try {
            sb.append(URLEncoder.encode(key, HTTP.UTF_8) + "="
                    + URLEncoder.encode(parameters.getString(key), HTTP.UTF_8));
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return sb.toString();
}

From source file:com.ble.facebook.Util.java

/**
 * Generate the multi-part post body providing the parameters and boundary
 * string/* w ww  .  jav a 2s  . c o  m*/
 * 
 * @param parameters the parameters need to be posted
 * @param boundary the random string as boundary
 * @return a string of the post body
 */
public static String encodePostBody(Bundle parameters, String boundary) {
    if (parameters == null)
        return "";
    StringBuilder sb = new StringBuilder();

    for (String key : parameters.keySet()) {

        if (parameters.getByteArray(key) != null) {
            continue;
        }

        sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + parameters.getString(key));
        sb.append("\r\n" + "--" + boundary + "\r\n");
    }
    Log.d("encodePostBody", sb.toString());
    return sb.toString();
}