List of usage examples for android.text TextUtils join
public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens)
From source file:com.microsoft.live.ApiRequest.java
/** * Constructs a new instance of a Header that contains the * @param accessToken to construct inside the Authorization header * @return a new instance of a Header that contains the Authorization access_token *//*from ww w .j a v a 2 s . c om*/ private static Header createAuthroizationHeader(LiveConnectSession session) { assert session != null; String accessToken = session.getAccessToken(); assert !TextUtils.isEmpty(accessToken); String tokenType = OAuth.TokenType.BEARER.toString().toLowerCase(Locale.US); String value = TextUtils.join(" ", new String[] { tokenType, accessToken }); return new BasicHeader(AUTH.WWW_AUTH_RESP, value); }
From source file:com.appsimobile.appsihomeplugins.dashclock.phone.SmsExtension.java
@Override public void onUpdateData(FieldValues.Builder builder) { long lastUnreadThreadId = 0; Set<Long> unreadThreadIds = new HashSet<Long>(); Set<String> unreadThreadParticipantNames = new HashSet<String>(); boolean showingAllConversationParticipants = false; Cursor cursor = tryOpenSimpleThreadsCursor(); if (cursor != null) { while (cursor.moveToNext()) { if (cursor.getInt(SimpleThreadsQuery.READ) == 0) { long threadId = cursor.getLong(SimpleThreadsQuery._ID); unreadThreadIds.add(threadId); lastUnreadThreadId = threadId; // Some devices will fail on tryOpenMmsSmsCursor below, so // store a list of participants on unread threads as a fallback. String recipientIdsStr = cursor.getString(SimpleThreadsQuery.RECIPIENT_IDS); if (!TextUtils.isEmpty(recipientIdsStr)) { String[] recipientIds = TextUtils.split(recipientIdsStr, " "); for (String recipientId : recipientIds) { Cursor canonAddrCursor = tryOpenCanonicalAddressCursorById(Long.parseLong(recipientId)); if (canonAddrCursor == null) { continue; }//from w w w . j a v a 2 s . c o m if (canonAddrCursor.moveToFirst()) { String address = canonAddrCursor.getString(CanonicalAddressQuery.ADDRESS); String displayName = getDisplayNameForContact(0, address); if (!TextUtils.isEmpty(displayName)) { unreadThreadParticipantNames.add(displayName); } } canonAddrCursor.close(); } } } } cursor.close(); LOGD(TAG, "Unread thread IDs: [" + TextUtils.join(", ", unreadThreadIds) + "]"); } int unreadConversations = 0; StringBuilder names = new StringBuilder(); cursor = tryOpenMmsSmsCursor(); if (cursor != null) { // Most devices will hit this code path. while (cursor.moveToNext()) { // Get display name. SMS's are easy; MMS's not so much. long id = cursor.getLong(MmsSmsQuery._ID); long contactId = cursor.getLong(MmsSmsQuery.PERSON); String address = cursor.getString(MmsSmsQuery.ADDRESS); long threadId = cursor.getLong(MmsSmsQuery.THREAD_ID); if (unreadThreadIds != null && !unreadThreadIds.contains(threadId)) { // We have the list of all thread IDs (same as what the messaging app uses), and // this supposedly unread message's thread isn't in the list. This message is // likely an orphaned message whose thread was deleted. Not skipping it is // likely the cause of http://code.google.com/p/dashclock/issues/detail?id=8 LOGD(TAG, "Skipping probably orphaned message " + id + " with thread ID " + threadId); continue; } ++unreadConversations; lastUnreadThreadId = threadId; if (contactId == 0 && TextUtils.isEmpty(address) && id != 0) { // Try MMS addr query Cursor addrCursor = tryOpenMmsAddrCursor(id); if (addrCursor != null) { if (addrCursor.moveToFirst()) { contactId = addrCursor.getLong(MmsAddrQuery.CONTACT_ID); address = addrCursor.getString(MmsAddrQuery.ADDRESS); } addrCursor.close(); } } String displayName = getDisplayNameForContact(contactId, address); if (names.length() > 0) { names.append(", "); } names.append(displayName); } cursor.close(); } else { // In case the cursor is null (some Samsung devices like the Galaxy S4), use the // fall back on the list of participants in unread threads. unreadConversations = unreadThreadIds.size(); names.append(TextUtils.join(", ", unreadThreadParticipantNames)); showingAllConversationParticipants = true; } Intent clickIntent; if (unreadConversations == 1 && lastUnreadThreadId > 0) { clickIntent = new Intent(Intent.ACTION_VIEW, TelephonyProviderConstants.MmsSms.CONTENT_CONVERSATIONS_URI .buildUpon().appendPath(Long.toString(lastUnreadThreadId)).build()); } else { clickIntent = IntentCompat.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_MESSAGING); } PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), DashClockHomeExtension.DASHCLOCK_EXTENSION_SMS, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.leftImageResId(R.drawable.ic_extension_sms).intent(pendingIntent).header(getResources() .getQuantityString(R.plurals.sms_title_template, unreadConversations, unreadConversations)); if (unreadConversations > 0) { builder.text(getString(showingAllConversationParticipants ? R.string.sms_body_all_participants_template : R.string.sms_body_template, names.toString())); } /* publishUpdate(new ExtensionData() .visible(unreadConversations > 0) .icon(R.drawable.ic_extension_sms) .status(Integer.toString(unreadConversations)) .expandedTitle( getResources().getQuantityString( R.plurals.sms_title_template, unreadConversations, unreadConversations)) .expandedBody(getString(showingAllConversationParticipants ? R.string.sms_body_all_participants_template : R.string.sms_body_template, names.toString())) .clickIntent(clickIntent)); */ }
From source file:org.linphone.compatibility.ApiFivePlus.java
public static Cursor getContactsCursor(ContentResolver cr, List<String> ids) { String req = Data.MIMETYPE + " = '" + CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND " + CommonDataKinds.Phone.NUMBER + " IS NOT NULL"; req += " OR (" + 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 + "))"; }/*from www .j a v a2s. c o m*/ return getGeneralContactCursor(cr, req, true); }
From source file:com.lurencun.cfuture09.androidkit.http.async.PersistentCookieStore.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.isExpired(date)) { // Clear cookies from local store cookies.remove(name);/*from ww w .j a v a2 s.c o 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:cn.caimatou.canting.utils.http.asynchttp.PersistentCookieStore.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)) { // Clear cookies from local store cookies.remove(name);/*from ww w . j a va2s. c o 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:nz.ac.otago.psyanlab.common.ImportPaleActivity.java
@Override public void onFilesPicked(File... files) { new AsyncTask<File, Void, Pair<ArrayList<String>, ArrayList<Long>>>() { @Override//from w w w.java 2s .com protected Pair<ArrayList<String>, ArrayList<Long>> doInBackground(File... files) { ArrayList<Long> ids = new ArrayList<Long>(); ArrayList<String> errored = new ArrayList<String>(); for (int i = 0; i < files.length; i++) { Uri uri; try { uri = mUserDelegate.addExperiment(files[i].getPath()); } catch (JSONException e) { errored.add(files[i].getName()); e.printStackTrace(); continue; } catch (IOException e) { errored.add(files[i].getName()); e.printStackTrace(); continue; } ids.add(Long.parseLong(uri.getLastPathSegment())); } return new Pair<ArrayList<String>, ArrayList<Long>>(errored, ids); } @Override protected void onPostExecute(Pair<ArrayList<String>, ArrayList<Long>> result) { ArrayList<String> errored = result.first; ArrayList<Long> ids = result.second; if (errored.size() > 0) { toast(getResources().getString(R.string.format_error_importing, TextUtils.join(", ", errored))); } if (ids.size() > 0) { Intent r = new Intent(); long[] lids = new long[ids.size()]; for (int i = 0; i < ids.size(); i++) { lids[i] = ids.get(i); } r.putExtra(RETURN_IDS, lids); setResult(RESULT_OK, r); finish(); } }; }.execute(files); }
From source file:com.http_asny.http.PersistentCookieStore.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)) { // Clear cookies from local store cookies.remove(name);// ww w.ja v a2 s. c o 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.apply(); return clearedAny; }
From source file:com.example.ali.rottentomatoesmaterialsample.BoxOfficeMovie.java
public String getCastList() { return TextUtils.join(", ", castList); }
From source file:com.heyzap.http.SDKCookieStore.java
public String getCookieString() { ArrayList<String> cookieStrings = new ArrayList<String>(); for (Cookie cookie : cookies.values()) { cookieStrings.add(getCookieString(cookie)); }/*from www . j a v a2s . c o m*/ return TextUtils.join("; ", cookieStrings); }
From source file: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. *//* w w w .j ava 2 s . co 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<String> triggeringGeofencesIdsList = new ArrayList<>(); for (Geofence geofence : triggeringGeofences) { triggeringGeofencesIdsList.add(geofence.getRequestId()); } String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList); return geofenceTransitionString + ": " + triggeringGeofencesIdsString; }