List of usage examples for android.text TextUtils join
public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens)
From source file:de.fmaul.android.cmis.utils.FeedUtils.java
public static String getSearchQueryFeedFullText(String urlTemplate, String query) { String[] words = TextUtils.split(query.trim(), "\\s+"); for (int i = 0; i < words.length; i++) { words[i] = "contains ('" + words[i] + "')"; }//from w w w.j a v a2 s .c o m String condition = TextUtils.join(" AND ", words); return getSearchQueryFeedCmisQuery(urlTemplate, "SELECT * FROM cmis:document WHERE " + condition); }
From source file:com.bcp.bcp.geofencing.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 www .ja v a 2s .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); Date curDate = new Date(); SimpleDateFormat format = new SimpleDateFormat(Constants.TIME_FORMAT); gEntryDate = format.format(curDate); boolean isInserted; gaddress = triggeringGeofencesIdsList.toString(); gstatus = geofenceTransitionString; String geoFenceDetailString = geofenceTransitionString + ": " + triggeringGeofencesIdsString; Pattern gmailPattern = Patterns.EMAIL_ADDRESS; Account[] accounts = AccountManager.get(this).getAccounts(); for (Account account : accounts) { if (gmailPattern.matcher(account.name).matches()) { gemail = account.name; } } //insert into new fence breach fusion table for each entry exit //no conditions //When switch is ON and we are breaching a fence (entering) we will write that data to FT When switch is ON and we are breaching fence(exiting) we will write that data to FT as well. //status:exit if (geofenceTransitionString.equalsIgnoreCase("Exited")) { if (mPref.getBoolean("SWITCH", false)) { //Switch : ON //if switch is ON String timeValue = mPref.getString("Time_Interval", "60000"); long configurableTime = Long.parseLong(timeValue); mEditor.putLong("CONFIG TIME", configurableTime); mEditor.commit(); Intent intent = new Intent(this, MyLocationService.class); startService(intent); if (!mPref.getBoolean(geoFenceDetailString, false)) { credentials.insertIntoGeoFusionTables( this.saveGeoFile(gaddress, gstatus, gEntryDate, gemail, "geofile")); } } else { } } else if (geofenceTransitionString.equalsIgnoreCase("Entered")) {//status :Entry if (mPref.getBoolean("SWITCH", false)) { if (!mPref.getBoolean(geoFenceDetailString, false)) { credentials.insertIntoGeoFusionTables( this.saveGeoFile(gaddress, gstatus, gEntryDate, gemail, "geofile")); } } else {//Switch : OFF } } if (!mPref.getBoolean(geoFenceDetailString, false)) { isInserted = databaseHandler.addFenceTiming( new FenceTiming(triggeringGeofencesIdsList.toString(), geofenceTransitionString, gEntryDate)); if (isInserted) { Log.e("GeofenceonsIS : ", "inserted to db"); } } return geoFenceDetailString; }
From source file:paulscode.android.mupen64plusae.preference.MultiSelectListPreference.java
/** * Serialize the selected values array to a string. * //from w w w . j a v a2 s . co m * @param selectedValues The array of selected values. * @param delimiter The delimiter used between array elements in the serialization. * * @return The serialized value of the array. */ public static String serialize(List<String> selectedValues, String delimiter) { return selectedValues == null ? "" : TextUtils.join(delimiter, selectedValues); }
From source file:com.eTilbudsavis.etasdk.network.impl.JsonArrayRequest.java
/** * Set a parameter for what specific id's to get from a given endpoint.<br><br> * //www .j a v a 2 s. co m * E.g.: setIds(Catalog.PARAM_IDS, new String[]{"eecdA5g","b4Aea5h"}); * @param type of the endpoint parameter e.g. Catalog.PARAM_IDS * @param ids to filter by * @return this object */ public Request<?> setIds(String type, Set<String> ids) { String idList = TextUtils.join(",", ids); getParameters().put(type, idList); return this; }
From source file:de.azapps.mirakel.dashclock.MirakelExtension.java
@Override protected void onUpdateData(final int reason) { // Get values from Settings final Optional<ListMirakel> listMirakelOptional = SettingsHelper.getList(); if (!listMirakelOptional.isPresent()) { reportError(this, getString(R.string.list_not_found), getString(R.string.list_not_found_message)); return;//ww w. j a v a 2 s.com } final int maxTasks = SettingsHelper.getMaxTasks(); final ListMirakel listMirakel = listMirakelOptional.get(); final MirakelQueryBuilder mirakelQueryBuilder = listMirakel.getTasksQueryBuilder(); final Cursor cursor; try { cursor = mirakelQueryBuilder.query(Task.URI); } catch (final SecurityException ignored) { reportError(this, getString(R.string.no_permission_title), getString(R.string.no_permission)); return; } catch (final RuntimeException e) { reportError(this, getString(R.string.cannot_communicate), getString(R.string.unexpected_error)); Log.e(TAG, "Cannot communicate to Mirakel", e); return; } // Set Status if (cursor.getCount() == 0 && !SettingsHelper.showEmpty()) { Log.d(TAG, "hide"); publishUpdate(new ExtensionData().visible(false)); } else { final boolean showDue = SettingsHelper.showDue(); final SimpleDateFormat dateFormat = new SimpleDateFormat(getString(R.string.due_outformat), Locale.getDefault()); final String status = getResources().getQuantityString(R.plurals.status, cursor.getCount(), cursor.getCount()); final String tasks[] = new String[Math.min(maxTasks, cursor.getCount())]; int i = 0; while (cursor.moveToNext() && i < maxTasks) { final Task task = MirakelQueryBuilder.cursorToObject(cursor, Task.class); final Optional<Calendar> dueOptional = task.getDue(); final StringBuilder taskRow = new StringBuilder(); if (dueOptional.isPresent() && showDue) { taskRow.append(dateFormat.format(dueOptional.get().getTime())).append(": "); } taskRow.append(task.getName()); tasks[i] = taskRow.toString(); i++; } cursor.close(); // Add click-event final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent( new ComponentName("de.azapps.mirakelandroid", "de.azapps.mirakel.main_activity.MainActivity")); intent.setAction("de.azapps.mirakel.SHOW_LIST"); intent.putExtra("de.azapps.mirakel.EXTRA_LIST_ID", listMirakel.getId()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Set Content publishUpdate(new ExtensionData().visible(true).icon(R.drawable.ic_mirakel).status(status) .expandedBody(TextUtils.join("\n", tasks)).clickIntent(intent)); } }
From source file:edu.mit.mobile.android.locast.data.JsonSyncableItem.java
/** * Turns a collection of strings into a delimited string * * @param list a list of strings//from w w w . ja v a 2 s. co m * @return a string representing the list, delimited by LIST_DELIM with any existing instances escaped. * @see #getList(String) */ public static String toListString(Collection<String> list) { final List<String> tempList = new Vector<String>(list.size()); for (String s : list) { // escape all of the delimiters in the individual strings s = s.replace(LIST_DELIM, "\\" + LIST_DELIM); tempList.add(s); } return TextUtils.join(LIST_DELIM, tempList); }
From source file:com.negaheno.ui.Components.EmojiView.java
private void saveRecents() { ArrayList<Long> localArrayList = new ArrayList<Long>(); long[] arrayOfLong = Emoji.data[0]; int i = arrayOfLong.length; for (int j = 0;; j++) { if (j >= i) { getContext().getSharedPreferences("emoji", 0).edit() .putString("recents", TextUtils.join(",", localArrayList)).commit(); return; }// w ww . j a v a 2 s. c o m localArrayList.add(arrayOfLong[j]); } }
From source file:com.easy.facebook.android.facebook.FBLoginManager.java
private void startDialogAuth(Activity activityDialog, String[] permissions) throws EasyFacebookError { Bundle params = new Bundle(); if (permissions.length > 0) { params.putString("scope", TextUtils.join(",", permissions)); }/*from w w w .j a va 2 s . co m*/ CookieSyncManager.createInstance(activityDialog); dialog(activityDialog, "oauth", params, new LoginListener() { public void loginSuccess(Facebook facebook) { CookieSyncManager.getInstance().sync(); ((LoginListener) activity).loginSuccess(facebook); } public void logoutSuccess() { ((LoginListener) activity).logoutSuccess(); } public void loginFail() { ((LoginListener) activity).loginFail(); } }); }
From source file:com.example.scandevice.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 a v a2 s . c o m*/ private String getGeofenceTransitionDetails(Context context, int geofenceTransition, List<Geofence> triggeringGeofences) { String geofenceTransitionString = getTransitionString(geofenceTransition); GPS_dbManager = new DBHelper(getApplicationContext(), "GPSList.db", null, 3); GPS_dbManager.insert( "insert into SCAN_LIST ('_id', 'identifier', 'enter', 'lat', 'lon', 'lat', 'timestamp') values(null,'" + geofence.getRequestId() + "', '" + geofenceTransitionString + "', '" + lat + "', '" + lon + "', '" + alt + "', '" + timestamp + "');"); // 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.yahala.ui.Views.StickersView.java
private void saveRecents() { ArrayList<String> localArrayList = new ArrayList<String>(); StickersGroup recent = EmojiManager.getInstance().stickersCategories.get(0); if (recent.stickers.size() <= 0) { return;/*from w w w . j a va 2s . c o m*/ } int i = recent.stickers.size(); // FileLog.e("recents emoji",""+ getContext().getSharedPreferences("emoji", 0).getString("recents", "")); for (int j = 0;; j++) { try { if (j >= i) { getContext().getSharedPreferences("sticker", 0).edit() .putString("recents", TextUtils.join(",", localArrayList)).commit(); return; } Sticker sticker = recent.stickers.get(j); localArrayList.add(Pattern.compile(':' + sticker.name + ':').toString()); /*if (emoji.moji != null) localArrayList.add(Pattern.compile(emoji.moji,Pattern.LITERAL).toString()); if (emoji.emoticon != null) localArrayList.add(Pattern.compile(emoji.emoticon,Pattern.LITERAL).toString()); if (emoji.category != null) localArrayList.add(emoji.category);*/ } catch (Exception e) { e.printStackTrace(); } } }