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.example.administrator.datarequest.ningworld.HttpHeaders.java

@Override
public Map<String, String> toRequestHeaders() {
    Map<String, String> singleMap = new LinkedHashMap<String, String>();
    for (Map.Entry<String, List<String>> entry : mSource.entrySet()) {
        String key = entry.getKey();
        List<String> value = entry.getValue();
        String trueValue = TextUtils.join("; ", value);
        singleMap.put(key, trueValue);/* w w  w.j  a  v  a2 s . co m*/
    }
    return singleMap;
}

From source file:com.yanzhenjie.nohttp.HttpHeaders.java

@Override
public Map<String, String> toRequestHeaders() {
    Map<String, String> singleMap = new LinkedHashMap<>();
    for (Map.Entry<String, List<String>> entry : entrySet()) {
        String key = entry.getKey();
        List<String> value = entry.getValue();
        String trueValue = TextUtils.join("; ", value);
        singleMap.put(key, trueValue);/*w  w  w .  jav a2s  .  c  o m*/
    }
    return singleMap;
}

From source file:org.gnucash.android.ui.report.BalanceSheetFragment.java

/**
 * Loads rows for the individual accounts and adds them to the report
 * @param accountTypes Account types for which to load balances
 * @param tableLayout Table layout into which to load the rows
 *///from   w ww . j a  v  a  2s.  com
private void loadAccountViews(List<AccountType> accountTypes, TableLayout tableLayout) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());

    Cursor cursor = mAccountsDbAdapter.fetchAccounts(
            DatabaseSchema.AccountEntry.COLUMN_TYPE + " IN ( '" + TextUtils.join("' , '", accountTypes)
                    + "' ) AND " + DatabaseSchema.AccountEntry.COLUMN_PLACEHOLDER + " = 0",
            null, DatabaseSchema.AccountEntry.COLUMN_FULL_NAME + " ASC");

    while (cursor.moveToNext()) {
        String accountUID = cursor
                .getString(cursor.getColumnIndexOrThrow(DatabaseSchema.AccountEntry.COLUMN_UID));
        String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseSchema.AccountEntry.COLUMN_NAME));
        Money balance = mAccountsDbAdapter.getAccountBalance(accountUID);
        View view = inflater.inflate(R.layout.row_balance_sheet, tableLayout, false);
        ((TextView) view.findViewById(R.id.account_name)).setText(name);
        TextView balanceTextView = ((TextView) view.findViewById(R.id.account_balance));
        TransactionsActivity.displayBalance(balanceTextView, balance);
        tableLayout.addView(view);
    }

    View totalView = inflater.inflate(R.layout.row_balance_sheet, tableLayout, false);
    TableLayout.LayoutParams layoutParams = (TableLayout.LayoutParams) totalView.getLayoutParams();
    layoutParams.setMargins(layoutParams.leftMargin, 20, layoutParams.rightMargin, layoutParams.bottomMargin);
    totalView.setLayoutParams(layoutParams);

    TextView accountName = (TextView) totalView.findViewById(R.id.account_name);
    accountName.setTextSize(16);
    accountName.setText(R.string.label_balance_sheet_total);
    TextView accountBalance = (TextView) totalView.findViewById(R.id.account_balance);
    accountBalance.setTextSize(16);
    accountBalance.setTypeface(null, Typeface.BOLD);
    TransactionsActivity.displayBalance(accountBalance,
            mAccountsDbAdapter.getAccountBalance(accountTypes, -1, System.currentTimeMillis()));

    tableLayout.addView(totalView);
}

From source file:com.google.android.gms.nearby.messages.samples.nearbybackgroundbeacons.BackgroundSubscribeIntentService.java

private String getContentText(List<String> messages) {
    String newline = System.getProperty("line.separator");
    if (messages.size() < NUM_MESSAGES_IN_NOTIFICATION) {
        return TextUtils.join(newline, messages);
    }/*from w w w  .j  a  v  a 2  s.  com*/
    return TextUtils.join(newline, messages.subList(0, NUM_MESSAGES_IN_NOTIFICATION)) + newline + "&#8230;";
}

From source file:org.fathens.cordova.googleplus.GooglePlusConnect.java

private void obtainToken() {
    final String scoping = String.format("oauth2:%s", TextUtils.join(" ", scopeUrls));
    Log.d(TAG, "Obtaining token by user(" + accountName + "): " + scoping);
    cordova.getThreadPool().execute(new Runnable() {
        @Override//w w w  .  j  a  v  a  2  s  .com
        public void run() {
            try {
                Log.d(TAG, "First try to get token");
                final String waste = GoogleAuthUtil.getToken(cordova.getActivity(), accountName, scoping);
                // TODO Check token if valid
                Log.d(TAG, "Clearing the token: " + waste);
                GoogleAuthUtil.clearToken(cordova.getActivity(), waste);
                final Bundle bundle = new Bundle();
                if (actions != null && actions.length > 0) {
                    final String actionString = TextUtils.join(" ", actions);
                    bundle.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, actionString);
                }
                Log.d(TAG, "SignIn with " + bundle);
                Log.d(TAG, "Second try to get token");
                final String token = GoogleAuthUtil.getToken(cordova.getActivity(), accountName, scoping,
                        bundle);
                Log.d(TAG, "Connected(" + accountName + "): " + token);
                final JSONObject result = new JSONObject().put("accountName", accountName).put("accessToken",
                        token);
                Log.d(TAG, "Callbacking result: " + result);
                currentCallback.success(result);
            } catch (UserRecoverableAuthException ex) {
                Log.e(TAG, "Recovering authorization", ex);
                cordova.startActivityForResult(GooglePlusConnect.this, ex.getIntent(), REQUEST_AUTH_RECOVER);
            } catch (IOException ex) {
                ex.printStackTrace();
                currentCallback.error(ex.getLocalizedMessage());
            } catch (GoogleAuthException ex) {
                ex.printStackTrace();
                if ("BadUsername".equals(ex.getMessage())) {
                    Log.e(TAG, "Invoked with BadUsername(" + accountName + "). re-select account...", ex);
                    accountName = null;
                    login();
                } else {
                    currentCallback.error(ex.getLocalizedMessage());
                }
            } catch (JSONException ex) {
                ex.printStackTrace();
                currentCallback.error(ex.getLocalizedMessage());
            }
        }
    });
}

From source file:paulscode.android.mupen64plusae.preference.MultiSelectListPreference.java

/**
 * Gets the selected entries as a concatenated string.
 * /*from   w ww.jav a  2 s  . co m*/
 * @return The selected entries as a string.
 */
public CharSequence getSelectedEntriesString() {
    return TextUtils.join(mSeparator, getSelectedEntries());
}

From source file:net.named_data.nfd.LogcatSettingsManager.java

/**
 * Generate a string representing all the tags to be filtered by logcat
 * and the relevant log levels.//from  w ww . j a va  2  s  .c  om
 *
 * An example of a string returned by this method is:
 *
 * <pre>
 *    NFDService:S Strategy:S TcpChannel:S TcpFactory:S TcpLocalFace:S UdpFactory:S *:S
 * </pre>
 *
 * @return String representation of the tags and their relevant log levels to be
 * filtered.
 */
public String getTags() {
    ArrayList<String> arr = new ArrayList<>();
    for (LogcatSettingItem item : m_logcatSettingItems) {
        arr.add(String.format("%s:%s", item.getLogTag(), getPriorityName(item.getLogLevel())));
    }

    // Sort and silence everything else by default
    Collections.sort(arr);
    arr.add("*:S");

    return TextUtils.join(" ", arr);
}

From source file:com.vaporwarecorp.mirror.component.configuration.WebServer.java

@Override
public Response serve(IHTTPSession session) {
    final String uri = session.getUri().substring(1);
    if (Method.GET.equals(session.getMethod()) && "proxy".equals(uri)) {
        return get(session.getParms().get("url"));
    } else if (NanoFileUpload.isMultipartContent(session)) {
        try {/*ww  w. j a  v  a 2s  .c o m*/
            List<FileItem> files = mUploader.parseRequest(session);
            if (files != null && files.size() > 0) {
                return newFixedLengthResponse(saveFileItemToDisk(files.get(0)));
            }
        } catch (FileUploadException e) {
            Timber.e(e, e.getMessage());
            return getInternalErrorResponse(e.getMessage());
        }
    } else if (Method.POST.equals(session.getMethod())) {
        for (Configuration configuration : mConfigurations) {
            if (configuration.getClass().getName().startsWith(uri)) {
                return updateConfiguration(session, configuration);
            }
        }
        return newFixedLengthResponse(null);
    } else if (uri.endsWith(".ico")) {
        return getNotFoundResponse();
    } else if (uri.endsWith(".js")) {
        String template = read("configuration/" + uri);
        if (uri.endsWith(JAVASCRIPT_APP)) {
            final List<String> modules = new LinkedList<>();
            for (Configuration configuration : mConfigurations) {
                final String jsonString = read(configuration.getJsonConfiguration());
                modules.add(new StringBuilder(jsonString)
                        .insert(jsonString.lastIndexOf('}'), MODEL_PLACEHOLDER + configuration.getJsonValues())
                        .toString());
            }
            template = template.replace(MODULES_PLACEHOLDER, TextUtils.join(",", modules));
        }
        return newFixedLengthResponse(OK, "application/javascript", template);
    } else if (uri.endsWith(".css")) {
        return newFixedLengthResponse(OK, "text/css", read("configuration/" + uri));
    }
    return newFixedLengthResponse(read("configuration/index.html"));
}

From source file:com.googlemapapp.GeofenceTransitionsIntentService.java

/**
 * Gets transition details and returns them as a formatted string.
 *
 * @param context             The app context.
 * @param geofenceTransition  The ID of the geofence transition.
 * @param triggeringGeofences The geofence(s) triggered.
 * @return The transition details formatted as String.
 *//*from   ww  w .j  a va  2s  .  c o m*/
private String getGeofenceTransitionDetails(Context context, int geofenceTransition,
        List<Geofence> triggeringGeofences) {

    String geofenceTransitionString = getTransitionString(geofenceTransition);

    // Get the Ids of each geofence that was triggered.
    ArrayList triggeringGeofencesIdsList = new ArrayList();
    for (Geofence geofence : triggeringGeofences) {
        triggeringGeofencesIdsList.add(geofence.getRequestId());
    }
    String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList);

    return geofenceTransitionString + " near by your " + triggeringGeofencesIdsString;
}

From source file:com.example.googlemaps.GeofenceTransitionsIntentService.java

/**
 * Gets transition details and returns them as a formatted string.
 *
 * @param context               The app context.
 * @param geofenceTransition    The ID of the geofence transition.
 * @param triggeringGeofences   The geofence(s) triggered.
 * @return                      The transition details formatted as String.
 */// ww w  . j a v  a  2s  .  c  om
private String getGeofenceTransitionDetails(Context context, int geofenceTransition,
        List<Geofence> triggeringGeofences) {

    String geofenceTransitionString = getTransitionString(geofenceTransition);

    // Get the Ids of each geofence that was triggered.
    ArrayList triggeringGeofencesIdsList = new ArrayList();
    for (Geofence geofence : triggeringGeofences) {
        triggeringGeofencesIdsList.add(geofence.getRequestId());
    }
    String triggeringGeofencesIdsString = TextUtils.join(", ", triggeringGeofencesIdsList);

    return triggeringGeofencesIdsString;
}