Example usage for android.text TextUtils join

List of usage examples for android.text TextUtils join

Introduction

In this page you can find the example usage for android.text TextUtils join.

Prototype

public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens) 

Source Link

Document

Returns a string containing the tokens joined by delimiters.

Usage

From source file:org.apps8os.contextlogger3.android.clientframework.ActivityRecognitionService.java

private void handleActivityRecognitionResult(final ActivityRecognitionResult result) {
    Bundle data = new Bundle();
    // Get the most probable activity
    DetectedActivity mostProbableActivity = result.getMostProbableActivity();
    String activityName = ActivityType.getActivityTypeByReference(mostProbableActivity.getType());
    data.putString("Activity", activityName);
    data.putString("ActivityConfidence", String.valueOf(mostProbableActivity.getConfidence()));
    try {//from  w ww.  j ava  2s .  c  o  m
        List<DetectedActivity> daList = result.getProbableActivities();
        if ((daList != null) && (!daList.isEmpty())) {
            JSONArray jsonArray = new JSONArray();
            for (DetectedActivity da : daList) {
                JSONObject daObject = new JSONObject();
                daObject.put("Activity", ActivityType.getActivityTypeByReference(da.getType()));
                daObject.put("ActivityConfidence", String.valueOf(da.getConfidence()));
                jsonArray.put(daObject);
            }
            if (jsonArray.length() > 0) {
                data.putString("ProbableActivities", jsonArray.toString());
            }
        }

    } catch (Exception e) {
        Log.e(ActivityRecognitionService.class.getCanonicalName(), "error: ", e);
        String probableActivities = TextUtils.join("|", result.getProbableActivities());
        data.putString("ProbableActivities", probableActivities);
    }
    data.putString("timestamp", String.valueOf(result.getTime()));
    Intent intent = new Intent(GoogleActivityRecognitionProbe.INTENT_ACTION);
    intent.putExtras(data);
    LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
}

From source file:com.deliciousdroid.platform.BundleManager.java

public static CursorLoader SearchBundles(String query, String username, Context context) {
    String[] projection = new String[] { Bundle._ID, Bundle.Name, Bundle.Tags };
    String selection = null;//from   w  w w.  j a  v a2s.co  m
    String sortorder = null;

    String[] queryBundles = query.split(" ");

    ArrayList<String> queryList = new ArrayList<String>();
    final ArrayList<String> selectionlist = new ArrayList<String>();

    for (String s : queryBundles) {
        queryList.add(Bundle.Name + " LIKE ?");
        selectionlist.add("%" + s + "%");
    }
    selectionlist.add(username);

    if (query != null && query != "") {
        selection = "(" + TextUtils.join(" OR ", queryList) + ")" + " AND " + Bundle.Account + "=?";
    } else {
        selection = Bundle.Account + "=?";
    }

    sortorder = Bundle.Name + " ASC";

    Uri bundles = Bundle.CONTENT_URI;

    return new CursorLoader(context, bundles, projection, selection, selectionlist.toArray(new String[] {}),
            sortorder);
}

From source file:com.eTilbudsavis.etasdk.network.impl.JsonArrayRequest.java

/**
 * Set a list of "order_by" parameters that the API should order the data by.
 * @param order parameters to order data by
 * @return/*from   w w  w  .  java 2  s .  co  m*/
 */
public Request<?> setOrderBy(List<String> order) {
    String tmp = TextUtils.join(",", order);
    getParameters().put(Api.Param.ORDER_BY, tmp);
    return this;
}

From source file:cordova.BackgroundSubscribeIntentService.java

private String getContentText(List<String> messages) {
        String newline = System.getProperty("line.separator");
        if (messages.size() < NUM_MESSAGES_IN_NOTIFICATION) {
            return TextUtils.join(newline, messages);
        }//from  w ww. j  a v a  2s. co m
        return TextUtils.join(newline, messages.subList(0, NUM_MESSAGES_IN_NOTIFICATION)) + newline + "&#8230;";
    }

From source file:com.example.automationapp.automationapp.Map.GeofenceTransitionsIntentService.java

/**
 * Gets transition details and returns them as a formatted string.
 *
 * @param context               The app context.
 * @param geofenceTransition    The ID of the geofence transition.
 * @param triggeringGeofences   The geofence(s) triggered.
 * @return                      The transition details formatted as String.
 *///  w  w w.j  a  v a2  s  .  c  o m
private String getGeofenceTransitionDetails(Context context, int geofenceTransition,
        List<Geofence> triggeringGeofences) {

    String geofenceTransitionString = getTransitionString(geofenceTransition);

    // Get the Ids of each geofence that was triggered.
    ArrayList triggeringGeofencesIdsList = new ArrayList();
    for (Geofence geofence : triggeringGeofences) {
        triggeringGeofencesIdsList.add(geofence.getRequestId());
    }

    String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList);

    return geofenceTransitionString + ": " + triggeringGeofencesIdsString;
}

From source file:cn.com.dfc.pl.afinal.http.PreferencesCookieStore.java

@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // cookies
            cookies.remove(name);//w w w . j  ava  2s. co  m

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    prefsWriter.commit();

    return clearedAny;
}

From source file:cn.isif.util_plus.util.PreferencesCookieStore.java

@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor editor = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.getExpiryDate() == null || cookie.isExpired(date)) {
            // Remove the cookie by name
            cookies.remove(name);/*from w  w  w  . ja  va  2s . co m*/

            // Clear cookies from persistent store
            editor.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        editor.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    editor.commit();

    return clearedAny;
}

From source file:com.skybee.tracker.service.GeofenceTransitionsIntentService.java

/**
 * Gets transition details and returns them as a formatted string.
 *
 * @param context               The app context.
 * @param geofenceTransition    The ID of the geofence transition.
 * @param triggeringGeofences   The geofence(s) triggered.
 * @return The transition details formatted as String.
 *///from  w w  w .  j  av a2  s  .  com
private String getGeofenceTransitionDetails(Context context, int geofenceTransition,
        List<Geofence> triggeringGeofences) {

    String geofenceTransitionString = getTransitionString(geofenceTransition);
    // Get the Ids of each geofence that was triggered.
    ArrayList triggeringGeofencesIdsList = new ArrayList();
    for (Geofence geofence : triggeringGeofences) {
        triggeringGeofencesIdsList.add(geofence.getRequestId());
    }
    String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList);
    return geofenceTransitionString + ": " + triggeringGeofencesIdsString;
}

From source file:com.facebook.login.LoginLogger.java

public void logStartLogin(LoginClient.Request pendingLoginRequest) {
    Bundle bundle = newAuthorizationLoggingBundle(pendingLoginRequest.getAuthId());

    // Log what we already know about the call in start event
    try {//from  w  w  w  .  j a v a 2s. c o m
        JSONObject extras = new JSONObject();
        extras.put(EVENT_EXTRAS_LOGIN_BEHAVIOR, pendingLoginRequest.getLoginBehavior().toString());
        extras.put(EVENT_EXTRAS_REQUEST_CODE, LoginClient.getLoginRequestCode());
        extras.put(EVENT_EXTRAS_PERMISSIONS, TextUtils.join(",", pendingLoginRequest.getPermissions()));
        extras.put(EVENT_EXTRAS_DEFAULT_AUDIENCE, pendingLoginRequest.getDefaultAudience().toString());
        extras.put(EVENT_EXTRAS_IS_REAUTHORIZE, pendingLoginRequest.isRerequest());
        bundle.putString(EVENT_PARAM_EXTRAS, extras.toString());
    } catch (JSONException e) {
    }

    appEventsLogger.logSdkEvent(EVENT_NAME_LOGIN_START, null, bundle);
}

From source file:com.commonsware.android.databind.basic.QuestionsFragment.java

private void updateQuestions() {
    ArrayList<String> idList = new ArrayList<String>();

    for (Question question : questions) {
        idList.add(question.id);//from   www  . j a v  a  2s. co  m
    }

    String ids = TextUtils.join(";", idList);

    unsub();
    sub = so.update(ids).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io())
            .subscribe(result -> {
                for (Item item : result.items) {
                    Question question = questionMap.get(item.id);

                    if (question != null) {
                        question.updateFromItem(item);
                    }
                }
            }, t -> {
                Toast.makeText(getActivity(), t.getMessage(), Toast.LENGTH_LONG).show();
                Log.e(getClass().getSimpleName(), "Exception from Retrofit request to StackOverflow", t);
            });
}