当前位置: 首页>>代码示例>>Java>>正文


Java Pinyin类代码示例

本文整理汇总了Java中com.github.promeg.pinyinhelper.Pinyin的典型用法代码示例。如果您正苦于以下问题:Java Pinyin类的具体用法?Java Pinyin怎么用?Java Pinyin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Pinyin类属于com.github.promeg.pinyinhelper包,在下文中一共展示了Pinyin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toPinyin_test_not_same_with_PinyinOrigin

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
@Test
public void toPinyin_test_not_same_with_PinyinOrigin() throws Exception {
    Set<String> words = mDict.mapping().keySet();
    for (String word : words) {

        String[] originPinyins = new String[word.length()];

        for (int i = 0; i < word.length(); i++) {
            originPinyins[i] = Pinyin.toPinyin(word.charAt(i));
        }

        String[] pinyins = mDict.mapping().get(word);

        boolean hasDifferent = false;

        for (int i = 0; i < word.length(); i++) {
            if (!originPinyins[i].equalsIgnoreCase(pinyins[i])) {
                hasDifferent = true;
                break;
            }
        }

        assertThat(hasDifferent, is(true));
    }
}
 
开发者ID:promeG,项目名称:TinyPinyin,代码行数:26,代码来源:CnCityDictTest.java

示例2: getStringPixLength

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
private int getStringPixLength(String str) {
    int pixLength = 0;
    char c;
    for (int i = 0; i < str.length(); i++) {
        c = str.charAt(i);
        if (Pinyin.isChinese(c)) {
            pixLength += 24;
        } else {
            pixLength += 12;
        }
    }
    return pixLength;
}
 
开发者ID:aiyangtianci,项目名称:BluetoothAPP,代码行数:14,代码来源:PrintUtil.java

示例3: getPinyinForSorting

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
@NonNull
public static String[] getPinyinForSorting(String[] textArr) {
    if (textArr == null) {
        return new String[0];
    }

    String[] resultArr = new String[textArr.length];
    for (int i = 0, len = textArr.length; i < len; ++i) {
        resultArr[i] = Pinyin.toPinyin(textArr[i], "").toLowerCase();
    }

    return resultArr;
}
 
开发者ID:homeii,项目名称:GxIconDIY,代码行数:14,代码来源:ExtraUtil.java

示例4: CityBean

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
public CityBean(String city) {
    if (!TextUtils.isEmpty(city)) {
        char[] chars = city.toCharArray();
        StringBuilder ctpy = new StringBuilder();
        for (int i = 0; i < chars.length; i++) {
            ctpy.append(Pinyin.toPinyin(chars[i]));
        }
        this.pinyin = ctpy.toString();
        this.tag = pinyin.substring(0, 1);
    }
    this.city = city;
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:13,代码来源:CityBean.java

示例5: getContactsList

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
/**
     * 同步返回联系人列表
     */
    public static List<ContactsInfo> getContactsList(Context context) {

        //检查权限
        if (Build.VERSION.SDK_INT >= 23) {
            if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
                return  new ArrayList<>();
            }
        }

        final ContentResolver contentResolver = context.getContentResolver();
        Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, new String[]{"_id"}, null, null, null);
        List<ContactsInfo> contactsInfos = new ArrayList<>();

        if (cursor != null) {
            //枚举所有联系人的id
            if (cursor.getCount() > 0) {
                L.w("联系人总数量:" + cursor.getCount()); //就是联系人的总数
                int count = 0;
                if (cursor.moveToFirst()) {
                    do {
                        int contactIdIndex = cursor.getColumnIndex(ContactsContract.Contacts._ID);//获取 id 所在列的索引
                        String contactId = cursor.getString(contactIdIndex);//联系人id

                        final List<String> phones = getData1(contentResolver, contactId, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
                        if (phones.isEmpty()) {
                            continue;
                        } else {
                            String name;
                            final List<String> names = getData1(contentResolver, contactId, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
                            if (names.isEmpty()) {
                                name = phones.get(0);
                            } else {
                                name = names.get(0);
                            }

                            //相同联系人的不同手机号码视为不同的联系人
                            for (String phone : phones) {
                                // 去除非手机号
                                if (!RegexUtils.isMobileExact(StringUtil.removeBlanks(phone))) {
                                    continue;
                                }
                                ContactsInfo io = new ContactsInfo();
                                io.contactId = contactId;
                                io.name = name;
                                io.phone = StringUtil.removeBlanks(phone);
                                io.letter = String.valueOf(Pinyin.toPinyin(name.charAt(0)).toUpperCase().charAt(0));
                                contactsInfos.add(io);
                            }
                        }

//                    L.e("-------------------------" + count + "----------------------");
//                    L.w("联系人ID:" + contactId);
//                    final String name = getData1(contentResolver, contactId, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
//                    L.w("联系人名称:" + Pinyin.toPinyin(name.charAt(0)).toUpperCase().charAt(0) + " " + name);
//                    L.w("联系人电话:" + getData1(contentResolver, contactId, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE));
//                    logData(contentResolver, contactId);
//                    count++;
                    } while (cursor.moveToNext());
                }
            }
            cursor.close();
        }
        return contactsInfos;
    }
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:68,代码来源:ContactsPickerHelper.java

示例6: search

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
private Observable<List<AppInfo>> search(final String key) {
  return Observable.create(new ObservableOnSubscribe<List<AppInfo>>() {
    @Override
    public void subscribe(ObservableEmitter<List<AppInfo>> e) throws Exception {
      Pattern p = Pattern.compile(".*(?i)(" + key + ").*");
      List<AppInfo> result = new ArrayList<>();
      for (AppInfo info : mBaseData) {
        if (p.matcher(info.appName).matches()) {
          result.add(info);
        } else {
          if (info.pinyin == null) {
            StringBuilder sb = new StringBuilder();
            char[] chars = info.appName.toCharArray();
            for (char aChar : chars) {
              String s = Pinyin.toPinyin(aChar);
              if (!TextUtils.isEmpty(s)) {
                sb.append(s.charAt(0));
              }
            }
            info.pinyin = sb.toString();
          }
          if (p.matcher(info.pinyin).matches()) {
            result.add(info);
          }
        }
      }
      e.onNext(result);
    }
  });
}
 
开发者ID:8enet,项目名称:AppOpsX,代码行数:31,代码来源:SearchHandler.java

示例7: getSectionText

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
@Override
public String getSectionText(int position) {
    if(position == 0)
        return "";
    if(mDatas != null && position - 1 < mDatas.size()){
        String title = mDatas.get(position - 1).getTitle();
        return !TextUtils.isEmpty(title) ? (Pinyin.toPinyin(title.charAt(0))).toUpperCase().substring(0,1)  : "";
    }
    return "";
}
 
开发者ID:rRemix,项目名称:APlayer,代码行数:11,代码来源:SongAdapter.java

示例8: getSectionText

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
@Override
public String getSectionText(int position) {
    if(position == 0)
        return "";
    if(mDatas != null && mDatas.size() > 0 && position < mDatas.size() && mDatas.get(position - 1) != null){
        String title = mDatas.get(position - 1).getTitle();
        return !TextUtils.isEmpty(title) ? (Pinyin.toPinyin(title.charAt(0))).toUpperCase().substring(0,1)  : "";
    }
    return "";
}
 
开发者ID:rRemix,项目名称:APlayer,代码行数:11,代码来源:ChildHolderAdapter.java

示例9: getSectionText

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
@Override
public String getSectionText(int position) {
    if(position == 0)
        return "";
    if(mDatas != null && position - 1 < mDatas.size()){
        String album = mDatas.get(position - 1).getAlbum();
        return !TextUtils.isEmpty(album) ? (Pinyin.toPinyin(album.charAt(0))).toUpperCase().substring(0,1)  : "";
    }
    return "";
}
 
开发者ID:rRemix,项目名称:APlayer,代码行数:11,代码来源:AlbumAdapter.java

示例10: getSectionText

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
@Override
public String getSectionText(int position) {
    if(position == 0)
        return "";
    if(mDatas != null && position - 1 < mDatas.size()){
        String artist = mDatas.get(position - 1).getArtist();
        return !TextUtils.isEmpty(artist) ? (Pinyin.toPinyin(artist.charAt(0))).toUpperCase().substring(0,1)  : "";
    }
    return "";
}
 
开发者ID:rRemix,项目名称:APlayer,代码行数:11,代码来源:ArtistAdapter.java

示例11: getSectionText

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
@Override
public String getSectionText(int position) {
    if(position == 0)
        return "";
    if(mDatas != null && position - 1 < mDatas.size()){
        String title = mDatas.get(position - 1).Name;
        return !TextUtils.isEmpty(title) ? (Pinyin.toPinyin(title.charAt(0))).toUpperCase().substring(0,1)  : "";
    }
    return "";
}
 
开发者ID:rRemix,项目名称:APlayer,代码行数:11,代码来源:PlayListAdapter.java

示例12: getPingYin

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
/**
 * 将字符串中的中文转化为拼音,其他字符不变
 */
public static String getPingYin(String inputString) {
    char[] input = inputString.trim().toCharArray();
    String output = "";
    for (int i = 0; i < input.length; i++) {
        output += Pinyin.toPinyin(input[i]);
    }
    return output.toLowerCase();
}
 
开发者ID:smuyyh,项目名称:SprintNBA,代码行数:12,代码来源:PinyinUtil.java

示例13: getPingYin

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
/**
 * 将中文转换为pinyin
 */
public static String getPingYin(String inputString) {

    char[] input = inputString.trim().toCharArray();
    String output = "";
    for (int i = 0; i < input.length; i++) {
        output += Pinyin.toPinyin(input[i]);
    }
    return output.toLowerCase();
}
 
开发者ID:huyongli,项目名称:IndexStickyView,代码行数:13,代码来源:PinYinHelper.java

示例14: transformPinYin

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
public String transformPinYin(String character) {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < character.length(); i++) {
        buffer.append(Pinyin.toPinyin(character.charAt(i)));
    }
    return buffer.toString();
}
 
开发者ID:garyhu1,项目名称:collapselrecycler,代码行数:8,代码来源:ThirdFragment.java

示例15: getPingYin

import com.github.promeg.pinyinhelper.Pinyin; //导入依赖的package包/类
/**
 * Chinese character -> Pinyin
 */
public static String getPingYin(String inputString) {
    char[] input = inputString.trim().toCharArray();
    String output = "";
    for (int i = 0; i < input.length; i++) {
        output += Pinyin.toPinyin(input[i]);
    }
    return output.toLowerCase();
}
 
开发者ID:garyhu1,项目名称:collapselrecycler,代码行数:12,代码来源:PinyinUtil.java


注:本文中的com.github.promeg.pinyinhelper.Pinyin类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。