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:com.scv.slackgo.services.GeofenceTransitionsIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    GeofencingEvent event = GeofencingEvent.fromIntent(intent);
    if (event.hasError()) {
        Log.e(TAG, "GeofencingEvent Error: " + event.getErrorCode());
        String description = getGeofenceTransitionDetails(event);
        sendNotification(getString(R.string.generic_notification_title), description);
        return;//from  ww  w  .ja  v a 2  s. c  o  m
    }
    int transitionType = event.getGeofenceTransition();
    channelsForLocationMap = GeofenceUtils.getChannelsForGeofences(locationsStore,
            event.getTriggeringGeofences());
    if (channelsList == null) {
        channelsList = locationsStore.getChannelsList();
    }

    Set<String> channelNames = new HashSet<>();
    for (List<Channel> channelList : channelsForLocationMap.values()) {
        for (Channel channel : channelList) {
            channelNames.add(channel.getName());
        }
    }
    String channels = TextUtils.join(", ", channelNames);
    String locations = TextUtils.join(", ", channelsForLocationMap.keySet());

    String title = "";
    String message = "";
    SlackApiService slackApiService = new SlackApiService(this);
    if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER) {
        title = getString(R.string.entering_geofence_title, locations);
        message = getString(R.string.entering_geofence_message, channels);
        joinChannelsFromGeofences(event.getTriggeringGeofences(), slackApiService);
    } else if (transitionType == Geofence.GEOFENCE_TRANSITION_EXIT) {
        title = getString(R.string.going_out_geofence_title, locations);
        message = getString(R.string.going_out_geofence_message, channels);
        leaveChannelsFromGeofences(event.getTriggeringGeofences(), slackApiService);
    }
    sendNotification(title, message);
}

From source file:nevermind.binaryb.android.geofencing.GeofenceTransitionsIntentService.java

private String[] getGeofenceTransitionDetails(Context context, int geofenceTransition,
        List<Geofence> triggeringGeofences) {
    String geofenceTransitionString = getTransitionString(geofenceTransition);
    ArrayList triggeringGeofencesIdsList = new ArrayList();
    for (Geofence geofence : triggeringGeofences) {
        triggeringGeofencesIdsList.add(geofence.getRequestId());
    }/*  w w  w.j a  va  2  s.c o m*/
    String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList);
    String[] parts = triggeringGeofencesIdsString.split("-");

    return parts;
}

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

@Override
public void addCookie(Cookie cookie) {
    String name = cookie.getName();

    // Save cookie into local store, or remove if expired
    if (!cookie.isExpired(new Date())) {
        cookies.put(name, cookie);/*w w w . j a  v  a 2s . c o  m*/
    } else {
        cookies.remove(name);
    }

    // Save cookie into persistent store
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
    prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie)));
    prefsWriter.commit();
}

From source file:com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment.java

static void updateCustomInputStylesSummary(final Preference pref) {
    // When we are called from the Settings application but we are not already running, some
    // singleton and utility classes may not have been initialized.  We have to call
    // initialization method of these classes here. See {@link LatinIME#onCreate()}.
    SubtypeLocaleUtils.init(pref.getContext());

    final Resources res = pref.getContext().getResources();
    final SharedPreferences prefs = pref.getSharedPreferences();
    final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res);
    final InputMethodSubtype[] subtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
    final ArrayList<String> subtypeNames = new ArrayList<>();
    for (final InputMethodSubtype subtype : subtypes) {
        subtypeNames.add(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype));
    }//from w w w .j a  va  2  s . c  om
    // TODO: A delimiter of custom input styles should be localized.
    pref.setSummary(TextUtils.join(", ", subtypeNames));
}

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

@Override
public void addCookie(Cookie cookie) {
    String name = cookie.getName();

    // Save cookie into local store, or remove if expired
    if (!cookie.isExpired(new Date())) {
        cookies.put(name, cookie);//from www  .  ja v a  2s  .co m
    } else {
        cookies.remove(name);
    }

    // Save cookie into persistent store
    SharedPreferences.Editor editor = cookiePrefs.edit();
    editor.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    editor.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie)));
    editor.commit();
}

From source file:eu.faircode.netguard.ForwardingAdapter.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    // Get values
    int protocol = cursor.getInt(colProtocol);
    int dport = cursor.getInt(colDPort);
    String raddr = cursor.getString(colRAddr);
    int rport = cursor.getInt(colRPort);
    int ruid = cursor.getInt(colRUid);

    // Get views//ww w .  j a  v  a 2  s  .c  om
    TextView tvProtocol = (TextView) view.findViewById(R.id.tvProtocol);
    TextView tvDPort = (TextView) view.findViewById(R.id.tvDPort);
    TextView tvRAddr = (TextView) view.findViewById(R.id.tvRAddr);
    TextView tvRPort = (TextView) view.findViewById(R.id.tvRPort);
    TextView tvRUid = (TextView) view.findViewById(R.id.tvRUid);

    tvProtocol.setText(Util.getProtocolName(protocol, 0, false));
    tvDPort.setText(Integer.toString(dport));
    tvRAddr.setText(raddr);
    tvRPort.setText(Integer.toString(rport));
    tvRUid.setText(TextUtils.join(", ", Util.getApplicationNames(ruid, context)));
}

From source file:es.diaketroid.http.cookies.PersistentCookieStore.java

public void addCookie(Cookie cookie) {
    String name = cookie.getName();

    // Save cookie into local store
    cookies.put(name, cookie);/*  ww  w .  j  av a  2 s  . c  o  m*/

    // Save cookie into persistent store
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
    prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie)));
    prefsWriter.commit();
}

From source file:com.adflake.adapters.MobClixAdapter.java

@Override
public String keywords() {
    String keywords = AdFlakeTargeting.getKeywordSet() != null
            ? TextUtils.join(",", AdFlakeTargeting.getKeywordSet())
            : AdFlakeTargeting.getKeywords();

    return keywords;
}

From source file:com.google.android.vending.licensing.ResponseData.java

@Override
public String toString() {
    return TextUtils.join("|",
            new Object[] { responseCode, nonce, packageName, versionCode, userId, timestamp });
}

From source file:com.corebase.android.framework.http.client.PersistentCookieStore.java

public void addCookie(Cookie cookie) {
    String name = cookie.getName();

    // Save cookie into local store, or remove if expired
    if (!cookie.isExpired(new Date())) {
        cookies.put(name, cookie);/*from  ww  w .ja v  a2 s .c om*/
    } else {
        cookies.remove(name);
    }

    // Save cookie into persistent store
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
    prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie)));
    prefsWriter.commit();
}