List of usage examples for android.text TextUtils join
public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens)
From source file:com.yanzhenjie.nohttp.HttpHeaders.java
@Override public void addCookie(URI uri, CookieHandler cookieHandler) { try {//from w w w.j a va2 s. c o m Map<String, List<String>> diskCookies = cookieHandler.get(uri, new HashMap<String, List<String>>()); for (Map.Entry<String, List<String>> entry : diskCookies.entrySet()) { String key = entry.getKey(); List<String> value = entry.getValue(); if (HEAD_KEY_COOKIE.equalsIgnoreCase(key)) { add(key, TextUtils.join("; ", value)); } } } catch (IOException e) { Logger.e(e); } }
From source file:com.fsck.k9.helper.Utility.java
/** * Combines the given Objects into a single String using * each Object's toString() method and the separator character * between each part.//from www . jav a 2 s .c om * * @param parts * @param separator * @return new String */ public static String combine(Iterable<?> parts, char separator) { if (parts == null) { return null; } return TextUtils.join(String.valueOf(separator), parts); }
From source file:net.bither.preference.PersistentCookieStore.java
@Override public void addCookie(Cookie cookie) { String name = cookie.getName(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie);/*ww w . j a va2s .co m*/ } else { cookies.remove(name); } // Save cookie into persistent store SharedPreferences.Editor prefsWriter = this.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:se.tmeit.app.ui.members.MemberInfoFragment.java
public static String getDescriptionOfFlags(Context context, Member member) { List<String> strings = new ArrayList<>(); if (member.hasFlag(Member.Flags.HAS_STAD)) { strings.add(context.getString(R.string.member_stad)); }//from w w w . j a v a 2 s .c o m if (member.hasFlag(Member.Flags.HAS_FEST)) { strings.add(context.getString(R.string.member_fest)); } if (member.hasFlag(Member.Flags.ON_PERMIT)) { strings.add(context.getString(R.string.member_on_permit)); } if (member.hasFlag(Member.Flags.DRIVERS_LICENSE)) { strings.add(context.getString(R.string.member_drivers_license)); } return TextUtils.join(", ", strings); }
From source file:com.facebook.login.WebViewLoginMethodHandler.java
@Override boolean tryAuthorize(final LoginClient.Request request) { Bundle parameters = new Bundle(); if (!Utility.isNullOrEmpty(request.getPermissions())) { String scope = TextUtils.join(",", request.getPermissions()); parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope); addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope); }/* ww w.j a va2 s. c om*/ DefaultAudience audience = request.getDefaultAudience(); parameters.putString(ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience()); AccessToken previousToken = AccessToken.getCurrentAccessToken(); String previousTokenString = previousToken != null ? previousToken.getToken() : null; if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) { parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString); // Don't log the actual access token, just its presence or absence. addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES); } else { // The call to clear cookies will create the first instance of CookieSyncManager if // necessary Utility.clearFacebookCookies(loginClient.getActivity()); addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO); } WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { onWebDialogComplete(request, values, error); } }; e2e = LoginClient.getE2E(); addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e); FragmentActivity fragmentActivity = loginClient.getActivity(); WebDialog.Builder builder = new AuthDialogBuilder(fragmentActivity, request.getApplicationId(), parameters) .setE2E(e2e).setIsRerequest(request.isRerequest()).setOnCompleteListener(listener); loginDialog = builder.build(); FacebookDialogFragment dialogFragment = new FacebookDialogFragment(); dialogFragment.setRetainInstance(true); dialogFragment.setDialog(loginDialog); dialogFragment.show(fragmentActivity.getSupportFragmentManager(), FacebookDialogFragment.TAG); return true; }
From source file:com.facebook.login.WebViewLoginMethodHandler.java
@Override boolean tryAuthorize(final LoginClient.Request request) { Bundle parameters = new Bundle(); if (!Utility.isNullOrEmpty(request.getPermissions())) { String scope = TextUtils.join(",", request.getPermissions()); parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope); addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope); }/*from w ww . jav a 2s.com*/ DefaultAudience audience = request.getDefaultAudience(); parameters.putString(ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience()); AccessToken previousToken = AccessToken.getCurrentAccessToken(); String previousTokenString = previousToken != null ? previousToken.getToken() : null; if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) { parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString); // Don't log the actual access token, just its presence or absence. addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES); } else { // The call to clear cookies will create the first instance of CookieSyncManager if // necessary Utility.clearFacebookCookies(loginClient.getActivity()); addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO); } WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { onWebDialogComplete(request, values, error); } }; e2e = LoginClient.getE2E(); addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e); FragmentActivity fragmentActivity = loginClient.getActivity(); WebDialog.Builder builder = new AuthDialogBuilder(fragmentActivity, request.getApplicationId(), parameters) .setE2E(e2e).setIsRerequest(request.isRerequest()).setOnCompleteListener(listener) .setTheme(FacebookSdk.getWebDialogTheme()); loginDialog = builder.build(); FacebookDialogFragment dialogFragment = new FacebookDialogFragment(); dialogFragment.setRetainInstance(true); dialogFragment.setDialog(loginDialog); dialogFragment.show(fragmentActivity.getSupportFragmentManager(), FacebookDialogFragment.TAG); return true; }
From source file:com.odo.kcl.mobileminer.OpenBmapCellRequest.java
@Override protected Object doInBackground(Object... cellSpec) { if (cellSpec.length < 4) return null; String Mcc, Mnc, Lac, Id;//w w w. j a va 2s. c om Mcc = (String) cellSpec[0]; Mnc = (String) cellSpec[1]; Lac = (String) cellSpec[2]; Id = (String) cellSpec[3]; HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://www.openbmap.org/api/getGPSfromGSM.php"); List<NameValuePair> postData = new ArrayList<NameValuePair>(4); postData.add(new BasicNameValuePair("mcc", Mcc)); postData.add(new BasicNameValuePair("mnc", Mnc)); postData.add(new BasicNameValuePair("lac", Lac)); postData.add(new BasicNameValuePair("cell_id", Id)); try { String XMLdump, Lat, Long, poly, polyDump; Lat = null; Long = null; poly = null; post.setEntity(new UrlEncodedFormEntity(postData)); XMLdump = EntityUtils.toString(client.execute(post).getEntity()); //Log.i("MobileMiner",XMLdump); Matcher latMatch = latPattern.matcher(XMLdump); while (latMatch.find()) Lat = latMatch.group(1); Matcher longMatch = longPattern.matcher(XMLdump); while (longMatch.find()) Long = longMatch.group(1); Matcher polyMatch = polyPattern.matcher(XMLdump); while (polyMatch.find()) poly = polyMatch.group(1); //Log.i("MobileMiner","Lat "+Lat); //Log.i("MobileMiner","Long "+Long); //Log.i("MobileMiner","Poly "+poly); if (poly != null) { List<String> points = new ArrayList<String>(); String[] point; String[] polyChunks = poly.split(","); for (String chunk : polyChunks) { point = chunk.split("\\s+"); points.add("[" + point[1] + "," + point[0] + "]"); } polyDump = "[" + TextUtils.join(",", points.subList(0, points.size() - 1)) + "]"; //Log.i("MobileMiner",polyDump); } else { polyDump = null; } if (Lat != null && Long != null) { return new String[] { Lat, Long, polyDump }; } else { return null; } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block //e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block } // TODO Auto-generated method stub return null; }
From source file:com.google.android.apps.dashclock.configuration.PackageChooserPreference.java
public void setPackages(Set<String> packages) { if (null == packages) { setValue(""); return;/*w w w . j a va2 s . co m*/ } setValue((packages.size() == 0) ? "" : TextUtils.join(":", packages)); }
From source file:com.easy.facebook.android.facebook.FBLoginManager.java
public void login() { Intent intent = new Intent(); intent.setClassName("com.facebook.katana", "com.facebook.katana.ProxyAuth"); if (!validateAppSignatureForIntent(activity, intent)) { try {/* w w w . j ava 2 s .c o m*/ startDialogAuth(activity, permissions); } catch (EasyFacebookError e) { ((LoginListener) activity).loginFail(); } } else { if (permissions.length > 0) { intent.putExtra("client_id", appID); intent.putExtra("scope", TextUtils.join(",", permissions)); try { activity.startActivityForResult(intent, DEFAULT_AUTH_ACTIVITY_CODE); } catch (ActivityNotFoundException e) { ((LoginListener) activity).loginFail(); } } } }
From source file:dev.drsoran.moloko.fragments.TaskEditFragment.java
@Override public Bundle determineInitialValues() { final Task task = getTaskAssertNotNull(); final Bundle initialValues = new Bundle(); initialValues.putString(Tasks.TASKSERIES_NAME, task.getName()); initialValues.putString(Tasks.LIST_ID, task.getListId()); initialValues.putString(Tasks.PRIORITY, RtmTask.convertPriority(task.getPriority())); initialValues.putString(Tasks.TAGS, TextUtils.join(Tasks.TAGS_SEPARATOR, task.getTags())); initialValues.putLong(Tasks.DUE_DATE, MolokoDateUtils.getTime(task.getDue(), Long.valueOf(-1))); initialValues.putBoolean(Tasks.HAS_DUE_TIME, task.hasDueTime()); initialValues.putString(Tasks.RECURRENCE, task.getRecurrence()); initialValues.putBoolean(Tasks.RECURRENCE_EVERY, task.isEveryRecurrence()); initialValues.putString(Tasks.ESTIMATE, task.getEstimate()); initialValues.putLong(Tasks.ESTIMATE_MILLIS, task.getEstimateMillis()); initialValues.putString(Tasks.LOCATION_ID, task.getLocationId()); initialValues.putString(Tasks.URL, task.getUrl()); return initialValues; }