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:com.android.launcher3.Utilities.java

public static String createDbSelectionQuery(String columnName, Iterable<?> values) {
    return String.format(Locale.ENGLISH, "%s IN (%s)", columnName, TextUtils.join(", ", values));
}

From source file:com.TagFu.facebook.Session.java

private void logAuthorizationStart() {

    final Bundle bundle = AuthorizationClient
            .newAuthorizationLoggingBundle(this.pendingAuthorizationRequest.getAuthId());
    bundle.putLong(AuthorizationClient.EVENT_PARAM_TIMESTAMP, System.currentTimeMillis());

    // Log what we already know about the call in start event
    try {/*from   w ww.  j a  v  a2s.  c o m*/
        final JSONObject extras = new JSONObject();
        extras.put(AuthorizationClient.EVENT_EXTRAS_LOGIN_BEHAVIOR,
                this.pendingAuthorizationRequest.loginBehavior.toString());
        extras.put(AuthorizationClient.EVENT_EXTRAS_REQUEST_CODE, this.pendingAuthorizationRequest.requestCode);
        extras.put(AuthorizationClient.EVENT_EXTRAS_IS_LEGACY, this.pendingAuthorizationRequest.legacy);
        extras.put(AuthorizationClient.EVENT_EXTRAS_PERMISSIONS,
                TextUtils.join(",", this.pendingAuthorizationRequest.permissions));
        extras.put(AuthorizationClient.EVENT_EXTRAS_DEFAULT_AUDIENCE,
                this.pendingAuthorizationRequest.defaultAudience.toString());
        bundle.putString(AuthorizationClient.EVENT_PARAM_EXTRAS, extras.toString());
    } catch (final JSONException e) {
    }

    final AppEventsLogger logger = this.getAppEventsLogger();
    logger.logSdkEvent(AuthorizationClient.EVENT_NAME_LOGIN_START, null, bundle);
}

From source file:com.ichi2.libanki.Collection.java

/**
 * Logging//from w  w  w  .  j a va 2 s .  c o  m
 * ***********************************************************
 */

public void log(Object... args) {
    if (!mDebugLog) {
        return;
    }
    StackTraceElement trace = Thread.currentThread().getStackTrace()[3];
    // Overwrite any args that need special handling for an appropriate string representation
    for (int i = 0; i < args.length; i++) {
        if (args[i] instanceof long[]) {
            args[i] = Arrays.toString((long[]) args[i]);
        }
    }
    String s = String.format("[%s] %s:%s(): %s", Utils.intNow(), trace.getFileName(), trace.getMethodName(),
            TextUtils.join(",  ", args));
    mLogHnd.println(s);
    Timber.d(s);
}

From source file:eu.faircode.adblocker.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;/* w w w  .j  av a2  s  .  co 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;

    // 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:illab.nabal.proxy.FacebookProxy.java

/**
 * Get friend requests for the owner of the current access token.
 * /*  www.  j a va2  s  . com*/
 * @param getOnlyUnread
 * @param limit
 * @param offset
 * @param locale
 * @return list of FacebookProfile
 * @throws Exception
 */
private List<FacebookProfile> getFriendRequestsForMe(boolean getOnlyUnread, int limit, int offset,
        Locale locale) throws Exception {

    String apiUri = "/me/friendrequests";

    // fields parameters - expand from field to get details 
    String[] fields = { "to", "from.fields(" + getProfileFields(null) + ")", "message", "unread",
            "created_time" };

    // 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
    setPageOffsetParams(params, limit, offset);

    return populateProfileList(null, getOnlyUnread, localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:com.example.search.car.pools.welcome.java

private CharSequence getCapitalWords(String sentence) {
    String[] words = null;//from  ww w.  j a va 2s  .  c  om
    if (sentence != null && sentence.length() > 2) {
        try {
            words = sentence.split(" ");
            for (int i = 0; i < words.length; i++) {
                words[i] = words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase();
            }
        } catch (Exception e) {
            //e.printStackTrace();
        }
        return TextUtils.join(" ", words);
    } else
        return sentence.toUpperCase().toString();
}

From source file:android_network.hetnet.vpn_service.ActivitySettings.java

private void xmlExport(SharedPreferences prefs, XmlSerializer serializer) throws IOException {
    Map<String, ?> settings = prefs.getAll();
    for (String key : settings.keySet()) {
        Object value = settings.get(key);

        if ("imported".equals(key))
            continue;

        if (value instanceof Boolean) {
            serializer.startTag(null, "setting");
            serializer.attribute(null, "key", key);
            serializer.attribute(null, "type", "boolean");
            serializer.attribute(null, "value", value.toString());
            serializer.endTag(null, "setting");

        } else if (value instanceof Integer) {
            serializer.startTag(null, "setting");
            serializer.attribute(null, "key", key);
            serializer.attribute(null, "type", "integer");
            serializer.attribute(null, "value", value.toString());
            serializer.endTag(null, "setting");

        } else if (value instanceof String) {
            serializer.startTag(null, "setting");
            serializer.attribute(null, "key", key);
            serializer.attribute(null, "type", "string");
            serializer.attribute(null, "value", value.toString());
            serializer.endTag(null, "setting");

        } else if (value instanceof Set) {
            Set<String> set = (Set<String>) value;
            serializer.startTag(null, "setting");
            serializer.attribute(null, "key", key);
            serializer.attribute(null, "type", "set");
            serializer.attribute(null, "value", TextUtils.join("\n", set));
            serializer.endTag(null, "setting");

        } else/* w  ww  . java2s  .  c  o m*/
            Log.e(TAG, "Unknown key=" + key);
    }
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get events.//from w w  w .j av a 2 s  .  c  om
 * 
 * @param ownerIdentifier
 * @param filter
 * @param limit
 * @param offset
 * @param locale
 * @return list of FacebookEvent objects
 * @throws Exception
 */
private List<FacebookEvent> getEvents(String ownerIdentifier, FacebookEvent.Filter filter, int limit,
        int offset, Locale locale) throws Exception {

    // throw an exception if owner identifier is invalid
    if (StringHelper.isEmpty(ownerIdentifier) == true) {
        throw new SystemException("Invalid owner identifier.");
    }

    String uriEndpoint = "";

    // set filter if needed
    if (filter != null) {
        uriEndpoint = "/" + filter.getFilterString();
    }

    String apiUri = "/" + ownerIdentifier + "/events" + uriEndpoint;

    String[] fields = { "id", "owner", "name", "description", "cover", "start_time", "end_time", "timezone",
            "location,venue", "privacy", "updated_time" };

    // 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
    setPageOffsetParams(params, limit, offset);

    return populateEventList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:dentex.youtube.downloader.ShareActivity.java

private String parseSingleEsSig(String sig) {
    if (sig.length() == 88) {
        String[] sigA = sig.split("");
        sigA = Arrays.copyOfRange(sigA, 2, sigA.length);
        sigA = swap(sigA, 1);/*from  w w w.j  a v a  2s .  co  m*/
        sigA = swap(sigA, 10);
        sigA = reverseArray(sigA);
        sigA = Arrays.copyOfRange(sigA, 2, sigA.length);
        sigA = swap(sigA, 23);
        sigA = Arrays.copyOfRange(sigA, 3, sigA.length);
        sigA = swap(sigA, 15);
        sigA = swap(sigA, 34);
        sig = TextUtils.join("", sigA);
    }

    if (sig.length() == 87) {
        String[] t = initialSigTransformation(sig, 44, 84, 3, 43);
        sig = t[0].substring(21, 22) + t[0].substring(1, 21) + t[0].substring(0, 1) + t[1].substring(22, 31)
                + sig.substring(0, 1) + t[0].substring(32, 40) + sig.substring(43, 44) + t[1];
    }

    if (sig.length() == 86) {
        String sigA = sig.substring(2, 42);
        String sigB = sig.substring(43, 83);
        sig = sigA + sig.substring(42, 43) + sigB.substring(0, 20) + sigB.substring(39, 40)
                + sigB.substring(21, 39) + sigB.substring(20, 21);
    }

    if (sig.length() == 85) {
        String[] t = initialSigTransformation(sig, 44, 84, 3, 43);
        sig = t[0].substring(7, 8) + t[0].substring(1, 7) + t[0].substring(0, 1) + t[0].substring(8, 23)
                + sig.substring(0, 1) + t[0].substring(24, 33) + sig.substring(1, 2) + t[0].substring(34, 40)
                + sig.substring(43, 44) + t[1];
    }

    if (sig.length() == 84) {
        String[] t = initialSigTransformation(sig, 44, 84, 3, 43);
        sig = t[0] + sig.substring(43, 44) + t[1].substring(0, 6) + sig.substring(2, 3) + t[1].substring(7, 16)
                + t[1].substring(39, 40) + t[1].substring(17, 39) + t[1].substring(16, 17);
    }

    if (sig.length() == 83) {
        String[] t = initialSigTransformation(sig, 43, 83, 2, 42);
        sig = t[0].substring(30, 31) + t[0].substring(1, 27) + t[1].substring(39, 40) + t[0].substring(28, 30)
                + t[0].substring(0, 1) + t[0].substring(31, 40) + sig.substring(42, 43) + t[1].substring(0, 5)
                + t[0].substring(27, 28) + t[1].substring(6, 39) + t[1].substring(5, 6);
    }

    if (sig.length() == 82) {
        String[] t = initialSigTransformation(sig, 34, 82, 0, 33);
        sig = t[0].substring(45, 46) + t[0].substring(2, 14) + t[0].substring(0, 1) + t[0].substring(15, 41)
                + sig.substring(33, 34) + t[0].substring(42, 43) + t[0].substring(43, 44)
                + t[0].substring(44, 45) + t[0].substring(41, 42) + t[0].substring(46, 47)
                + t[1].substring(32, 33) + t[0].substring(14, 15) + t[1].substring(0, 32)
                + t[0].substring(47, 48);
    }
    return sig;
}

From source file:com.facebook.Session.java

private void logAuthorizationStart() {
    Bundle bundle = AuthorizationClient.newAuthorizationLoggingBundle(pendingAuthorizationRequest.getAuthId());
    bundle.putLong(AuthorizationClient.EVENT_PARAM_TIMESTAMP, System.currentTimeMillis());

    // Log what we already know about the call in start event
    try {//  ww  w.j  a  v  a  2  s  .com
        JSONObject extras = new JSONObject();
        extras.put(AuthorizationClient.EVENT_EXTRAS_LOGIN_BEHAVIOR,
                pendingAuthorizationRequest.loginBehavior.toString());
        extras.put(AuthorizationClient.EVENT_EXTRAS_REQUEST_CODE, pendingAuthorizationRequest.requestCode);
        extras.put(AuthorizationClient.EVENT_EXTRAS_IS_LEGACY, pendingAuthorizationRequest.isLegacy);
        extras.put(AuthorizationClient.EVENT_EXTRAS_PERMISSIONS,
                TextUtils.join(",", pendingAuthorizationRequest.permissions));
        extras.put(AuthorizationClient.EVENT_EXTRAS_DEFAULT_AUDIENCE,
                pendingAuthorizationRequest.defaultAudience.toString());
        bundle.putString(AuthorizationClient.EVENT_PARAM_EXTRAS, extras.toString());
    } catch (JSONException e) {
    }

    AppEventsLogger logger = getAppEventsLogger();
    logger.logSdkEvent(AuthorizationClient.EVENT_NAME_LOGIN_START, null, bundle);
}