本文整理汇总了Java中com.easemob.util.HanziToPinyin类的典型用法代码示例。如果您正苦于以下问题:Java HanziToPinyin类的具体用法?Java HanziToPinyin怎么用?Java HanziToPinyin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HanziToPinyin类属于com.easemob.util包,在下文中一共展示了HanziToPinyin类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUserHead
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* set head
* @param username
* @return
*/
User setUserHead(String username) {
User user = new User();
user.setUsername(username);
String headerName = null;
if (!TextUtils.isEmpty(user.getNick())) {
headerName = user.getNick();
} else {
headerName = user.getUsername();
}
if (username.equals(Constant.NEW_FRIENDS_USERNAME)) {
user.setHeader("");
} else if (Character.isDigit(headerName.charAt(0))) {
user.setHeader("#");
} else {
user.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target.substring(
0, 1).toUpperCase());
char header = user.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setHeader("#");
}
}
return user;
}
示例2: setUserHearder
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 设置hearder属性,方便通讯中对联系人按header分类显示,以及通过右侧ABCD...字母栏快速定位联系人
*
* @param username
* @param user
*/
protected void setUserHearder(String username, User user) {
String headerName = null;
if (!TextUtils.isEmpty(user.getNick())) {
headerName = user.getNick();
} else {
headerName = user.getUsername();
}
if (username.equals(Constant.NEW_FRIENDS_USERNAME)) {
user.setHeader("");
} else if (Character.isDigit(headerName.charAt(0))) {
user.setHeader("#");
} else {
user.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target.substring(0, 1).toUpperCase());
char header = user.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setHeader("#");
}
}
}
示例3: setUserInitialLetter
import com.easemob.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("#");
}
}
}
示例4: setUserHearder
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 设置hearder属性,方便通讯中对联系人按header分类显示,以及通过右侧ABCD...字母栏快速定位联系人
*
* @param username
* @param user
*/
protected void setUserHearder(String username, User user) {
String headerName = null;
if (!TextUtils.isEmpty(user.getNick())) {
headerName = user.getNick();
} else {
headerName = user.getUsername();
}
if (username.equals(Constants.NEW_FRIENDS_USERNAME)) {
user.setHeader("");
} else if (Character.isDigit(headerName.charAt(0))) {
user.setHeader("#");
} else {
user.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target.substring(0, 1).toUpperCase());
char header = user.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setHeader("#");
}
}
}
示例5: setUserHearder
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 设置hearder属性,方便通讯中对联系人按header分类显示,以及通过右侧ABCD...字母栏快速定位联系人
*
* @param EMUser
*/
private static void setUserHearder(EMUser EMUser) {
String headerName = null;
if (!TextUtils.isEmpty(EMUser.getNick())) {
headerName = EMUser.getNick();
} else {
headerName = EMUser.getUsername();
}
if (Character.isDigit(headerName.charAt(0))) {
EMUser.setHeader("#");
} else {
EMUser.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target.substring(0, 1)
.toUpperCase());
char header = EMUser.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
EMUser.setHeader("#");
}
}
}
示例6: setUserHearder
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 设置hearder属性,方便通讯中对联系人按header分类显示,以及通过右侧ABCD...字母栏快速定位联系人
*
* @param username
* @param EMUser
*/
private static void setUserHearder(String username, EMUser EMUser) {
String headerName = null;
if (!TextUtils.isEmpty(EMUser.getNick())) {
headerName = EMUser.getNick();
} else {
headerName = EMUser.getUsername();
}
if (username.equals(Constant.NEW_FRIENDS_USERNAME)) {
EMUser.setHeader("");
} else if (Character.isDigit(headerName.charAt(0))) {
EMUser.setHeader("#");
} else {
EMUser.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target.substring(0, 1)
.toUpperCase());
char header = EMUser.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
EMUser.setHeader("#");
}
}
}
示例7: setUserInitialLetter
import com.easemob.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("#");
}
}
}
示例8: getContactList
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 获取好友list
*
* @return
*/
public Map<String, User> getContactList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, User> users = new HashMap<String, User>();
if (db.isOpen()) {
Cursor cursor = db.rawQuery("select * from " + TABLE_NAME +" WHERE " + COLUMN_NAME_IS_STRANGER +" = '2' "/* + " desc" */, null);
while (cursor.moveToNext()) {
String username = cursor.getString(cursor.getColumnIndex(COLUMN_NAME_ID));
String nick = cursor.getString(cursor.getColumnIndex(COLUMN_NAME_NICK));
User user = new User();
user.setUsername(username);
user.setNick(nick);
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)) {
user.setHeader("");
} else if (Character.isDigit(headerName.charAt(0))) {
user.setHeader("#");
} else {
user.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1))
.get(0).target.substring(0, 1).toUpperCase());
char header = user.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setHeader("#");
}
}
users.put(username, user);
}
cursor.close();
}
return users;
}
示例9: getContactList
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 获取好友list
*
* @return
*/
synchronized public Map<String, EaseUser> getContactList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, EaseUser> users = new HashMap<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;
}
示例10: getRobotList
import com.easemob.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 HashMap<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;
}
示例11: getContactList
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 获取好友list
*
* @return
*/
public Map<String, User> getContactList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, User> users = new HashMap<String, User>();
if (db.isOpen()) {
Cursor cursor = db.rawQuery("select * from " + TABLE_NAME /* + " desc" */, null);
while (cursor.moveToNext()) {
String username = cursor.getString(cursor.getColumnIndex(COLUMN_NAME_ID));
String nick = cursor.getString(cursor.getColumnIndex(COLUMN_NAME_NICK));
String avatar = cursor.getString(cursor.getColumnIndex(COLUMN_NAME_AVATAR));
User user = new User();
user.setUsername(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(Constants.NEW_FRIENDS_USERNAME) || username.equals(Constants.GROUP_USERNAME)) {
user.setHeader("");
} else if (Character.isDigit(headerName.charAt(0))) {
user.setHeader("#");
} else {
user.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1))
.get(0).target.substring(0, 1).toUpperCase());
char header = user.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setHeader("#");
}
}
users.put(username, user);
}
cursor.close();
}
return users;
}
示例12: getRobotList
import com.easemob.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 HashMap<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();
user.setUsername(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.setHeader("#");
}else{
user.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target
.substring(0, 1).toUpperCase());
char header = user.getHeader().toLowerCase().charAt(0);
if (header < 'a' || header > 'z') {
user.setHeader("#");
}
}
users.put(username, user);
}
cursor.close();
}
return users;
}
示例13: getContactList
import com.easemob.util.HanziToPinyin; //导入依赖的package包/类
/**
* 获取好友list
*
* @return
*/
synchronized public Map<String, EaseUser> getContactList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, EaseUser> users = new HashMap<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;
}
示例14: getRobotList
import com.easemob.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 HashMap<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;
}