am c6ee9e69: am 183fe800: Small cleanup of RunInLocale

* commit 'c6ee9e692c02b49b2feabda494985f59eff33d68':
  Small cleanup of RunInLocale
main
Tadashi G. Takaoka 2013-02-26 05:59:24 -08:00 committed by Android Git Automerger
commit 0a0e04e833
1 changed files with 3 additions and 2 deletions

View File

@ -180,14 +180,15 @@ public final class LocaleUtils {
synchronized (sLockForRunInLocale) { synchronized (sLockForRunInLocale) {
final Configuration conf = res.getConfiguration(); final Configuration conf = res.getConfiguration();
final Locale oldLocale = conf.locale; final Locale oldLocale = conf.locale;
final boolean needsChange = (newLocale != null && !newLocale.equals(oldLocale));
try { try {
if (newLocale != null && !newLocale.equals(oldLocale)) { if (needsChange) {
conf.locale = newLocale; conf.locale = newLocale;
res.updateConfiguration(conf, null); res.updateConfiguration(conf, null);
} }
return job(res); return job(res);
} finally { } finally {
if (newLocale != null && !newLocale.equals(oldLocale)) { if (needsChange) {
conf.locale = oldLocale; conf.locale = oldLocale;
res.updateConfiguration(conf, null); res.updateConfiguration(conf, null);
} }