Merge "Fixing crash when using app name comparator with empty titles." into ub-launcher3-burnaby

This commit is contained in:
Winson Chung 2015-06-25 17:11:02 +00:00 committed by Android (Google) Code Review
commit 051527fd54
1 changed files with 4 additions and 2 deletions

View File

@ -85,8 +85,10 @@ public class AppNameComparator {
*/
@Thunk int compareTitles(String titleA, String titleB) {
// Ensure that we de-prioritize any titles that don't start with a linguistic letter or digit
boolean aStartsWithLetter = Character.isLetterOrDigit(titleA.codePointAt(0));
boolean bStartsWithLetter = Character.isLetterOrDigit(titleB.codePointAt(0));
boolean aStartsWithLetter = (titleA.length() > 0) &&
Character.isLetterOrDigit(titleA.codePointAt(0));
boolean bStartsWithLetter = (titleB.length() > 0) &&
Character.isLetterOrDigit(titleB.codePointAt(0));
if (aStartsWithLetter && !bStartsWithLetter) {
return -1;
} else if (!aStartsWithLetter && bStartsWithLetter) {