List of usage examples for android.text TextUtils join
public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens)
From source file:com.trk.aboutme.facebook.Request.java
private void serializeToBatch(JSONArray batch, Bundle attachments) throws JSONException, IOException { JSONObject batchEntry = new JSONObject(); if (this.batchEntryName != null) { batchEntry.put(BATCH_ENTRY_NAME_PARAM, this.batchEntryName); batchEntry.put(BATCH_ENTRY_OMIT_RESPONSE_ON_SUCCESS_PARAM, this.batchEntryOmitResultOnSuccess); }// w ww . j a va 2 s . c o m if (this.batchEntryDependsOn != null) { batchEntry.put(BATCH_ENTRY_DEPENDS_ON_PARAM, this.batchEntryDependsOn); } String relativeURL = getUrlForBatchedRequest(); batchEntry.put(BATCH_RELATIVE_URL_PARAM, relativeURL); batchEntry.put(BATCH_METHOD_PARAM, httpMethod); if (this.session != null) { String accessToken = this.session.getAccessToken(); Logger.registerAccessToken(accessToken); } // Find all of our attachments. Remember their names and put them in the attachment map. ArrayList<String> attachmentNames = new ArrayList<String>(); Set<String> keys = this.parameters.keySet(); for (String key : keys) { Object value = this.parameters.get(key); if (isSupportedAttachmentType(value)) { // Make the name unique across this entire batch. String name = String.format("%s%d", ATTACHMENT_FILENAME_PREFIX, attachments.size()); attachmentNames.add(name); Utility.putObjectInBundle(attachments, name, value); } } if (!attachmentNames.isEmpty()) { String attachmentNamesString = TextUtils.join(",", attachmentNames); batchEntry.put(ATTACHED_FILES_PARAM, attachmentNamesString); } if (this.graphObject != null) { // Serialize the graph object into the "body" parameter. final ArrayList<String> keysAndValues = new ArrayList<String>(); processGraphObject(this.graphObject, relativeURL, new KeyValueSerializer() { @Override public void writeString(String key, String value) throws IOException { keysAndValues.add(String.format("%s=%s", key, URLEncoder.encode(value, "UTF-8"))); } }); String bodyValue = TextUtils.join("&", keysAndValues); batchEntry.put(BATCH_BODY_PARAM, bodyValue); } batch.put(batchEntry); }
From source file:com.ichi2.anki.NoteEditor.java
private String tagsAsString(List<String> tags) { return TextUtils.join(" ", tags); }
From source file:dentex.youtube.downloader.ShareActivity.java
private String[] initialSigTransformation(String sig, int a, int b, int c, int d) { String[] sigA = sig.substring(a, b).split(""); sigA = reverseArray(sigA);/*from w ww . j a v a 2 s.c om*/ String sigAs = TextUtils.join("", sigA); String[] sigB = sig.substring(c, d).split(""); sigB = reverseArray(sigB); String sigBs = TextUtils.join("", sigB); return new String[] { sigAs, sigBs }; }
From source file:com.facebook.GraphRequest.java
private void serializeToBatch(JSONArray batch, Map<String, Attachment> attachments) throws JSONException, IOException { JSONObject batchEntry = new JSONObject(); if (this.batchEntryName != null) { batchEntry.put(BATCH_ENTRY_NAME_PARAM, this.batchEntryName); batchEntry.put(BATCH_ENTRY_OMIT_RESPONSE_ON_SUCCESS_PARAM, this.batchEntryOmitResultOnSuccess); }/* w ww . j a va2 s . c o m*/ if (this.batchEntryDependsOn != null) { batchEntry.put(BATCH_ENTRY_DEPENDS_ON_PARAM, this.batchEntryDependsOn); } String relativeURL = getUrlForBatchedRequest(); batchEntry.put(BATCH_RELATIVE_URL_PARAM, relativeURL); batchEntry.put(BATCH_METHOD_PARAM, httpMethod); if (this.accessToken != null) { String token = this.accessToken.getToken(); Logger.registerAccessToken(token); } // Find all of our attachments. Remember their names and put them in the attachment map. ArrayList<String> attachmentNames = new ArrayList<String>(); Set<String> keys = this.parameters.keySet(); for (String key : keys) { Object value = this.parameters.get(key); if (isSupportedAttachmentType(value)) { // Make the name unique across this entire batch. String name = String.format(Locale.ROOT, "%s%d", ATTACHMENT_FILENAME_PREFIX, attachments.size()); attachmentNames.add(name); attachments.put(name, new Attachment(this, value)); } } if (!attachmentNames.isEmpty()) { String attachmentNamesString = TextUtils.join(",", attachmentNames); batchEntry.put(ATTACHED_FILES_PARAM, attachmentNamesString); } if (this.graphObject != null) { // Serialize the graph object into the "body" parameter. final ArrayList<String> keysAndValues = new ArrayList<String>(); processGraphObject(this.graphObject, relativeURL, new KeyValueSerializer() { @Override public void writeString(String key, String value) throws IOException { keysAndValues.add(String.format(Locale.US, "%s=%s", key, URLEncoder.encode(value, "UTF-8"))); } }); String bodyValue = TextUtils.join("&", keysAndValues); batchEntry.put(BATCH_BODY_PARAM, bodyValue); } batch.put(batchEntry); }
From source file:com.zhengde163.netguard.ServiceSinkhole.java
private List<Rule> getAllowedRules(List<Rule> listRule) { List<Rule> listAllowed = new ArrayList<>(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Check state wifi = Util.isWifiActive(this); boolean metered = Util.isMeteredNetwork(this); boolean useMetered = prefs.getBoolean("use_metered", false); Set<String> ssidHomes = prefs.getStringSet("wifi_homes", new HashSet<String>()); String ssidNetwork = Util.getWifiSSID(this); String generation = Util.getNetworkGeneration(this); boolean unmetered_2g = prefs.getBoolean("unmetered_2g", false); boolean unmetered_3g = prefs.getBoolean("unmetered_3g", false); boolean unmetered_4g = prefs.getBoolean("unmetered_4g", false); boolean roaming = Util.isRoaming(ServiceSinkhole.this); boolean national = prefs.getBoolean("national_roaming", false); boolean tethering = prefs.getBoolean("tethering", false); boolean filter = prefs.getBoolean("filter", false); // Update connected state last_connected = Util.isConnected(ServiceSinkhole.this); boolean org_metered = metered; boolean org_roaming = roaming; // Update metered state if (wifi && !useMetered) metered = false;//from w w w .jav a 2 s .com if (wifi && ssidHomes.size() > 0 && !(ssidHomes.contains(ssidNetwork) || ssidHomes.contains('"' + ssidNetwork + '"'))) { metered = true; Log.i(TAG, "!@home"); } if (unmetered_2g && "2G".equals(generation)) metered = false; if (unmetered_3g && "3G".equals(generation)) metered = false; if (unmetered_4g && "4G".equals(generation)) metered = false; last_metered = metered; // Update roaming state if (roaming && national) roaming = Util.isInternational(this); Log.i(TAG, "Get allowed" + " connected=" + last_connected + " wifi=" + wifi + " home=" + TextUtils.join(",", ssidHomes) + " network=" + ssidNetwork + " metered=" + metered + "/" + org_metered + " generation=" + generation + " roaming=" + roaming + "/" + org_roaming + " interactive=" + last_interactive + " tethering=" + tethering + " filter=" + filter); if (last_connected) for (Rule rule : listRule) { boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked); boolean screen = (metered ? rule.screen_other : rule.screen_wifi); if ((!blocked || (screen && last_interactive)) && (!metered || !(rule.roaming && roaming))) listAllowed.add(rule); } Log.i(TAG, "Allowed " + listAllowed.size() + " of " + listRule.size()); return listAllowed; }
From source file:com.facebook.litho.InternalNode.java
/** * Crash if the given node has context specific style set. *//*from w ww . j av a 2 s.com*/ static void assertContextSpecificStyleNotSet(InternalNode node) { List<CharSequence> errorTypes = null; if ((node.mPrivateFlags & PFLAG_ALIGN_SELF_IS_SET) != 0L) { errorTypes = addOrCreateList(errorTypes, "alignSelf"); } if ((node.mPrivateFlags & PFLAG_POSITION_TYPE_IS_SET) != 0L) { errorTypes = addOrCreateList(errorTypes, "positionType"); } if ((node.mPrivateFlags & PFLAG_FLEX_IS_SET) != 0L) { errorTypes = addOrCreateList(errorTypes, "flex"); } if ((node.mPrivateFlags & PFLAG_FLEX_GROW_IS_SET) != 0L) { errorTypes = addOrCreateList(errorTypes, "flexGrow"); } if ((node.mPrivateFlags & PFLAG_MARGIN_IS_SET) != 0L) { errorTypes = addOrCreateList(errorTypes, "margin"); } if (errorTypes != null) { final CharSequence errorStr = TextUtils.join(", ", errorTypes); throw new IllegalStateException("You should not set " + errorStr + " to a root layout in " + node.getRootComponent().getLifecycle()); } }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get my message threads./*ww w .ja v a2s . co m*/ * * @param howManyMessages * @param since * @param until * @param limit * @param locale * @param isUnixTime * @return list of FacebookMessageThread objects * @throws Exception */ private List<FacebookMessageThread> getMyMessageThreads(int howManyMessages, long since, long until, int limit, Locale locale, boolean isUnixTime) throws Exception { String apiUri = "/me/inbox"; // validate how many messages per thread int messageLimit = howManyMessages; if (messageLimit < 1) { messageLimit = 1; } else if (messageLimit > 30) { messageLimit = 30; } // fields parameters String[] fields = { "id", "to", "unread", "unseen", "updated_time", "comments.limit(" + messageLimit + ")" }; // set system locale if none given Locale localeParam = locale; if (localeParam == null) localeParam = Util.getSystemLocale(); List<NameValuePair> params = ParameterHelper.addAllParams( new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()), new BasicNameValuePair("fields", TextUtils.join(",", fields)), new BasicNameValuePair("locale", localeParam.toString())); // set page parameters setTimeBasedPageParams(params, since, until, limit, isUnixTime); return populateMessageThreadList(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:com.tct.mail.ui.ConversationViewFragment.java
@Override public void showExternalResources(final String senderRawAddress) { mWebView.getSettings().setBlockNetworkImage(false); final Address sender = getAddress(senderRawAddress); final MessageCursor cursor = getMessageCursor(); final List<String> messageDomIds = new ArrayList<String>(); int pos = -1; while (cursor.moveToPosition(++pos)) { final ConversationMessage message = cursor.getMessage(); if (sender.equals(getAddress(message.getFrom()))) { message.alwaysShowImages = true; mViewState.setShouldShowImages(message, true); messageDomIds.add(mTemplates.getMessageDomId(message)); }/* w w w . ja v a 2 s .c o m*/ } final String url = String.format("javascript:unblockImages(['%s']);", TextUtils.join("','", messageDomIds)); mWebView.loadUrl(url); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get a message thread with last 30 messages in it. * // ww w. ja v a 2s. co m * @param messageThreadId * @param locale * @param isUnixTime * @return FacebookMessageThread * @throws Exception */ private FacebookMessageThread getMessageThread(String messageThreadId, Locale locale, boolean isUnixTime) throws Exception { // throw an exception if message threaad ID is invalid if (StringHelper.isEmpty(messageThreadId) == true) { throw new SystemException("Invalid message thread ID."); } String apiUri = "/" + messageThreadId; // fields parameters String[] fields = { "id", "to", "unread", "unseen", "updated_time", "comments.limit(30)" }; // set system locale if none given Locale localeParam = locale; if (localeParam == null) localeParam = Util.getSystemLocale(); List<NameValuePair> params = ParameterHelper.addAllParams( new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()), new BasicNameValuePair("fields", TextUtils.join(",", fields)), new BasicNameValuePair("locale", localeParam.toString())); // set date format parameter setDateFormatParam(params, isUnixTime); return populateMessageThreadBean(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:eu.faircode.netguard.ServiceSinkhole.java
private List<Rule> getAllowedRules(List<Rule> listRule) { List<Rule> listAllowed = new ArrayList<>(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Check state boolean wifi = Util.isWifiActive(this); boolean metered = Util.isMeteredNetwork(this); boolean useMetered = prefs.getBoolean("use_metered", false); Set<String> ssidHomes = prefs.getStringSet("wifi_homes", new HashSet<String>()); String ssidNetwork = Util.getWifiSSID(this); String generation = Util.getNetworkGeneration(this); boolean unmetered_2g = prefs.getBoolean("unmetered_2g", false); boolean unmetered_3g = prefs.getBoolean("unmetered_3g", false); boolean unmetered_4g = prefs.getBoolean("unmetered_4g", false); boolean roaming = Util.isRoaming(ServiceSinkhole.this); boolean national = prefs.getBoolean("national_roaming", false); boolean tethering = prefs.getBoolean("tethering", false); boolean filter = prefs.getBoolean("filter", false); // Update connected state last_connected = Util.isConnected(ServiceSinkhole.this); boolean org_metered = metered; boolean org_roaming = roaming; // Update metered state if (wifi && !useMetered) metered = false;/* ww w .ja va 2 s . c o m*/ if (wifi && ssidHomes.size() > 0 && !(ssidHomes.contains(ssidNetwork) || ssidHomes.contains('"' + ssidNetwork + '"'))) { metered = true; Log.i(TAG, "!@home"); } if (unmetered_2g && "2G".equals(generation)) metered = false; if (unmetered_3g && "3G".equals(generation)) metered = false; if (unmetered_4g && "4G".equals(generation)) metered = false; last_metered = metered; boolean lockdown = isLockedDown(last_metered); // Update roaming state if (roaming && national) roaming = Util.isInternational(this); Log.i(TAG, "Get allowed" + " connected=" + last_connected + " wifi=" + wifi + " home=" + TextUtils.join(",", ssidHomes) + " network=" + ssidNetwork + " metered=" + metered + "/" + org_metered + " generation=" + generation + " roaming=" + roaming + "/" + org_roaming + " interactive=" + last_interactive + " tethering=" + tethering + " filter=" + filter + " lockdown=" + lockdown); if (last_connected) for (Rule rule : listRule) { boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked); boolean screen = (metered ? rule.screen_other : rule.screen_wifi); if ((!blocked || (screen && last_interactive)) && (!metered || !(rule.roaming && roaming)) && (!lockdown || rule.lockdown)) listAllowed.add(rule); } Log.i(TAG, "Allowed " + listAllowed.size() + " of " + listRule.size()); return listAllowed; }