Fixing crash when using app name comparator with empty titles.

Bug: 22065752
Change-Id: I4160f5e1728e46ce85fd2579889e7952de01a752
This commit is contained in:
Winson Chung 2015-06-25 10:05:54 -07:00
parent 4c7fc62ae2
commit 2a1d4ed54f
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) { @Thunk int compareTitles(String titleA, String titleB) {
// Ensure that we de-prioritize any titles that don't start with a linguistic letter or digit // 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 aStartsWithLetter = (titleA.length() > 0) &&
boolean bStartsWithLetter = Character.isLetterOrDigit(titleB.codePointAt(0)); Character.isLetterOrDigit(titleA.codePointAt(0));
boolean bStartsWithLetter = (titleB.length() > 0) &&
Character.isLetterOrDigit(titleB.codePointAt(0));
if (aStartsWithLetter && !bStartsWithLetter) { if (aStartsWithLetter && !bStartsWithLetter) {
return -1; return -1;
} else if (!aStartsWithLetter && bStartsWithLetter) { } else if (!aStartsWithLetter && bStartsWithLetter) {