private String updateSortKey(String s) {
   // 汉字转换成拼音
   String pinyin = characterParser.getSelling(TextUtil.processNullString(s));
   //        LogUtils.e("userName: "******", pinyin: " + pinyin);
   String sortString;
   if (pinyin != null && pinyin.length() > 0) {
     sortString = pinyin.substring(0, 1).toUpperCase();
   } else {
     sortString = "#";
   }
   return sortString;
 }
Example #2
0
  private void updateSortKey(FriendInfo friendInfo) {
    // 汉字转换成拼音
    String pinyin =
        characterParser.getSelling(TextUtil.processNullString(friendInfo.getUserName()));
    //        LogUtils.e("userName: "******", pinyin: " + pinyin);
    String sortString;
    if (pinyin != null && pinyin.length() > 0) {
      sortString = pinyin.substring(0, 1).toUpperCase();
    } else {
      sortString = "#";
    }

    // 正则表达式,判断首字母是否是英文字母
    if (sortString.matches("[A-Z]")) {
      friendInfo.setSortKey(sortString.toUpperCase());
    } else {
      friendInfo.setSortKey("#");
    }
  }
Example #3
0
 public Friends() {
   characterParser = CharacterParser.getInstance();
 }