本文整理汇总了Java中com.hyphenate.util.HanziToPinyin类的典型用法代码示例。如果您正苦于以下问题:Java HanziToPinyin类的具体用法?Java HanziToPinyin怎么用?Java HanziToPinyin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HanziToPinyin类属于com.hyphenate.util包,在下文中一共展示了HanziToPinyin类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUserInitialLetter
import com.hyphenate.util.HanziToPinyin; //导入依赖的package包/类
/**
* 设置user昵称(没有昵称取username)的首字母属性,方便通讯中对联系人按header分类显示,以及通过右侧ABCD...字母栏快速定位联系人
*
* @param username
* @param user
*/
public static void setUserInitialLetter(EaseUser user) {
String headerName = null;
if (!TextUtils.isEmpty(user.getNick())) {
headerName = user.getNick();
} else {
headerName = user.getUsername();
}
if (Character.isDigit(headerName.charAt(0))) {
user.setInitialLetter("#");
} else {
user.setInitialLetter(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target.substring(0, 1)
.toUpperCase());
char header = user.getInitialLetter().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setInitialLetter("#");
}
}
}
开发者ID:Rabbit00,项目名称:MeifuGO,代码行数:25,代码来源:EaseCommonUtils.java
示例2: getRobotList
import com.hyphenate.util.HanziToPinyin; //导入依赖的package包/类
/**
* load robot list
*/
synchronized public Map<String, RobotUser> getRobotList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, RobotUser> users = null;
if (db.isOpen()) {
Cursor cursor = db.rawQuery("select * from " + UserDao.ROBOT_TABLE_NAME, null);
if(cursor.getCount()>0){
users = new Hashtable<String, RobotUser>();
};
while (cursor.moveToNext()) {
String username = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_ID));
String nick = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_NICK));
String avatar = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_AVATAR));
RobotUser user = new RobotUser(username);
user.setNick(nick);
user.setAvatar(avatar);
String headerName = null;
if (!TextUtils.isEmpty(user.getNick())) {
headerName = user.getNick();
} else {
headerName = user.getUsername();
}
if(Character.isDigit(headerName.charAt(0))){
user.setInitialLetter("#");
}else{
user.setInitialLetter(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target
.substring(0, 1).toUpperCase());
char header = user.getInitialLetter().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setInitialLetter("#");
}
}
users.put(username, user);
}
cursor.close();
}
return users;
}
开发者ID:laoduDYM,项目名称:ChatDemoUI3.0,代码行数:42,代码来源:DemoDBManager.java
示例3: getContactList
import com.hyphenate.util.HanziToPinyin; //导入依赖的package包/类
/**
* 获取好友list
*
* @return
*/
synchronized public Map<String, EaseUser> getContactList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, EaseUser> users = new Hashtable<String, EaseUser>();
if (db.isOpen()) {
Cursor cursor = db.rawQuery("select * from " + UserDao.TABLE_NAME /* + " desc" */, null);
while (cursor.moveToNext()) {
String username = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_ID));
String nick = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_NICK));
String avatar = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_AVATAR));
EaseUser user = new EaseUser(username);
user.setNick(nick);
user.setAvatar(avatar);
String headerName = null;
if (!TextUtils.isEmpty(user.getNick())) {
headerName = user.getNick();
} else {
headerName = user.getUsername();
}
if (username.equals(Constant.NEW_FRIENDS_USERNAME) || username.equals(Constant.GROUP_USERNAME)
|| username.equals(Constant.CHAT_ROOM)|| username.equals(Constant.CHAT_ROBOT)) {
user.setInitialLetter("");
} else if (Character.isDigit(headerName.charAt(0))) {
user.setInitialLetter("#");
} else {
user.setInitialLetter(HanziToPinyin.getInstance().get(headerName.substring(0, 1))
.get(0).target.substring(0, 1).toUpperCase());
char header = user.getInitialLetter().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setInitialLetter("#");
}
}
users.put(username, user);
}
cursor.close();
}
return users;
}
开发者ID:tianyuan168326,项目名称:nono-android,代码行数:44,代码来源:DemoDBManager.java
示例4: getRobotList
import com.hyphenate.util.HanziToPinyin; //导入依赖的package包/类
/**
* load robot list
*/
synchronized public Map<String, RobotUser> getRobotList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, RobotUser> users = null;
if (db.isOpen()) {
Cursor cursor = db.rawQuery("select * from " + UserDao.ROBOT_TABLE_NAME, null);
if (cursor.getCount() > 0) {
users = new Hashtable<String, RobotUser>();
}
while (cursor.moveToNext()) {
String username = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_ID));
String nick = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_NICK));
String avatar = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_AVATAR));
RobotUser user = new RobotUser(username);
user.setNick(nick);
user.setAvatar(avatar);
String headerName = null;
if (!TextUtils.isEmpty(user.getNick())) {
headerName = user.getNick();
} else {
headerName = user.getUsername();
}
if (Character.isDigit(headerName.charAt(0))) {
user.setInitialLetter("#");
} else {
user.setInitialLetter(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target
.substring(0, 1).toUpperCase());
char header = user.getInitialLetter().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setInitialLetter("#");
}
}
try {
users.put(username, user);
} catch (Exception e) {
e.printStackTrace();
}
}
cursor.close();
}
return users;
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:46,代码来源:DemoDBManager.java
注:本文中的com.hyphenate.util.HanziToPinyin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论