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:ar.org.fsadosky.iptablesmanager.activity.MainActivity.java

@Override
public void onChangesApplied(List<ApplicationItem> applications) {
    saveApplications(applications);// w  w w .  j  av  a2s  .c  om

    Integer vpn_client = 0;
    List<Integer> uids = new ArrayList<>();

    for (ApplicationItem applicationItem : applications) {
        switch (applicationItem.getState()) {
        case VPN_CLIENT:
            vpn_client = applicationItem.getUID();
            break;
        case BLOCK:
            Log.d("DEBUG", "Block");
            break;
        case ALLOW:
            uids.add(applicationItem.getUID());
            break;
        default:
            Log.d("DEBUG", "There was a problem");
            break;
        }
    }

    if (vpn_client != 0) {
        SystemProperties.set("persist.security.vpn.uid", "" + vpn_client);
    } else {
        SystemProperties.set("persist.security.vpn.uid", "");
    }

    if (uids.size() > 0) {
        SystemProperties.set("persist.security.whitelist", TextUtils.join(", ", uids));
    }

}

From source file:com.i2r.alan.rate_this_place.visitedplace.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   ww  w.  j av  a 2s  .  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());
        addDB(geofence.getRequestId());
    }
    String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList);

    return geofenceTransitionString + ": " + triggeringGeofencesIdsString;
}

From source file:com.aoeng.degu.utils.net.asyncthhpclient.PersistentCookieStore.java

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)) {
            // Clear cookies from local store
            cookies.remove(name);/* w ww  .java  2  s.  c om*/

            // 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:com.xengar.android.booksearch.ui.BookDetailActivity.java

private void loadBook(Book book) {
    //change activity title
    this.setTitle(book.getTitle());
    // Populate data
    Picasso.with(this).load(Uri.parse(book.getLargeCoverUrl())).error(R.drawable.ic_nocover).into(ivBookCover);
    tvTitle.setText(book.getTitle());//from w  w  w  .  j  av  a  2s .com
    tvAuthor.setText(book.getAuthor());
    // fetch extra book data from books API
    client = new BookClient();
    client.getExtraBookDetails(book.getOpenLibraryId(), new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            try {
                if (response.has("publishers")) {
                    // display comma separated list of publishers
                    final JSONArray publisher = response.getJSONArray("publishers");
                    final int numPublishers = publisher.length();
                    final String[] publishers = new String[numPublishers];
                    for (int i = 0; i < numPublishers; ++i) {
                        publishers[i] = publisher.getString(i);
                    }
                    tvPublisher.setText(TextUtils.join(", ", publishers));
                }
                if (response.has("number_of_pages")) {
                    tvPageCount.setText(Integer.toString(response.getInt("number_of_pages")) + " pages");
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.adkdevelopment.e_contact.ui.presenters.ProfilePresenter.java

/**
 * Gets profile information from Facebook API
 * and calls getPhotos to retrieve photos from this profile
 *//*from w  w  w  .  ja  va  2  s . c o m*/
private void getUser() {
    // user, parse response
    GraphRequest request = GraphRequest.newMeRequest(mAccessToken, new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {
            ProfileRealm profileRealm = new ProfileRealm();
            try {
                profileRealm.setId(object.getString(RESP_ID));
                profileRealm.setName(object.getString(RESP_NAME));
                profileRealm.setLink(object.getString(RESP_LINK));
            } catch (JSONException e) {
                Log.e(TAG, "Error: " + e);
            }

            getPhotos(profileRealm);

        }
    });

    Bundle parameters = new Bundle();
    parameters.putString(PARAM_FIELDS, TextUtils.join(",", new String[] { RESP_ID, RESP_NAME, RESP_LINK }));
    request.setParameters(parameters);

    request.executeAsync();
}

From source file:toll.geofence.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   ww  w.  j av  a  2  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 triggeringGeofencesIdsString + "_" + geofenceTransitionString;
}

From source file:com.example.umyhnystma.matsvisitumea.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 .  ja  va  2s .  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);
    Log.i("TAG", "getGeofenceTransitionDetails har krts");
    // return geofenceTransitionString + ": " + triggeringGeofencesIdsString;
    return geofenceTransitionString + ": " + triggeringGeofencesIdsString;
}

From source file:com.blazeroni.reddit.http.PersistentCookieStore.java

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

    for (ConcurrentHashMap.Entry<String, Cookie> entry : this.cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            this.cookies.remove(name);

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

            // We've cleared at least one
            clearedAny = true;//  w  w  w. j  a  va  2s . c o m
        }
    }

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

    return clearedAny;
}

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

public static void TruncateOldTags(ArrayList<String> accounts, Context context) {

    final ArrayList<String> selectionList = new ArrayList<String>();

    for (String s : accounts) {
        selectionList.add(Tag.Account + " <> '" + s + "'");
    }//from ww w  .  j  a va 2  s  . c  o  m

    final String selection = TextUtils.join(" AND ", selectionList);

    context.getContentResolver().delete(Tag.CONTENT_URI, selection, null);
}

From source file:org.linphone.compatibility.ApiFivePlus.java

public static Cursor getSIPContactsCursor(ContentResolver cr, List<String> ids) {
    String req = null;//from w ww.j  a  v  a  2s.  co m
    req = Contacts.Data.MIMETYPE + " = '" + CommonDataKinds.Im.CONTENT_ITEM_TYPE + "' AND lower("
            + CommonDataKinds.Im.CUSTOM_PROTOCOL + ") = 'sip'";

    if (ids != null) {
        String s = TextUtils.join(",", ids);
        req += " OR (" + Data.CONTACT_ID + " IN (" + s + "))";
    }

    return getGeneralContactCursor(cr, req, true);
}