@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_tick: // create group. String groupName = edtName.getText().toString().trim(); if (Helper.isEmpty(groupName)) { Toast.makeText(getActivity(), "Please input the group name.", Toast.LENGTH_SHORT).show(); return false; } String inviteUsers = clientId; for (int i = 0; i < mSourceDataList.size(); i++) { if (mSourceDataList.get(i).getIsSelected()) { if (Helper.isEmpty(inviteUsers)) { inviteUsers = mSourceDataList.get(i).getFriend_userId(); } else { inviteUsers += "," + mSourceDataList.get(i).getFriend_userId(); } mSourceDataList.get(i).setIsSelected(false); } } if (Helper.isEmpty(inviteUsers)) { Toast.makeText(getActivity(), "Please select one friend at least.", Toast.LENGTH_SHORT) .show(); return false; } BroadcastManager.sendCreateGroupMessage(getActivity(), groupName, "", inviteUsers); dialog.show(); return true; case android.R.id.home: Helper.simulateKey(KeyEvent.KEYCODE_BACK); return true; default: return super.onOptionsItemSelected(item); } }
private void filledData() { for (int i = 0; i < mSourceDataList.size(); i++) { String pinyin = Helper.converterToPinYin(mSourceDataList.get(i).getName()); String sortString = pinyin.substring(0, 1).toUpperCase(); if (sortString.matches("[A-Z]")) { mSourceDataList.get(i).setSortLetters(sortString.toUpperCase()); } else { mSourceDataList.get(i).setSortLetters("#"); } } Collections.sort(mSourceDataList); }