List of usage examples for android.text TextUtils join
public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens)
From source file:us.parshall.ezandroid.activity.EZItemListActivity.java
protected OnClickListener deleteItemsListener(final EZItemListActivity activity, final String tableName) { return new DialogInterface.OnClickListener() { @Override//from w ww . j ava 2s . com public void onClick(DialogInterface dialog, int which) { long[] selectedItemIds = activity.getListView().getCheckedItemIds(); String[] itemIds = new String[selectedItemIds.length]; String[] parameters = new String[selectedItemIds.length]; for (int i = 0; i < selectedItemIds.length; i++) { itemIds[i] = String.valueOf(selectedItemIds[i]); parameters[i] = "?"; } String where = EZContentProvider.KEY_ID + " in ( " + TextUtils.join(",", parameters) + " )"; ContentResolver cr = activity.getContentResolver(); cr.delete(Uri.withAppendedPath(EZContentProvider.CONTENT_URI, tableName), where, itemIds); cr.notifyChange(Uri.withAppendedPath(EZContentProvider.CONTENT_URI, tableName), null); dialog.dismiss(); activity.finish(); activity.startActivity(activity.getIntent()); } }; }
From source file:com.appsimobile.appsii.module.weather.loader.WeatherDataParser.java
@Nullable private static WeatherData parseWeatherData(String woeid, SimpleDateFormat simpleDateFormat, JSONObject weatherJsonObj) throws ResponseParserException, JSONException, ParseException { SimpleJson weatherJson = new SimpleJson(weatherJsonObj); String city = weatherJson.optString("location.city"); if (city == null) { String country = weatherJson.optString("location.country"); String region = weatherJson.optString("location.region"); if (country != null && region != null) { city = TextUtils.join(", ", new String[] { country, region }); } else if (country != null) { city = country;/*from w w w . ja va2 s. c o m*/ } } if (city == null) { Log.w("WeatherDataParser", "Error in weather-query. Ignoring location"); return null; } WeatherData weatherData = new WeatherData(); weatherData.location = city; weatherData.windChill = weatherJson.getInt("wind.chill", Integer.MIN_VALUE); weatherData.windDirection = weatherJson.getInt("wind.direction", Integer.MIN_VALUE); weatherData.windSpeed = (float) weatherJson.getDouble("wind.speed", Float.MIN_VALUE); weatherData.atmosphereHumidity = weatherJson.getInt("atmosphere.humidity", Integer.MIN_VALUE); weatherData.atmospherePressure = (float) weatherJson.getDouble("atmosphere.pressure", Float.MIN_VALUE); weatherData.atmosphereRising = weatherJson.getInt("atmosphere.rising", Integer.MIN_VALUE); weatherData.atmosphereVisible = (float) weatherJson.getDouble("atmosphere.visibility", Float.MIN_VALUE); weatherData.sunrise = weatherJson.optString("astronomy.sunrise"); weatherData.sunset = weatherJson.optString("astronomy.sunset"); weatherData.nowConditionCode = weatherJson.getInt("item.condition.code", WeatherData.INVALID_CONDITION); weatherData.nowConditionText = weatherJson.optString("item.condition.text"); weatherData.nowTemperature = weatherJson.getInt("item.condition.temp", WeatherData.INVALID_TEMPERATURE); JSONArray forecastArray = weatherJson.optJsonArray("item.forecast"); if (forecastArray != null) { int fl = forecastArray.length(); for (int k = 0; k < fl; k++) { JSONObject forecastJson = forecastArray.getJSONObject(k); WeatherData.Forecast forecast = new WeatherData.Forecast(); String date = forecastJson.optString("date"); long millis = simpleDateFormat.parse(date).getTime(); forecast.julianDay = Time.getJulianDay(millis, 0); forecast.conditionCode = forecastJson.optInt("code", WeatherData.INVALID_CONDITION); forecast.forecastText = forecastJson.optString("text"); forecast.low = forecastJson.optInt("low", WeatherData.INVALID_TEMPERATURE); forecast.high = forecastJson.optInt("high", WeatherData.INVALID_TEMPERATURE); weatherData.forecasts.add(forecast); } } weatherData.woeid = woeid; return weatherData; }
From source file:com.pindroid.platform.NoteManager.java
public static void TruncateOldNotes(ArrayList<String> accounts, Context context) { final ArrayList<String> selectionList = new ArrayList<String>(); for (String s : accounts) { selectionList.add(Note.Account + " <> '" + s + "'"); }/*from www . jav a2 s . c om*/ final String selection = TextUtils.join(" AND ", selectionList); context.getContentResolver().delete(Note.CONTENT_URI, selection, null); }
From source file:cn.caimatou.canting.utils.http.asynchttp.PersistentCookieStore.java
@Override public void addCookie(Cookie cookie) { String name = cookie.getName() + cookie.getDomain(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie);//from w w w . ja v a 2 s . 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.lurencun.cfuture09.androidkit.http.async.PersistentCookieStore.java
@Override public void addCookie(Cookie cookie) { String name = cookie.getName() + cookie.getDomain(); // Save cookie into local store, or remove if expired if (cookie.isExpired(new Date())) { cookies.remove(name);//ww w . ja va2 s . c o m } else { cookies.put(name, cookie); } // 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:com.google.devplat.lmoroney.locationlesson3_1.GeofenceTransitionsIntentService.java
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()); }//from www. ja v a 2 s .c o m String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList); return geofenceTransitionString + ": " + triggeringGeofencesIdsString; }
From source file:com.http_asny.http.PersistentCookieStore.java
@Override public void addCookie(Cookie cookie) { String name = cookie.getName() + cookie.getDomain(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie);/*from w ww . j a va 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.apply(); }
From source file:com.example.androidthings.doorbell.DoorbellEntryAdapter.java
@Override protected void populateViewHolder(DoorbellEntryViewHolder viewHolder, DoorbellEntry model, int position) { // Display the timestamp CharSequence prettyTime = DateUtils.getRelativeDateTimeString(mApplicationContext, model.getTimestamp(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); viewHolder.time.setText(prettyTime); // Display the image if (model.getImage() != null) { // Decode image data encoded by the Cloud Vision library byte[] imageBytes = Base64.decode(model.getImage(), Base64.NO_WRAP | Base64.URL_SAFE); Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); if (bitmap != null) { viewHolder.image.setImageBitmap(bitmap); } else {//from w ww . j a v a 2 s . c o m Drawable placeholder = ContextCompat.getDrawable(mApplicationContext, R.drawable.ic_image); viewHolder.image.setImageDrawable(placeholder); } } // Display the metadata if (model.getAnnotations() != null) { ArrayList<String> keywords = new ArrayList<>(model.getAnnotations().keySet()); int limit = Math.min(keywords.size(), 3); viewHolder.metadata.setText(TextUtils.join("\n", keywords.subList(0, limit))); } else { viewHolder.metadata.setText("no annotations yet"); } }
From source file:in.andres.kandroid.ui.ProjectOverviewFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); KanboardProject project = ((MainActivity) getActivity()).getProject(); if (project != null) { assert getView() != null : "ProjectOverviewFragment: getView() returned null"; TextView projectDescription = (TextView) getView().findViewById(R.id.project_description); TextView projectNBActiveTasks = (TextView) getView().findViewById(R.id.project_active_tasks); TextView projectNBInactiveTasks = (TextView) getView().findViewById(R.id.project_inactive_tasks); TextView projectNBOverdueTasks = (TextView) getView().findViewById(R.id.project_overdue_tasks); TextView projectNBTotalTasks = (TextView) getView().findViewById(R.id.project_total_tasks); TextView projectModifyDate = (TextView) getView().findViewById(R.id.project_modify_date); TextView projectMembers = (TextView) getView().findViewById(R.id.project_members); TextView projectColumns = (TextView) getView().findViewById(R.id.project_columns); TextView projectSwimlanes = (TextView) getView().findViewById(R.id.project_swimlanes); if (!project.getDescription().contentEquals("")) { projectDescription//from w w w. j av a2 s . c o m .setText(Utils.fromHtml(mRenderer.render(mParser.parse(project.getDescription())))); } else { getView().findViewById(R.id.card_description).setVisibility(View.GONE); } projectMembers.setText(Utils.fromHtml(TextUtils.join(" <big><b>|</b></big> ", Collections.list(project.getProjectUsers().elements())))); projectColumns.setText(Utils.fromHtml(TextUtils.join(" <big><b>|</b></big> ", project.getColumns()))); projectSwimlanes .setText(Utils.fromHtml(TextUtils.join(" <big><b>|</b></big> ", project.getSwimlanes()))); projectNBActiveTasks .setText(getContext().getResources().getQuantityString(R.plurals.format_nb_active_tasks, project.getActiveTasks().size(), project.getActiveTasks().size())); projectNBInactiveTasks .setText(getContext().getResources().getQuantityString(R.plurals.format_nb_inactive_tasks, project.getInactiveTasks().size(), project.getInactiveTasks().size())); projectNBOverdueTasks .setText(getContext().getResources().getQuantityString(R.plurals.format_nb_overdue_tasks, project.getOverdueTasks().size(), project.getOverdueTasks().size())); projectNBTotalTasks .setText(getContext().getResources().getQuantityString(R.plurals.format_nb_total_tasks, project.getActiveTasks().size() + project.getInactiveTasks().size(), project.getActiveTasks().size() + project.getInactiveTasks().size())); projectModifyDate.setText(DateFormat.getLongDateFormat(getContext()).format(project.getLastModified()) + " " + DateFormat.getTimeFormat(getContext()).format(project.getLastModified())); } }
From source file:org.totschnig.myexpenses.dialog.SelectMainCategoryDialogFragment.java
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { if (getActivity() == null) { return null; }//from ww w. ja v a 2 s .c o m String selection = KEY_PARENTID + " is null AND " + KEY_ROWID + " NOT IN (" + TextUtils.join(",", ArrayUtils.toObject(getArguments().getLongArray(KEY_EXCLUDED_ID))) + ")"; CursorLoader cursorLoader = new CursorLoader(getActivity(), TransactionProvider.CATEGORIES_URI, projection, selection, null, null); return cursorLoader; }