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:org.quizpoll.net.AppEngineHelper.java

/**
 * Create polling submit request/*from w  ww  .  j  av  a 2s  .c  o m*/
 */
private String createPollSubmitRequest(Poll poll) {
    Question question = poll.getQuestions().get(poll.getCurrentQuestion());
    List<String> answeredAnswers = new ArrayList<String>();
    for (Answer answer : question.getAnswers()) {
        if (answer.isAnswered()) {
            answeredAnswers.add(String.valueOf(answer.getNumber() + 1));
        }
    }
    String answers = TextUtils.join(",", answeredAnswers);
    PollResponse response = new PollResponse(poll.getDocumentId(), poll.getResponsesSheet(),
            question.isAnonymous(), poll.getCurrentQuestion() + 1, answers, question.isSuccess());
    return getGson().toJson(response);
}

From source file:me.trashout.fragment.CollectionPointDetailFragment.java

/**
 * setup collection point data//  ww w. ja v a  2s  .co m
 *
 * @param collectionPoint
 */
private void setupCollectionPointData(CollectionPoint collectionPoint) {
    if (isAdded()) {
        collectionPointDetailName
                .setText(collectionPoint.getSize().equals(Constants.CollectionPointSize.DUSTBIN)
                        ? getString(Constants.CollectionPointSize.DUSTBIN.getStringResId())
                        : collectionPoint.getName());

        collectionPointDetailType.setText(Html.fromHtml(
                getString(R.string.recyclable_gray, getString(R.string.collectionPoint_detail_mobile_recycable))
                        + TextUtils.join(", ", Constants.CollectionPointType
                                .getCollectionPointTypeNameList(getContext(), collectionPoint.getTypes()))));
        collectionPointDetailDistance
                .setText(String.format(getString(R.string.distance_away_formatter),
                        lastPosition != null ? PositionUtils.getFormattedComputeDistance(getContext(),
                                lastPosition, collectionPoint.getPosition()) : "?",
                        getString(R.string.global_distanceAttribute_away)));
        collectionPointDetailPosition
                .setText(collectionPoint.getPosition() != null
                        ? PositionUtils.getFormattedLocation(getContext(),
                                collectionPoint.getPosition().latitude, collectionPoint.getPosition().longitude)
                        : "?");

        if (collectionPoint.getOpeningHours() == null || collectionPoint.getOpeningHours().isEmpty()) {
            collectionPointDetailOpeningHoursContainer.setVisibility(View.GONE);
            collectionPointDetailOpeningHours.setVisibility(View.GONE);
        } else {
            collectionPointDetailOpeningHoursContainer.setVisibility(View.VISIBLE);
            collectionPointDetailOpeningHoursContainer.removeAllViews();
            collectionPointDetailOpeningHours.setVisibility(View.VISIBLE);
            for (Map<String, List<OpeningHour>> openingHoursMap : collectionPoint.getOpeningHours()) {
                for (Map.Entry<String, List<OpeningHour>> openingHourEntry : openingHoursMap.entrySet()) {
                    LinearLayout openingHoursLayout = (LinearLayout) getLayoutInflater()
                            .inflate(R.layout.item_opening_hours, null);
                    TextView dayNameTextView = openingHoursLayout.findViewById(R.id.txt_day_name);
                    TextView openingHoursTextView = openingHoursLayout.findViewById(R.id.txt_opening_hours);

                    int dayNameResId;
                    switch (openingHourEntry.getKey()) {
                    case "Monday":
                        dayNameResId = R.string.global_days_Monday;
                        break;
                    case "Tuesday":
                        dayNameResId = R.string.global_days_Tuesday;
                        break;
                    case "Wednesday":
                        dayNameResId = R.string.global_days_Wednesday;
                        break;
                    case "Thursday":
                        dayNameResId = R.string.global_days_Thursday;
                        break;
                    case "Friday":
                        dayNameResId = R.string.global_days_Friday;
                        break;
                    case "Saturday":
                        dayNameResId = R.string.global_days_Saturday;
                        break;
                    case "Sunday":
                        dayNameResId = R.string.global_days_Sunday;
                        break;
                    default:
                        dayNameResId = R.string.global_days_Monday;
                    }

                    dayNameTextView.setText(getString(dayNameResId));
                    for (OpeningHour openingHour : openingHourEntry.getValue()) {
                        String startString = String.valueOf(openingHour.getStart());
                        String finishString = String.valueOf(openingHour.getFinish());
                        if (startString.length() == 3) {
                            startString = "0" + startString;
                        }
                        if (finishString.length() == 3) {
                            finishString = "0" + finishString;
                        }
                        openingHoursTextView.append(startString.substring(0, 2) + ":"
                                + startString.substring(2, startString.length()) + " - "
                                + finishString.substring(0, 2) + ":"
                                + finishString.substring(2, finishString.length()) + ", ");
                    }
                    if (openingHourEntry.getValue().size() > 0) {
                        openingHoursTextView.setText(openingHoursTextView.getText().toString().substring(0,
                                openingHoursTextView.getText().length() - 2));
                    }
                    collectionPointDetailOpeningHoursContainer.addView(openingHoursLayout);
                }
            }
        }
        collectionPointDetailNote.setText(collectionPoint.getNote());

        if (collectionPoint.getPhone() == null || collectionPoint.getPhone().isEmpty()) {
            collectionPointDetailPhoneLayout.setVisibility(View.GONE);
        } else {
            collectionPointDetailPhoneLayout.setVisibility(View.VISIBLE);
            collectionPointDetailPhone.setText(collectionPoint.getPhone());
        }
        if (collectionPoint.getEmail() == null || collectionPoint.getEmail().isEmpty()) {
            collectionPointDetailEmailLayout.setVisibility(View.GONE);
        } else {
            collectionPointDetailEmailLayout.setVisibility(View.VISIBLE);
            collectionPointDetailEmail.setText(collectionPoint.getEmail());
        }

        if (collectionPoint.getGps() != null && collectionPoint.getGps().getArea() != null
                && !TextUtils.isEmpty(collectionPoint.getGps().getArea().getFormatedLocation())) {
            collectionPointDetailPlace.setText(collectionPoint.getGps().getArea().getFormatedLocation());
        } else {
            Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault());
            new GeocoderTask(geocoder, collectionPoint.getGps().getLat(), collectionPoint.getGps().getLng(),
                    new GeocoderTask.Callback() {
                        @Override
                        public void onAddressComplete(GeocoderTask.GeocoderResult geocoderResult) {
                            if (!TextUtils.isEmpty(geocoderResult.getFormattedAddress())) {
                                collectionPointDetailPlace.setText(geocoderResult.getFormattedAddress());
                            } else {
                                collectionPointDetailPlace.setVisibility(View.GONE);
                            }
                        }
                    }).execute();
        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    Util.setTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.logging);//ww  w. j ava  2  s.co  m
    running = true;

    // Action bar
    View actionView = getLayoutInflater().inflate(R.layout.actionlog, null, false);
    SwitchCompat swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled);

    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setCustomView(actionView);

    getSupportActionBar().setTitle(R.string.menu_log);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Get settings
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    resolve = prefs.getBoolean("resolve", false);
    organization = prefs.getBoolean("organization", false);
    boolean log = prefs.getBoolean("log", false);

    // Show disabled message
    TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled);
    tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE);

    // Set enabled switch
    swEnabled.setChecked(log);
    swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            prefs.edit().putBoolean("log", isChecked).apply();
        }
    });

    // Listen for preference changes
    prefs.registerOnSharedPreferenceChangeListener(this);

    lvLog = (ListView) findViewById(R.id.lvLog);

    boolean udp = prefs.getBoolean("proto_udp", true);
    boolean tcp = prefs.getBoolean("proto_tcp", true);
    boolean other = prefs.getBoolean("proto_other", true);
    boolean allowed = prefs.getBoolean("traffic_allowed", true);
    boolean blocked = prefs.getBoolean("traffic_blocked", true);

    // -- the adapter holds rows of data entries -> AdapterLog class
    adapter = new AdapterLog(this, DatabaseHelper.getInstance(this).getLog(udp, tcp, other, allowed, blocked),
            resolve, organization);
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return DatabaseHelper.getInstance(ActivityLog.this).searchLog(constraint.toString());
        }
    });

    lvLog.setAdapter(adapter);

    try {
        vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1"));
        vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1"));
    } catch (UnknownHostException ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }

    // -- when clicking the log items
    lvLog.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            PackageManager pm = getPackageManager();
            Cursor cursor = (Cursor) adapter.getItem(position);
            long time = cursor.getLong(cursor.getColumnIndex("time"));
            int version = cursor.getInt(cursor.getColumnIndex("version"));
            int protocol = cursor.getInt(cursor.getColumnIndex("protocol"));
            final String saddr = cursor.getString(cursor.getColumnIndex("saddr"));
            final int sport = (cursor.isNull(cursor.getColumnIndex("sport")) ? -1
                    : cursor.getInt(cursor.getColumnIndex("sport")));
            final String daddr = cursor.getString(cursor.getColumnIndex("daddr"));
            final int dport = (cursor.isNull(cursor.getColumnIndex("dport")) ? -1
                    : cursor.getInt(cursor.getColumnIndex("dport")));
            final String dname = cursor.getString(cursor.getColumnIndex("dname"));
            final int uid = (cursor.isNull(cursor.getColumnIndex("uid")) ? -1
                    : cursor.getInt(cursor.getColumnIndex("uid")));
            int allowed = (cursor.isNull(cursor.getColumnIndex("allowed")) ? -1
                    : cursor.getInt(cursor.getColumnIndex("allowed")));

            // Get external address
            InetAddress addr = null;
            try {
                addr = InetAddress.getByName(daddr);
            } catch (UnknownHostException ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            }

            String ip;
            int port;
            if (addr.equals(vpn4) || addr.equals(vpn6)) {
                ip = saddr;
                port = sport;
            } else {
                ip = daddr;
                port = dport;
            }

            // Build popup menu
            PopupMenu popup = new PopupMenu(ActivityLog.this, findViewById(R.id.vwPopupAnchor));
            popup.inflate(R.menu.log);

            // Application name
            if (uid >= 0)
                popup.getMenu().findItem(R.id.menu_application)
                        .setTitle(TextUtils.join(", ", Util.getApplicationNames(uid, ActivityLog.this)));
            else
                popup.getMenu().removeItem(R.id.menu_application);

            // Destination IP
            popup.getMenu().findItem(R.id.menu_protocol)
                    .setTitle(Util.getProtocolName(protocol, version, false));

            // Whois
            final Intent lookupIP = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://www.tcpiputils.com/whois-lookup/" + ip));
            if (pm.resolveActivity(lookupIP, 0) == null)
                popup.getMenu().removeItem(R.id.menu_whois);
            else
                popup.getMenu().findItem(R.id.menu_whois).setTitle(getString(R.string.title_log_whois, ip));

            // Lookup port
            final Intent lookupPort = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://www.speedguide.net/port.php?port=" + port));
            if (port <= 0 || pm.resolveActivity(lookupPort, 0) == null)
                popup.getMenu().removeItem(R.id.menu_port);
            else
                popup.getMenu().findItem(R.id.menu_port).setTitle(getString(R.string.title_log_port, port));

            if (!prefs.getBoolean("filter", false)) {
                popup.getMenu().removeItem(R.id.menu_allow);
                popup.getMenu().removeItem(R.id.menu_block);
            }

            final Packet packet = new Packet();
            packet.version = version;
            packet.protocol = protocol;
            packet.daddr = daddr;
            packet.dport = dport;
            packet.time = time;
            packet.uid = uid;
            packet.allowed = (allowed > 0);

            // Time
            popup.getMenu().findItem(R.id.menu_time)
                    .setTitle(SimpleDateFormat.getDateTimeInstance().format(time));

            // Handle click
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                    case R.id.menu_application: {
                        Intent main = new Intent(ActivityLog.this, MainActivity.class);
                        main.putExtra(MainActivity.EXTRA_SEARCH, Integer.toString(uid));
                        startActivity(main);
                        return true;
                    }

                    case R.id.menu_whois:
                        startActivity(lookupIP);
                        return true;

                    case R.id.menu_port:
                        startActivity(lookupPort);
                        return true;

                    case R.id.menu_allow:
                        if (true) {
                            DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 0);
                            ServiceSinkhole.reload("allow host", ActivityLog.this);
                            Intent main = new Intent(ActivityLog.this, MainActivity.class);
                            main.putExtra(MainActivity.EXTRA_SEARCH, Integer.toString(uid));
                            startActivity(main);
                        }

                        return true;

                    case R.id.menu_block:
                        if (true) {
                            DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 1);
                            ServiceSinkhole.reload("block host", ActivityLog.this);
                            Intent main = new Intent(ActivityLog.this, MainActivity.class);
                            main.putExtra(MainActivity.EXTRA_SEARCH, Integer.toString(uid));
                            startActivity(main);
                        }
                        return true;

                    default:
                        return false;
                    }
                }
            });

            // Show
            popup.show();
        }
    });

    live = true;
}

From source file:com.adkdevelopment.e_contact.ui.presenters.ProfilePresenter.java

/**
 * Retrieves profile photos and saves the profile and photos
 * to the database/*  w w  w.  ja  v a  2 s. c  o  m*/
 * Updates View on completion
 * @param profileRealm for which photos are required
 */
private void getPhotos(final ProfileRealm profileRealm) {
    GraphRequest request = new GraphRequest(mAccessToken, "/" + profileRealm.getId() + PARAM_PHOTOS, null,
            HttpMethod.GET, new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                    RealmList<ProfilePhotosRealm> photosRealms = new RealmList<>();

                    try {
                        JSONArray photos = response.getJSONObject().getJSONArray(RESP_DATA);
                        for (int i = 0, n = photos.length(); i < n; i++) {
                            ProfilePhotosRealm photoRealm = new ProfilePhotosRealm();
                            JSONObject object = photos.getJSONObject(i);

                            String id = object.getString(RESP_ID);

                            if (object.has(RESP_NAME)) {
                                String description = object.getString(RESP_NAME);
                                photoRealm.setDescription(description);
                            }

                            if (object.has(RESP_CREATED)) {
                                String createdTime = object.getString(RESP_CREATED);
                                photoRealm.setCreatedTime(createdTime);
                            }

                            if (object.has(RESP_IMAGE)) {
                                String link = object.getJSONArray(RESP_IMAGE).getJSONObject(0)
                                        .getString(RESP_SOURCE);
                                photoRealm.setUrl(link);
                            }

                            photoRealm.setId(id);
                            photosRealms.add(photoRealm);
                        }
                    } catch (JSONException e) {
                        Log.e(TAG, "Error: " + e);
                    }

                    profileRealm.setPhotos(photosRealms);

                    getMvpView().showData(profileRealm);

                    // add to the database and confirm that is was successfully
                    // added to the db while debugging
                    mSubscription
                            .add(mDataManager.saveProfile(profileRealm).subscribe(new Subscriber<Boolean>() {
                                @Override
                                public void onCompleted() {
                                    Log.d(TAG, "onCompleted: ");
                                }

                                @Override
                                public void onError(Throwable e) {
                                    Log.e(TAG, "Error: " + e);
                                }

                                @Override
                                public void onNext(Boolean aBoolean) {
                                    Log.d(TAG, "onNext: " + aBoolean);
                                }
                            }));
                }
            });

    Bundle parameters = new Bundle();
    parameters.putString(PARAM_FIELDS, TextUtils.join(",",
            new String[] { RESP_ID, RESP_NAME, RESP_LINK, RESP_URL, RESP_PICTURE, RESP_IMAGE }));
    request.setParameters(parameters);
    request.executeAsync();
}

From source file:com.androidquery.simplefeed.activity.PostActivity.java

private void putTags(Map<String, Object> params, List<Entity> tags) {

    if (tags == null || tags.size() == 0)
        return;/*  w w w  .  j a  va2 s.  com*/

    List<String> ids = new ArrayList<String>();

    for (Entity tag : tags) {

        ids.add(tag.getId());

    }

    String value = TextUtils.join(",", ids);

    AQUtility.debug("tags", value);
    params.put("tags", value);

}

From source file:ru.gkpromtech.exhibition.events.EventsActivity.java

@Override
public void onFavoriteChanged(int pageNumber, final int eventId, int state) {
    EventReader.getInstance(this).updateFavorite(eventId, state, SQLiteDatabase.CONFLICT_REPLACE);

    final int eventid = eventId;
    final Context context = this;
    Event e = EventReader.getInstance(this).findItem(eventId);
    if (e != null) {

        EventCalendar cal = EventCalendar.getInstance(this);
        cal.setEventCalendarInteractionListener(new EventCalendar.EventCalendarInteraction() {
            @Override//  w  ww  .  java2  s .  com
            public void eventInserted(int calEventId) {
                EventReader.getInstance(context).updateCalendarEvent(eventid, calEventId,
                        SQLiteDatabase.CONFLICT_REPLACE);
                AnalyticsManager.sendEvent(EventsActivity.this, R.string.events_category,
                        R.string.action_favorite_add, eventId);
            }

            @Override
            public void eventRemoved(int calEventId) {
                EventReader.getInstance(context).updateCalendarEvent(eventid, -1,
                        SQLiteDatabase.CONFLICT_REPLACE);
                AnalyticsManager.sendEvent(EventsActivity.this, R.string.events_category,
                        R.string.action_favorite_removed, eventId);
            }
        });

        // add to calendar
        if (state == 1) {
            // get places for event
            List<Place> places = EventReader.getInstance(this).getPlaces(eventId);
            String[] sPlaces = new String[places.size()];
            for (int i = 0; i < places.size(); i++) {
                sPlaces[i] = places.get(i).name;
            }

            EventCalendar.getInstance(this).insertEventToCalendar(e.header, e.details,
                    TextUtils.join(", ", sPlaces), e.date, true);
        }
        // remove from calendar
        else {
            EventFavorite fav = EventReader.getInstance(this).getEventFavorite(eventId);
            if (fav.calendarEventId != null) {
                EventCalendar.getInstance(this).removeEventFromCalendar(fav.calendarEventId);
            }
        }
    }
}

From source file:com.ichi2.anki.dialogs.CustomStudyDialog.java

/**
 * Build a context menu for custom study
 * @param id//from ww  w .java2 s . c o  m
 * @return
 */
private MaterialDialog buildContextMenu(int id) {
    int[] listIds = getListIds(id);
    final boolean jumpToReviewer = getArguments().getBoolean("jumpToReviewer");
    return new MaterialDialog.Builder(this.getActivity()).title(R.string.custom_study).cancelable(true)
            .itemsIds(listIds).items(ContextMenuHelper.getValuesFromKeys(getKeyValueMap(), listIds))
            .itemsCallback(new MaterialDialog.ListCallback() {
                @Override
                public void onSelection(MaterialDialog materialDialog, View view, int which,
                        CharSequence charSequence) {
                    AnkiActivity activity = (AnkiActivity) getActivity();
                    switch (view.getId()) {
                    case DECK_OPTIONS: {
                        // User asked to permanently change the deck options
                        Intent i = new Intent(activity, DeckOptions.class);
                        i.putExtra("did", getArguments().getLong("did"));
                        getActivity().startActivity(i);
                        break;
                    }
                    case MORE_OPTIONS: {
                        // User asked to see all custom study options
                        CustomStudyDialog d = CustomStudyDialog.newInstance(CONTEXT_MENU_STANDARD,
                                getArguments().getLong("did"), jumpToReviewer);
                        activity.showDialogFragment(d);
                        break;
                    }
                    case CUSTOM_STUDY_TAGS: {
                        /*
                         * This is a special Dialog for CUSTOM STUDY, where instead of only collecting a
                         * number, it is necessary to collect a list of tags. This case handles the creation
                         * of that Dialog.
                         */
                        long currentDeck = getArguments().getLong("did");
                        TagsDialog dialogFragment = TagsDialog.newInstance(TagsDialog.TYPE_CUSTOM_STUDY_TAGS,
                                new ArrayList<String>(),
                                new ArrayList<>(activity.getCol().getTags().byDeck(currentDeck, true)));
                        dialogFragment.setTagsDialogListener(new TagsDialog.TagsDialogListener() {
                            @Override
                            public void onPositive(List<String> selectedTags, int option) {
                                /*
                                 * Here's the method that gathers the final selection of tags, type of cards and
                                 * generates the search screen for the custom study deck.
                                 */
                                StringBuilder sb = new StringBuilder();
                                switch (option) {
                                case 1:
                                    sb.append("is:new ");
                                    break;
                                case 2:
                                    sb.append("is:due ");
                                    break;
                                default:
                                    // Logging here might be appropriate : )
                                    break;
                                }
                                List<String> arr = new ArrayList<>();
                                if (selectedTags.size() > 0) {
                                    for (String tag : selectedTags) {
                                        arr.add(String.format("tag:'%s'", tag));
                                    }
                                    sb.append("(").append(TextUtils.join(" or ", arr)).append(")");
                                }
                                createCustomStudySession(new JSONArray(),
                                        new Object[] { sb.toString(), Consts.DYN_MAX_SIZE, Consts.DYN_RANDOM },
                                        false);
                            }
                        });
                        activity.showDialogFragment(dialogFragment);
                        break;
                    }
                    default: {
                        // User asked for a standard custom study option
                        CustomStudyDialog d = CustomStudyDialog.newInstance(view.getId(),
                                getArguments().getLong("did"), jumpToReviewer);
                        ((AnkiActivity) getActivity()).showDialogFragment(d);
                    }
                    }
                }
            }).build();
}

From source file:org.jboss.aerogear.android.pipe.http.HttpRestProvider.java

private HeaderAndBody getHeaderAndBody(HttpURLConnection urlConnection) throws IOException {

    int statusCode = urlConnection.getResponseCode();
    HeaderAndBody result;/*  w  w w  .j  a  va 2s. c  o m*/
    Map<String, List<String>> headers;
    byte[] responseData;

    switch (statusCode) {
    case HttpStatus.SC_OK:
    case HttpStatus.SC_CREATED:
        InputStream in = new BufferedInputStream(urlConnection.getInputStream());

        responseData = readBytes(in);

        break;

    case HttpStatus.SC_NO_CONTENT:
        responseData = new byte[0];

        break;

    default:
        InputStream err = new BufferedInputStream(urlConnection.getErrorStream());

        byte[] errData = readBytes(err);
        Map<String, List<String>> errorListHeaders = urlConnection.getHeaderFields();
        Map<String, String> errorHeaders = new HashMap<String, String>();

        for (String header : errorListHeaders.keySet()) {

            String comma = "";
            StringBuilder errorHeaderBuilder = new StringBuilder();

            for (String errorHeader : errorListHeaders.get(header)) {
                errorHeaderBuilder.append(comma).append(errorHeader);
                comma = ",";
            }

            errorHeaders.put(header, errorHeaderBuilder.toString());

        }

        throw new HttpException(errData, statusCode, errorHeaders);

    }

    headers = urlConnection.getHeaderFields();
    result = new HeaderAndBody(responseData, new HashMap<String, Object>(headers.size()));

    for (Map.Entry<String, List<String>> header : headers.entrySet()) {
        result.setHeader(header.getKey(), TextUtils.join(",", header.getValue()));
    }

    return result;

}

From source file:com.secupwn.aimsicd.ui.fragments.CellInfoFragment.java

void updateNeighboringCells() {
    final List<String> list = rilExecutor.getNeighbors();
    getActivity().runOnUiThread(new Runnable() {
        @Override// w  w w.j a v  a  2  s.c om
        public void run() {
            if (list != null) {
                mNeighboringCells.setText(TextUtils.join("\n", list));
                mNeighboringCells.setVisibility(View.VISIBLE);
                mNeighboringTotalView.setVisibility(View.GONE);
            }
        }
    });
}

From source file:comp3111h.anytaxi.driver.Register_FormFragment.java

private String licenseBeautifier(String license) {
    String[] partialLicense = TextUtils.split(license.trim().toUpperCase(Locale.getDefault()), " +");

    license = TextUtils.join(" ", partialLicense);

    return license;
}