Return asset manager with correct config from ContextThemeWrapper

Bug: 23416037
Change-Id: Ia87bebbe6f23214c892bc2ca19d4112853023235
This commit is contained in:
Alan Viverette
2015-08-25 13:45:38 -04:00
parent fa0f7cdd2e
commit 99bf63fdaf

View File

@@ -19,6 +19,7 @@ package android.view;
import android.annotation.StyleRes;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -60,11 +61,12 @@ public class ContextThemeWrapper extends ContextWrapper {
* information.
*
* <p>This method can only be called once, and must be called before any
* calls to {@link #getResources()} are made.
* calls to {@link #getResources()} or {@link #getAssets()} are made.
*/
public void applyOverrideConfiguration(Configuration overrideConfiguration) {
if (mResources != null) {
throw new IllegalStateException("getResources() has already been called");
throw new IllegalStateException(
"getResources() or getAssets() has already been called");
}
if (mOverrideConfiguration != null) {
throw new IllegalStateException("Override configuration has already been set");
@@ -72,6 +74,12 @@ public class ContextThemeWrapper extends ContextWrapper {
mOverrideConfiguration = new Configuration(overrideConfiguration);
}
@Override
public AssetManager getAssets() {
// Ensure we're returning assets with the correct configuration.
return getResources().getAssets();
}
@Override
public Resources getResources() {
if (mResources != null) {