From 2a1d4ed54feb26405c0c6253df5431303cedefa8 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 25 Jun 2015 10:05:54 -0700 Subject: [PATCH] Fixing crash when using app name comparator with empty titles. Bug: 22065752 Change-Id: I4160f5e1728e46ce85fd2579889e7952de01a752 --- src/com/android/launcher3/model/AppNameComparator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/model/AppNameComparator.java b/src/com/android/launcher3/model/AppNameComparator.java index cd45d2c94a..c4b74d4dc4 100644 --- a/src/com/android/launcher3/model/AppNameComparator.java +++ b/src/com/android/launcher3/model/AppNameComparator.java @@ -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) {