am cfdeb9b0: Merge "Stop using Configuration.setLocale"

* commit 'cfdeb9b04bd1646e97973823fd9d4fb5dee09681':
  Stop using Configuration.setLocale
This commit is contained in:
Tadashi G. Takaoka 2014-04-22 16:51:02 +00:00 committed by Android Git Automerger
commit ade8b001e3

View file

@ -35,18 +35,18 @@ public abstract class RunInLocale<T> {
*/ */
public T runInLocale(final Resources res, final Locale newLocale) { public T runInLocale(final Resources res, final Locale newLocale) {
synchronized (sLockForRunInLocale) { synchronized (sLockForRunInLocale) {
final Configuration savedConf = res.getConfiguration(); final Configuration conf = res.getConfiguration();
if (newLocale == null || newLocale.equals(savedConf.locale)) { if (newLocale == null || newLocale.equals(conf.locale)) {
return job(res); return job(res);
} }
final Configuration newConf = new Configuration(); final Locale savedLocale = conf.locale;
newConf.setTo(savedConf);
newConf.setLocale(newLocale);
try { try {
res.updateConfiguration(newConf, null); conf.locale = newLocale;
res.updateConfiguration(conf, null);
return job(res); return job(res);
} finally { } finally {
res.updateConfiguration(savedConf, null); conf.locale = savedLocale;
res.updateConfiguration(conf, null);
} }
} }
} }