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


Java HanziToPinyin类代码示例

本文整理汇总了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;
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:29,代码来源:MainActivity_0903.java

示例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("#");
		}
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:26,代码来源:LoginActivity.java

示例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("#");
        }
    }
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:25,代码来源:EaseCommonUtils.java

示例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("#");
		}
	}
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:26,代码来源:LoginActivity.java

示例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("#");
        }
    }
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:24,代码来源:ParseManager.java

示例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("#");
        }
    }
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:27,代码来源:EMChatMainActivity.java

示例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("#");
        }
    }
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:25,代码来源:EaseCommonUtils.java

示例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;
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:42,代码来源:UserDao.java

示例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;
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:44,代码来源:DemoDBManager.java

示例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;
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:42,代码来源:DemoDBManager.java

示例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;
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:44,代码来源:UserDao.java

示例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;
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:43,代码来源:DemoDBManager.java

示例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;
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:44,代码来源:DemoDBManager.java

示例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;
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:43,代码来源:DemoDBManager.java


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