this code used for check if word in string in hashMap key
String[] arrs = message.split("(?<! ) |(?<= {2})");
for(int j = 0 ; j < arrs.length; j++){
if(AppConfig.hashMap.containsKey(arrs[j])){
int s = AppConfig.hashMap.get(arrs[j]);
} else
text.append(" "+arrs[j]);
}
and the hashMap its
public static Map<String, Integer> hashMap = new HashMap<String, Integer>()
{{
put(":)", R.drawable.emoji_1f60a_64);
put(":D", R.drawable.emoji_1f601_64);
put(":'(", R.drawable.emoji_1f622_64);
put(":P", R.drawable.emoji_1f61c_64);
put(";)", R.drawable.emoji_1f609_64);
put(":O", R.drawable.emoji_1f632_64);
put("-_-", R.drawable.emoji_1f620_64);
put(":*", R.drawable.emoji_1f618_64);
put("<3", R.drawable.emoji_2764_64);
put("^_^", R.drawable.emoji_2764_64);
}};
now its can replace :) with drawable emogi but the problem when i use another smile symbole
when i loop on string and compare every word if found in hashMap
if(AppConfig.hashMap.containsKey(arrs[j])) //found smile replace with emogi
its check if there are :) or :D in string but problem when there are smiles symbols like those
"","","","","","","",""
so the hashMap will be
public static Map<String, Integer> hashMap = new HashMap<String, Integer>()
{{
put("", R.drawable.emoji_1f60a_64);
put("", R.drawable.emoji_1f601_64);
put("", R.drawable.emoji_1f622_64);
put("", R.drawable.emoji_1f61c_64);
put("", R.drawable.emoji_1f609_64);
put("", R.drawable.emoji_1f632_64);
put("", R.drawable.emoji_1f620_64);
put("", R.drawable.emoji_1f618_64);
}};
here i have this string
hi how are you ?
now when check if there are key in hashMap equal or ... by
if(AppConfig.hashMap.containsKey(arrs[j]))
its fail and say no key with this string