diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-06-11 14:06:29 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-11 14:06:29 -0700 |
| commit | f372e331e46bb9852520fa76c76f99ad99441893 (patch) | |
| tree | de0d829b6fedb577e3bee7badec90a05532d0427 /core/java/android | |
| parent | 409d563b51853fc9dce6b4c02df84f58ec887afd (diff) | |
| parent | bbd31559f32f86a100904fe8a5bc37677b5ba441 (diff) | |
Merge "NPE when iterating by character and word in Launcher widgets." into jb-dev
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/AccessibilityIterators.java | 26 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 6 |
2 files changed, 16 insertions, 16 deletions
diff --git a/core/java/android/view/AccessibilityIterators.java b/core/java/android/view/AccessibilityIterators.java index 2a7dc181def1..17ce4f639f28 100644 --- a/core/java/android/view/AccessibilityIterators.java +++ b/core/java/android/view/AccessibilityIterators.java @@ -70,20 +70,19 @@ public final class AccessibilityIterators { implements ComponentCallbacks { private static CharacterTextSegmentIterator sInstance; - private final Context mAppContext; + private Locale mLocale; protected BreakIterator mImpl; - public static CharacterTextSegmentIterator getInstance(Context context) { + public static CharacterTextSegmentIterator getInstance(Locale locale) { if (sInstance == null) { - sInstance = new CharacterTextSegmentIterator(context); + sInstance = new CharacterTextSegmentIterator(locale); } return sInstance; } - private CharacterTextSegmentIterator(Context context) { - mAppContext = context.getApplicationContext(); - Locale locale = mAppContext.getResources().getConfiguration().locale; + private CharacterTextSegmentIterator(Locale locale) { + mLocale = locale; onLocaleChanged(locale); ViewRootImpl.addConfigCallback(this); } @@ -148,10 +147,9 @@ public final class AccessibilityIterators { @Override public void onConfigurationChanged(Configuration newConfig) { - Configuration oldConfig = mAppContext.getResources().getConfiguration(); - final int changed = oldConfig.diff(newConfig); - if ((changed & ActivityInfo.CONFIG_LOCALE) != 0) { - Locale locale = newConfig.locale; + Locale locale = newConfig.locale; + if (!mLocale.equals(locale)) { + mLocale = locale; onLocaleChanged(locale); } } @@ -169,15 +167,15 @@ public final class AccessibilityIterators { static class WordTextSegmentIterator extends CharacterTextSegmentIterator { private static WordTextSegmentIterator sInstance; - public static WordTextSegmentIterator getInstance(Context context) { + public static WordTextSegmentIterator getInstance(Locale locale) { if (sInstance == null) { - sInstance = new WordTextSegmentIterator(context); + sInstance = new WordTextSegmentIterator(locale); } return sInstance; } - private WordTextSegmentIterator(Context context) { - super(context); + private WordTextSegmentIterator(Locale locale) { + super(locale); } @Override diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index f005eeba151c..816b631bf987 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6957,7 +6957,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal CharSequence text = getIterableTextForAccessibility(); if (text != null && text.length() > 0) { CharacterTextSegmentIterator iterator = - CharacterTextSegmentIterator.getInstance(mContext); + CharacterTextSegmentIterator.getInstance( + mContext.getResources().getConfiguration().locale); iterator.initialize(text.toString()); return iterator; } @@ -6966,7 +6967,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal CharSequence text = getIterableTextForAccessibility(); if (text != null && text.length() > 0) { WordTextSegmentIterator iterator = - WordTextSegmentIterator.getInstance(mContext); + WordTextSegmentIterator.getInstance( + mContext.getResources().getConfiguration().locale); iterator.initialize(text.toString()); return iterator; } |
