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:
parent
a685fc1792
commit
543d3d24bd
1 changed files with 7 additions and 7 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue