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:jen.jobs.application.UpdateJobSeeking.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int clickedItem = item.getItemId();
    if (clickedItem == R.id.save) {
        if (isOnline) {
            ArrayList<String> errors = new ArrayList<>();
            if (selectedJobSeekingStatusValues == null) {
                errors.add("Please select jobseeking status!");
            }//from   w  w w  . ja  v  a  2s.c  o  m

            if (selectedAvailability.length() == 0 && selectedAvailabilityUnit.length() == 0) {
                errors.add("Please select your notice period!");
            }

            if (selectedCountryValues == null) {
                errors.add("Please select the country!");
            } else {
                if (selectedCountryValues.id == 127) {
                    if (selectedMalaysiaStateValues == null) {
                        errors.add("Please select the state!");
                    }
                }
            }

            if (errors.size() == 0) {
                JSONObject obj = new JSONObject();

                // TODO - save to profile, local db
                ContentValues cv = new ContentValues();
                cv.put("js_jobseek_status_id", selectedJobSeekingStatusValues.id);
                cv.put("driving_license", cbLicense.isChecked() ? 1 : 0);
                cv.put("transport", cbTransport.isChecked() ? 1 : 0);
                cv.put("availability", selectedAvailability);
                cv.put("availability_unit", selectedAvailabilityUnit.substring(0, 1));
                tableProfile.updateProfile(cv, profileId);

                // TODO - save to address, add address to parameter
                ContentValues cv2 = new ContentValues();
                if (selectedMalaysiaStateValues != null) {
                    cv2.put("state_id", selectedMalaysiaStateValues.id);
                    cv2.put("state_name", selectedMalaysiaStateValues.name);
                } else {
                    cv2.put("state_id", 0);
                    cv2.put("state_name", "");
                }
                cv2.put("country_id", selectedCountryValues.id);
                cv2.put("updated_at", Jenjobs.date(null, "yyyy-MM-dd", null));
                tableAddress.updateAddress(cv2);

                // update POST data
                try {
                    obj.put("js_jobseek_status_id", cv.getAsString("js_jobseek_status_id"));
                    obj.put("driving_license", cv.getAsString("driving_license"));
                    obj.put("transport", cv.getAsString("transport"));
                    obj.put("availability", cv.getAsString("availability"));
                    obj.put("availability_unit", cv.getAsString("availability_unit"));

                    obj.put("state_id", cv.getAsString("state_id"));
                    obj.put("country_id", cv.getAsString("country_id"));
                } catch (JSONException e) {
                    Log.e("err", e.getMessage());
                }

                // TODO - change cv to ArrayList -> String, post to server
                String accessToken = sharedPref.getString("access_token", null);
                PostRequest p = new PostRequest();
                p.setResultListener(new PostRequest.ResultListener() {
                    @Override
                    public void processResult(JSONObject success) {
                        if (success != null) {
                            try {
                                success.get("status_code");
                            } catch (JSONException e) {
                                Log.e("test", e.getMessage());
                            }
                        }
                    }
                });

                String[] s = { Jenjobs.JOBSEEKING_INFO + "?access-token=" + accessToken, obj.toString() };
                p.execute(s);

                Intent intent = new Intent();
                intent.putExtra("summary", selectedJobSeekingStatusValues.name);
                setResult(Activity.RESULT_OK, intent);
                finish();
            } else {
                Toast.makeText(getApplicationContext(), TextUtils.join(", ", errors), Toast.LENGTH_LONG).show();
            }
        } else {
            Toast.makeText(getApplicationContext(), R.string.network_error, Toast.LENGTH_LONG).show();
        }
    }
    return true;
}

From source file:com.android.mail.ui.NestedFolderTeaserView.java

private void updateViews(final FolderHolder folderHolder) {
    final Folder folder = folderHolder.getFolder();

    // Update unread count
    final String unreadText = Utils.getUnreadCountString(getContext(), folder.unreadCount);
    folderHolder.getCountTextView().setText(unreadText.isEmpty() ? "0" : unreadText);

    // Update unread senders
    final String sendersText = TextUtils.join(getResources().getString(R.string.enumeration_comma),
            folderHolder.getUnreadSenders());
    final TextView sendersTextView = folderHolder.getSendersTextView();
    if (!TextUtils.isEmpty(sendersText)) {
        sendersTextView.setVisibility(VISIBLE);
        sendersTextView.setText(sendersText);
    } else {/* w  w w. j  a  va 2s .  co  m*/
        sendersTextView.setVisibility(GONE);
    }
}

From source file:com.facebook.samples.hellofacebook.MainActivity.java

private void onFriendPickerDone(FriendPickerFragment fragment) {
    FragmentManager fm = getSupportFragmentManager();
    fm.popBackStack();//from w  w  w . jav a  2  s .co  m

    String results = "";

    Collection<GraphUser> selection = fragment.getSelection();
    if (selection != null && selection.size() > 0) {
        ArrayList<String> names = new ArrayList<String>();
        for (GraphUser user : selection) {
            names.add(user.getName());
        }
        results = TextUtils.join(", ", names);
    } else {
        results = getString(R.string.no_friends_selected);
    }

    showAlert(getString(R.string.you_picked), results);
}

From source file:com.ds.kaixin.Kaixin.java

/**
 * accessTokenaccessToken// w w  w . j av  a  2s. c o m
 * 
 * @param context
 * 
 * @param permissions
 *            ?http://wiki.open.kaixin001.com/index.php?id=OAuth%E6%
 *            96% 87%E6%A1%A3#REST%E6%
 *            8E%A5%E5%8F%A3%E5%92%8COAuth%E6%9D%83%E9%99%90%E5%AF%B9%E7%85%
 *            A 7%E8%A1%A8
 * 
 * @return JSON
 * @throws FileNotFoundException
 * @throws MalformedURLException
 * @throws IOException
 */
public String refreshAccessToken(Context context, String[] permissions)
        throws FileNotFoundException, MalformedURLException, IOException {

    mAccessToken = null;
    if (mRefreshToken == null) {
        return null;
    }

    Bundle params = new Bundle();
    params.putString("grant_type", REFRESH_TOKEN);
    params.putString("refresh_token", mRefreshToken);
    params.putString("client_id", API_KEY);
    params.putString("client_secret", SECRET_KEY);
    if (permissions != null && permissions.length > 0) {
        String scope = TextUtils.join(" ", permissions);
        params.putString("scope", scope);
    }

    return Util.openUrl(context, KX_REFRESHTOKEN_URL, "GET", params, null);
}

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

/**
 * Create and return Trash view/*ww w . j  av  a  2 s . c  o m*/
 *
 * @param trashPoint
 * @return
 */
private View getTrashView(TrashPoint trashPoint) {
    View eventTrashView = inflater.inflate(R.layout.layout_event_trash, null);

    TextView eventTrashDate = eventTrashView.findViewById(R.id.event_trash_date);
    TextView eventTrashTypes = eventTrashView.findViewById(R.id.event_trash_types);
    TextView eventTrashLocation = eventTrashView.findViewById(R.id.event_trash_location);
    ImageView eventTrashImage = eventTrashView.findViewById(R.id.event_trash_image);
    ImageView eventTrashStatusIcon = eventTrashView.findViewById(R.id.event_trash_status_icon);

    eventTrashLocation
            .setText(
                    String.format(getContext().getString(R.string.distance_away_formatter),
                            lastPosition != null ? PositionUtils.getFormattedComputeDistance(getContext(),
                                    lastPosition, trashPoint.getPosition()) : "?",
                            getString(R.string.global_distanceAttribute_away)));

    if (trashPoint.getLastChangeDate() != null)
        eventTrashDate.setText(DateTimeUtils.getRoundedTimeAgo(getContext(), trashPoint.getLastChangeDate()));

    eventTrashTypes.setText(TextUtils.join(", ",
            Constants.TrashType.getTrashTypeNameList(getContext(), trashPoint.getTypes())));

    eventTrashStatusIcon.setImageResource(trashPoint.getStatus().getIconResId());

    if (trashPoint.getImages() != null && !trashPoint.getImages().isEmpty()
            && !TextUtils.isEmpty(trashPoint.getImages().get(0).getSmallestImage())) {
        StorageReference mImageRef = FirebaseStorage.getInstance()
                .getReferenceFromUrl(trashPoint.getImages().get(0).getSmallestImage());
        GlideApp.with(getContext()).load(mImageRef).centerCrop()
                .placeholder(R.drawable.ic_image_placeholder_square).into(eventTrashImage);
    } else {
        eventTrashImage.setImageResource(R.drawable.ic_image_placeholder_square);
    }

    return eventTrashView;
}

From source file:com.chen.mail.ui.NestedFolderTeaserView.java

private void updateViews(final FolderHolder folderHolder) {
    final Folder folder = folderHolder.getFolder();

    final String unreadText = Utils.getUnreadCountString(getContext(), folder.unreadCount);
    folderHolder.getCountTextView().setText(unreadText.isEmpty() ? "0" : unreadText);

    final String sendersText = TextUtils.join(", ", folderHolder.getUnreadSenders());
    folderHolder.getSendersTextView().setText(sendersText);
}

From source file:com.csipsimple.ui.calllog.CallLogListFragment.java

private void actionModeDelete() {
    ListView lv = getListView();/*from  w ww.  j a  va2  s  . co  m*/

    ArrayList<Long> checkedIds = new ArrayList<Long>();

    for (int i = 0; i < lv.getCount(); i++) {
        if (lv.isItemChecked(i)) {
            long[] selectedIds = mAdapter.getCallIdsAtPosition(i);

            for (long id : selectedIds) {
                checkedIds.add(id);
            }

        }
    }
    if (checkedIds.size() > 0) {
        String strCheckedIds = TextUtils.join(", ", checkedIds);
        Log.d(THIS_FILE, "Checked positions (" + strCheckedIds + ")");
        getActivity().getContentResolver().delete(SipManager.CALLLOG_URI,
                CallLog.Calls._ID + " IN (" + strCheckedIds + ")", null);
        mMode.finish();
    }
}

From source file:com.morestudio.littledot.doctor.ui.calllog.CallLogListFragment.java

private void actionModeDelete() {
    ListView lv = getListView();// w  w w .j a v a 2  s . c o  m

    ArrayList<Long> checkedIds = new ArrayList<Long>();

    for (int i = 0; i < lv.getCount(); i++) {
        if (lv.isItemChecked(i)) {
            long[] selectedIds = mAdapter.getCallIdsAtPosition(i);

            for (long id : selectedIds) {
                checkedIds.add(id);
            }

        }
    }
    if (checkedIds.size() > 0) {
        String strCheckedIds = TextUtils.join(", ", checkedIds);
        Log.d(THIS_FILE, "Checked positions (" + strCheckedIds + ")");
        getActivity().getContentResolver().delete(SipManager.CALLLOG_URI,
                Calls._ID + " IN (" + strCheckedIds + ")", null);
        mMode.finish();
    }
}

From source file:ms.android.facebookSDK.Facebook.java

/**
 * Internal method to handle dialog-based authentication backend for
 * authorize()./* ww  w  .  j a  v  a2 s .c o  m*/
 * 
 * @param activity
 *            The Android Activity that will parent the auth dialog.
 * @param applicationId
 *            The Facebook application identifier.
 * @param permissions
 *            A list of permissions required for this application. If you do
 *            not require any permissions, pass an empty String array.
 */
private void startDialogAuth(final Activity activity, String[] permissions) {
    Bundle params = new Bundle();
    if (permissions.length > 0) {
        params.putString("scope", TextUtils.join(",", permissions));
    }
    CookieSyncManager.createInstance(activity);
    dialog(activity, LOGIN, params, new DialogListener() {

        public void onComplete(Bundle values) {
            // ensure any cookies set by the dialog are saved
            CookieSyncManager.getInstance().sync();
            setAccessToken(values.getString(TOKEN));
            setAccessExpiresIn(values.getString(EXPIRES));
            if (isSessionValid()) {
                Util.logd("Facebook-authorize",
                        "Login Success! access_token=" + getAccessToken() + " expires=" + getAccessExpires());
                mAuthDialogListener.onComplete(values);

                try {
                    String jsonUser = request("me");
                    /*   JSONObject obj = null;
                       try {
                          obj = Util.parseJson(jsonUser);
                       } catch (FacebookError e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                       }
                       */

                } catch (Exception e) {
                    e.printStackTrace();
                }

            } else {
                mAuthDialogListener.onFacebookError(new FacebookError("Failed to receive access token."));
            }
        }

        public void onError(DialogError error) {
            Util.logd("Facebook-authorize", "Login failed: " + error);
            mAuthDialogListener.onError(error);
        }

        public void onFacebookError(FacebookError error) {
            Util.logd("Facebook-authorize", "Login failed: " + error);
            mAuthDialogListener.onFacebookError(error);
        }

        public void onCancel() {
            Util.logd("Facebook-authorize", "Login canceled");
            mAuthDialogListener.onCancel();
        }
    });
}

From source file:com.example.nitish.welcomapp.activitypt.ElementDetailsFragment.java

/**
 * Get the electrons per shell.//  w  w  w .jav a  2 s  .co  m
 */
private void getElectrons() {
    mTxtElectrons.setText(TextUtils.join(", ", mElement.electrons));
    mTxtElementElectrons.setText(TextUtils.join("\n", mElement.electrons));
}