Example usage for android.text TextUtils join

List of usage examples for android.text TextUtils join

Introduction

In this page you can find the example usage for android.text TextUtils join.

Prototype

public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens) 

Source Link

Document

Returns a string containing the tokens joined by delimiters.

Usage

From source file:Main.java

/**
 * Convert capitalize mode flags into human readable text.
 *
 * @param capsFlags The modes flags to be converted. It may be any combination of
 * {@link TextUtils#CAP_MODE_CHARACTERS}, {@link TextUtils#CAP_MODE_WORDS}, and
 * {@link TextUtils#CAP_MODE_SENTENCES}.
 * @return the text that describe the <code>capsMode</code>.
 *///from  w  w w .  j a v  a  2 s .  c o  m
public static String flagsToString(final int capsFlags) {
    final int capsFlagsMask = TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS
            | TextUtils.CAP_MODE_SENTENCES;
    if ((capsFlags & ~capsFlagsMask) != 0) {
        return "unknown<0x" + Integer.toHexString(capsFlags) + ">";
    }
    final ArrayList<String> builder = new ArrayList<>();
    if ((capsFlags & android.text.TextUtils.CAP_MODE_CHARACTERS) != 0) {
        builder.add("characters");
    }
    if ((capsFlags & android.text.TextUtils.CAP_MODE_WORDS) != 0) {
        builder.add("words");
    }
    if ((capsFlags & android.text.TextUtils.CAP_MODE_SENTENCES) != 0) {
        builder.add("sentences");
    }
    return builder.isEmpty() ? "none" : TextUtils.join("|", builder);
}

From source file:com.vk.sdk.util.VKStringJoiner.java

/**
 * Joins some collection to string with glue
 *
 * @param what Collection to join/* w w w .j  a  v  a2 s  .  c  om*/
 * @param glue Glue for joined strings
 * @return Joined string
 */
public static String join(Collection<?> what, String glue) {
    return TextUtils.join(glue, what);
}

From source file:org.wikipedia.pageimages.PageImagesClient.java

@VisibleForTesting
Call<MwQueryResponse> request(@NonNull final WikiSite wiki, @NonNull Service service,
        @NonNull final List<PageTitle> titles, @NonNull final Callback cb) {
    Call<MwQueryResponse> call = service.request(TextUtils.join("|", titles));
    call.enqueue(new retrofit2.Callback<MwQueryResponse>() {
        @Override//from ww w .j a v a2 s  .  c o  m
        public void onResponse(@NonNull Call<MwQueryResponse> call,
                @NonNull Response<MwQueryResponse> response) {
            Map<PageTitle, PageImage> pageImagesMap = new ArrayMap<>();
            // error cases
            if (response.body().success()) {
                // nominal case
                Map<String, PageTitle> titlesMap = new ArrayMap<>();
                for (PageTitle title : titles) {
                    titlesMap.put(title.getPrefixedText(), title);
                }
                Map<String, String> thumbnailSourcesMap = new ArrayMap<>();

                // noinspection ConstantConditions
                for (MwQueryPage page : response.body().query().pages()) {
                    thumbnailSourcesMap.put(new PageTitle(null, page.title(), wiki).getPrefixedText(),
                            page.thumbUrl());
                    if (!TextUtils.isEmpty(page.convertedFrom())) {
                        thumbnailSourcesMap.put(
                                new PageTitle(null, page.convertedFrom(), wiki).getPrefixedText(),
                                page.thumbUrl());
                    }
                    if (!TextUtils.isEmpty(page.redirectFrom())) {
                        thumbnailSourcesMap.put(
                                new PageTitle(null, page.redirectFrom(), wiki).getPrefixedText(),
                                page.thumbUrl());
                    }
                }

                for (String key : titlesMap.keySet()) {
                    if (thumbnailSourcesMap.containsKey(key)) {
                        PageTitle title = titlesMap.get(key);
                        pageImagesMap.put(title, new PageImage(title, thumbnailSourcesMap.get(key)));
                    }
                }
                cb.success(call, pageImagesMap);
            } else if (response.body().hasError()) {
                // noinspection ConstantConditions
                cb.failure(call, new MwException(response.body().getError()));
            } else {
                cb.failure(call, new IOException("An unknown error occurred."));
            }
        }

        @Override
        public void onFailure(@NonNull Call<MwQueryResponse> call, @NonNull Throwable t) {
            cb.failure(call, t);
        }
    });
    return call;
}

From source file:com.deliciousdroid.platform.BookmarkManager.java

public static CursorLoader GetBookmarks(String username, String tagname, String sortorder, Context context) {
    final String[] projection = new String[] { Bookmark._ID, Bookmark.Url, Bookmark.Description, Bookmark.Meta,
            Bookmark.Tags, Bookmark.Shared, Bookmark.Synced, Bookmark.Deleted };
    String selection = null;//ww w  . jav  a  2  s.  c  om
    ArrayList<String> selectionList = new ArrayList<String>();
    final ArrayList<String> queryList = new ArrayList<String>();

    if (tagname != null && tagname != "") {
        String[] tagList = tagname.split(",");

        for (String s : tagList) {
            queryList.add("(" + Bookmark.Tags + " LIKE ? OR " + Bookmark.Tags + " LIKE ? OR " + Bookmark.Tags
                    + " LIKE ? OR " + Bookmark.Tags + " = ?)");

            selectionList.add("% " + s + " %");
            selectionList.add("% " + s);
            selectionList.add(s + " %");
            selectionList.add(s);
        }
        selection = TextUtils.join(" OR ", queryList) + " AND " + Bookmark.Account + "=?";

        selectionList.add(username);
    } else {
        selectionList.add(username);
        selection = Bookmark.Account + "=?";
    }

    selection += " AND " + Bookmark.Deleted + "=0";

    return new CursorLoader(context, Bookmark.CONTENT_URI, projection, selection,
            selectionList.toArray(new String[] {}), sortorder);
}

From source file:android.net.ProxyInfo.java

/**
 * Constructs a {@link ProxyInfo} object that points at a Direct proxy
 * on the specified host and port.//from w  ww .  j a  v  a  2 s . co m
 *
 * The proxy will not be used to access any host in exclusion list, exclList.
 *
 * @param exclList Hosts to exclude using the proxy on connections for.  These
 *                 hosts can use wildcards such as *.example.com.
 */
public static ProxyInfo buildDirectProxy(String host, int port, List<String> exclList) {
    String[] array = exclList.toArray(new String[exclList.size()]);
    return new ProxyInfo(host, port, TextUtils.join(",", array), array);
}

From source file:com.example.android.permissionrequest.ConfirmationDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    String[] resources = getArguments().getStringArray(ARG_RESOURCES);
    return new AlertDialog.Builder(getActivity())
            .setMessage(getString(R.string.confirmation, TextUtils.join("\n", resources)))
            .setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
                @Override// w ww. j a v  a  2s .c o  m
                public void onClick(DialogInterface dialog, int which) {
                    ((Listener) getParentFragment()).onConfirmation(false);
                }
            }).setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ((Listener) getParentFragment()).onConfirmation(true);
                }
            }).create();
}

From source file:org.totschnig.myexpenses.dialog.WelcomeDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity ctx = (Activity) getActivity();
    LayoutInflater li = LayoutInflater.from(ctx);
    View view = li.inflate(R.layout.welcome_dialog, null);
    ((TextView) view.findViewById(R.id.help_intro))
            .setText("- " + TextUtils.join("\n- ", getResources().getStringArray(R.array.help_intro)));
    return new AlertDialog.Builder(ctx)
            .setTitle(getResources().getString(R.string.app_name) + " "
                    + getResources().getString(R.string.dialog_title_welcome))
            .setIcon(R.drawable.icon).setView(view).setPositiveButton(android.R.string.ok, null).create();
}

From source file:com.xengar.android.booksearch.data.Book.java

private static String getAuthor(final JSONObject jsonObject) {
    try {/*from  w w  w.j  a  va2  s.com*/
        final JSONArray authors = jsonObject.getJSONArray("author_name");
        int numAuthors = authors.length();
        final String[] authorStrings = new String[numAuthors];
        for (int i = 0; i < numAuthors; ++i) {
            authorStrings[i] = authors.getString(i);
        }
        return TextUtils.join(", ", authorStrings);
    } catch (JSONException e) {
        return "";
    }
}

From source file:net.kjmaster.cookiemom.settings.SettingsActivity.java

@AfterViews
void afterViews() {
    if (iSettings.CookieList().get() == null) {
        iSettings.CookieList()/*w  ww  .ja va2s .  c  om*/
                .put(TextUtils.join(",", getResources().getStringArray(R.array.cookie_names_array)));
    } else {
        cookieList = iSettings.CookieList().get();
        String[] cookies = TextUtils.split(cookieList, ",");
        if (cookies.length != getResources().getStringArray(R.array.cookie_names_array).length) {
            cookieList = TextUtils.join(",", getResources().getStringArray(R.array.cookie_names_array));
        }
    }
    settingsFragment = SettingsFragment_.builder().build();
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.content, settingsFragment);
    ft.commit();

}

From source file:com.adjust.sdk.Util.java

protected static String getUserAgent(final Context context) {
    final Resources resources = context.getResources();
    final DisplayMetrics displayMetrics = resources.getDisplayMetrics();
    final Configuration configuration = resources.getConfiguration();
    final Locale locale = configuration.locale;
    final int screenLayout = configuration.screenLayout;

    final String[] parts = { getPackageName(context), getAppVersion(context), getDeviceType(screenLayout),
            getDeviceName(), getOsName(), getOsVersion(), getLanguage(locale), getCountry(locale),
            getScreenSize(screenLayout), getScreenFormat(screenLayout), getScreenDensity(displayMetrics),
            getDisplayWidth(displayMetrics), getDisplayHeight(displayMetrics) };
    return TextUtils.join(" ", parts);
}