Stop using Configuration.setLocale

The call for method Configuration.setLocale that is introduce by
If60877b29b should be remove to be compatible with API 14 and later.

Bug: 14239862
Change-Id: I3815c2b56bd9c655b8bde6f93143adf3ff08c35d
This commit is contained in:
Tadashi G. Takaoka 2014-04-22 09:19:39 -07:00
parent a685fc1792
commit 543d3d24bd

View file

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