diff options
| author | YuanQY <yuanqingyun@gmail.com> | 2012-11-06 22:35:36 +0800 |
|---|---|---|
| committer | YuanQY <yuanqingyun@gmail.com> | 2012-11-06 23:00:07 +0800 |
| commit | 8dc8c0515b925c0bdcd529bebdcd5d1026c20843 (patch) | |
| tree | d65fe08779d094286bccda012f06752435fa4c56 | |
| parent | 3ae1d1d9ab6e615a81032d40befbec593e1d397e (diff) | |
| download | android_packages_apps_CMFileManager-8dc8c0515b925c0bdcd529bebdcd5d1026c20843.tar.gz android_packages_apps_CMFileManager-8dc8c0515b925c0bdcd529bebdcd5d1026c20843.tar.bz2 android_packages_apps_CMFileManager-8dc8c0515b925c0bdcd529bebdcd5d1026c20843.zip | |
CMFileManager: Fix the crash when the search file name includes mutiple white spaces.
When the file name include mutiple white spaces and it fit for the search condition.
The highlight logical call Html.fromHtml will convert mutiple white spaces to one white
space (For example, the file name is "A .mp3", after conver it will change to "A .mp3"),
the span length will less than the orginal file name. When call setSpan,
it will throw IndexOutOfBoundsException.
Change-Id: I00e26464427538de8f5f85ac8d6d009493767b1e
| -rw-r--r-- | src/com/cyanogenmod/filemanager/util/SearchHelper.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/com/cyanogenmod/filemanager/util/SearchHelper.java b/src/com/cyanogenmod/filemanager/util/SearchHelper.java index d6120759..7b45eac7 100644 --- a/src/com/cyanogenmod/filemanager/util/SearchHelper.java +++ b/src/com/cyanogenmod/filemanager/util/SearchHelper.java @@ -18,8 +18,8 @@ package com.cyanogenmod.filemanager.util; import android.graphics.Color; import android.graphics.Typeface; -import android.text.Html; import android.text.Spannable; +import android.text.SpannableString; import android.text.style.BackgroundColorSpan; import android.text.style.StyleSpan; @@ -131,7 +131,7 @@ public final class SearchHelper { .replace("*", ".*"); //$NON-NLS-1$//$NON-NLS-2$ Pattern pattern = Pattern.compile(query, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(name); - Spannable span = (Spannable)Html.fromHtml(name); + Spannable span = new SpannableString(name); if (matcher.find()) { //Highlight the match span.setSpan( @@ -155,7 +155,7 @@ public final class SearchHelper { */ public static CharSequence getNonHighlightedName(SearchResult result) { String name = result.getFso().getName(); - Spannable span = (Spannable)Html.fromHtml(name); + Spannable span = new SpannableString(name); span.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); return span; } |
