List of usage examples for android.text TextUtils join
public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens)
From source file:com.google.android.car.kitchensink.sensor.SensorsTestFragment.java
private String getGpsSatelliteString(CarSensorEvent event) { String inUse = mNaString;/*from www .j av a2 s . c om*/ String inView = mNaString; String perSattelite = ""; if (event != null) { CarSensorEvent.GpsSatelliteData gpsData = event.getGpsSatelliteData(true); inUse = gpsData.numberInUse != -1 ? String.valueOf(gpsData.numberInUse) : inUse; inView = gpsData.numberInView != -1 ? String.valueOf(gpsData.numberInView) : inView; List<String> perSatteliteList = new ArrayList<>(); int num = gpsData.usedInFix.length; for (int i = 0; i < num; i++) { perSatteliteList.add( getContext().getString(R.string.sensor_single_gps_satellite, i + 1, gpsData.usedInFix[i], gpsData.prn[i], gpsData.snr[i], gpsData.azimuth[i], gpsData.elevation[i])); } perSattelite = TextUtils.join(", ", perSatteliteList); } return getContext().getString(R.string.sensor_gps, getTimestamp(event), inView, inUse, perSattelite); }
From source file:org.thoughtcrime.securesms.logsubmit.SubmitLogFragment.java
private static String buildDescription(Context context) { final PackageManager pm = context.getPackageManager(); final StringBuilder builder = new StringBuilder(); builder.append("Time : ").append(System.currentTimeMillis()).append('\n'); builder.append("Device : ").append(Build.MANUFACTURER).append(" ").append(Build.MODEL).append(" (") .append(Build.PRODUCT).append(")\n"); builder.append("Android : ").append(VERSION.RELEASE).append(" (").append(VERSION.INCREMENTAL).append(", ") .append(Build.DISPLAY).append(")\n"); builder.append("ABIs : ").append(TextUtils.join(", ", getSupportedAbis())).append("\n"); builder.append("Memory : ").append(getMemoryUsage(context)).append("\n"); builder.append("Memclass: ").append(getMemoryClass(context)).append("\n"); builder.append("OS Host : ").append(Build.HOST).append("\n"); builder.append("App : "); try {/*from w w w . ja v a2 s . c o m*/ builder.append(pm.getApplicationLabel(pm.getApplicationInfo(context.getPackageName(), 0))).append(" ") .append(pm.getPackageInfo(context.getPackageName(), 0).versionName).append("\n"); } catch (PackageManager.NameNotFoundException nnfe) { builder.append("Unknown\n"); } return builder.toString(); }
From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java
@Background void importCardsFrom(String jsonPath) { activityHelper.showProgressDialog(R.string.message_in_processing); String json;//from w w w.j ava 2 s .c o m try { FileInputStream inputStream = new FileInputStream(jsonPath); json = TextUtils.join("", IOUtils.readLines(inputStream)); } catch (FileNotFoundException e) { activityHelper.showError(e); activityHelper.hideProgressDialog(); return; } catch (IOException e) { activityHelper.showError(e); activityHelper.hideProgressDialog(); return; } JsonArray cards; try { JsonElement jsonElement = new JsonParser().parse(json); JsonObject object = jsonElement.getAsJsonObject(); cards = object.getAsJsonArray(JSON_KEY_CARDS); } catch (JsonIOException e) { activityHelper.showError(e); activityHelper.hideProgressDialog(); return; } for (JsonElement element : cards) { JsonObject cardData = element.getAsJsonObject(); Card card = new Card(cardData); try { databaseHelper.createCard(card); } catch (SQLException e) { activityHelper.showError(e); activityHelper.hideProgressDialog(); return; } } activityHelper.hideProgressDialog(); activityHelper.showToast(R.string.message_success); loadContents(); }
From source file:org.telegramsecureplus.ui.Components.EmojiView.java
private void saveRecents() { ArrayList<Long> arrayList = new ArrayList<>(Emoji.data[0].length); for (int j = 0; j < Emoji.data[0].length; j++) { arrayList.add(Emoji.data[0][j]); }//from w ww . jav a 2 s .com getContext().getSharedPreferences("emoji", 0).edit().putString("recents", TextUtils.join(",", arrayList)) .commit(); }
From source file:net.potterpcs.recipebook.RecipeData.java
public Cursor query(String search, String tag, int min, int max, String sortBy) { // this is the "multi-query" method, that searches by name, tag, and time // Log.i(TAG, "multi-query: search = " + search + ", tag = " + tag + ", time = " + min + " to " + max + ", sort by = " + sortBy); String like = createLikePattern(); String time = createTimeComparisonPattern(); String searchPart = "(" + like + ")"; String timePart = "(" + time + ")"; String tagPart = "(" + TT_TAG + " = ?)"; // We have to match like this because of Android bug 3153 String match = "%" + search + "%"; ArrayList<String> parts = new ArrayList<String>(); ArrayList<String> args = new ArrayList<String>(); if (search != null) { parts.add(searchPart);/*from ww w . j ava 2 s. co m*/ args.add(match); args.add(match); } if (!(min == 0 && max == 0)) { parts.add(timePart); args.add(Integer.toString(max)); args.add(Integer.toString(min)); } if (tag != null) { parts.add(tagPart); args.add(tag); } String selection = TextUtils.join(" and ", parts); String[] selectionArgs = (String[]) args.toArray(new String[args.size()]); // Log.i(TAG, selection + ", " + selectionArgs + ", " + sortBy); return queryBuilder(selection, selectionArgs, sortBy); }
From source file:at.bitfire.davdroid.syncadapter.SyncManager.java
/** * Compares {@link #localResources} and {@link #remoteResources} by file name and ETag: * <ul>/*from w w w. jav a 2 s .c om*/ * <li>Local resources which are not available in the remote collection (anymore) will be removed.</li> * <li>Resources whose remote ETag has changed will be added into {@link #toDownload}</li> * </ul> */ protected void compareLocalRemote() throws IOException, HttpException, DavException, CalendarStorageException, ContactsStorageException { /* check which contacts 1. are not present anymore remotely -> delete immediately on local side 2. updated remotely -> add to downloadNames 3. added remotely -> add to downloadNames */ toDownload = new HashSet<>(); for (String localName : localResources.keySet()) { DavResource remote = remoteResources.get(localName); if (remote == null) { App.log.info(localName + " is not on server anymore, deleting"); localResources.get(localName).delete(); syncResult.stats.numDeletes++; } else { // contact is still on server, check whether it has been updated remotely GetETag getETag = (GetETag) remote.properties.get(GetETag.NAME); if (getETag == null || getETag.eTag == null) throw new DavException("Server didn't provide ETag"); String localETag = localResources.get(localName).getETag(), remoteETag = getETag.eTag; if (remoteETag.equals(localETag)) syncResult.stats.numSkippedEntries++; else { App.log.info(localName + " has been changed on server (current ETag=" + remoteETag + ", last known ETag=" + localETag + ")"); toDownload.add(remote); } // remote entry has been seen, remove from list remoteResources.remove(localName); } } // add all unseen (= remotely added) remote contacts if (!remoteResources.isEmpty()) { App.log.info("New resources have been found on the server: " + TextUtils.join(", ", remoteResources.keySet())); toDownload.addAll(remoteResources.values()); } }
From source file:com.afrozaar.jazzfestreporting.MainActivity.java
private void loadUploadedVideos() { if (mChosenAccountName == null) { return;//from w w w. ja v a 2 s .c om } setProgressBarIndeterminateVisibility(true); new AsyncTask<Void, Void, List<VideoData>>() { @Override protected List<VideoData> doInBackground(Void... voids) { YouTube youtube = new YouTube.Builder(transport, jsonFactory, credential) .setApplicationName(Constants.APP_NAME).build(); try { /* * Now that the user is authenticated, the app makes a * channels list request to get the authenticated user's * channel. Returned with that data is the playlist id for * the uploaded videos. * https://developers.google.com/youtube * /v3/docs/channels/list */ ChannelListResponse clr = youtube.channels().list("contentDetails").setMine(true).execute(); // Get the user's uploads playlist's id from channel list // response String uploadsPlaylistId = clr.getItems().get(0).getContentDetails().getRelatedPlaylists() .getUploads(); List<VideoData> videos = new ArrayList<VideoData>(); // Get videos from user's upload playlist with a playlist // items list request PlaylistItemListResponse pilr = youtube.playlistItems().list("id,contentDetails") .setPlaylistId(uploadsPlaylistId).setMaxResults(20l).execute(); List<String> videoIds = new ArrayList<String>(); // Iterate over playlist item list response to get uploaded // videos' ids. for (PlaylistItem item : pilr.getItems()) { videoIds.add(item.getContentDetails().getVideoId()); } // Get details of uploaded videos with a videos list // request. VideoListResponse vlr = youtube.videos().list("id,snippet,status") .setId(TextUtils.join(",", videoIds)).execute(); // Add only the public videos to the local videos list. for (Video video : vlr.getItems()) { if ("public".equals(video.getStatus().getPrivacyStatus())) { VideoData videoData = new VideoData(); videoData.setVideo(video); videos.add(videoData); } } // Sort videos by title Collections.sort(videos, new Comparator<VideoData>() { @Override public int compare(VideoData videoData, VideoData videoData2) { return videoData.getTitle().compareTo(videoData2.getTitle()); } }); return videos; } catch (final GooglePlayServicesAvailabilityIOException availabilityException) { showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode()); } catch (UserRecoverableAuthIOException userRecoverableException) { startActivityForResult(userRecoverableException.getIntent(), REQUEST_AUTHORIZATION); } catch (IOException e) { Utils.logAndShow(MainActivity.this, Constants.APP_NAME, e); } return null; } @Override protected void onPostExecute(List<VideoData> videos) { setProgressBarIndeterminateVisibility(false); if (videos == null) { return; } mUploadsListFragment.setVideos(videos); } }.execute((Void) null); }
From source file:com.facebook.TestSession.java
private String getPermissionsString() { return TextUtils.join(",", requestedPermissions); }
From source file:com.chen.mail.browse.SendersView.java
private static void generateSenderFragments(ConversationItemViewModel header, String[] names, final CharacterStyle readStyleSpan) { header.sendersText = TextUtils.join(Address.ADDRESS_DELIMETER + " ", names); header.addSenderFragment(0, header.sendersText.length(), getWrappedStyleSpan(readStyleSpan), true); }
From source file:com.df.push.DemoActivity.java
private void saveSubscriptionList() { final SharedPreferences prefs = getGcmPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PROPERTY_SUB, TextUtils.join(",", subscriptions)); editor.commit();/*from w w w . java2 s .c o m*/ }