diff options
author | Alan Viverette <alanv@google.com> | 2015-05-08 21:10:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-08 21:10:03 +0000 |
commit | f93bba5b793a73f98fdaf62ffbccb3ee1769194c (patch) | |
tree | b08c9fab1f979bf9b8774ebea38ea29b1e25f879 /core | |
parent | ed9af066b2407a36699fae2e475c4d1b53d2ca1d (diff) | |
parent | cc2a1d48a0e4134823c940291f5db6fd9f2ae9b3 (diff) | |
download | frameworks_base-f93bba5b793a73f98fdaf62ffbccb3ee1769194c.zip frameworks_base-f93bba5b793a73f98fdaf62ffbccb3ee1769194c.tar.gz frameworks_base-f93bba5b793a73f98fdaf62ffbccb3ee1769194c.tar.bz2 |
Merge "Allow ContextImpl.setTheme(int) to be called after getTheme()" into mnc-dev
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/ContextImpl.java | 24 | ||||
-rw-r--r-- | core/java/android/view/ContextThemeWrapper.java | 9 |
2 files changed, 24 insertions, 9 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 81a78f6..cb20cb8 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -237,8 +237,11 @@ class ContextImpl extends Context { } @Override - public void setTheme(int resid) { - mThemeResource = resid; + public void setTheme(int resId) { + if (mThemeResource != resId) { + mThemeResource = resId; + initializeTheme(); + } } @Override @@ -248,13 +251,22 @@ class ContextImpl extends Context { @Override public Resources.Theme getTheme() { + if (mTheme != null) { + return mTheme; + } + + mThemeResource = Resources.selectDefaultTheme(mThemeResource, + getOuterContext().getApplicationInfo().targetSdkVersion); + initializeTheme(); + + return mTheme; + } + + private void initializeTheme() { if (mTheme == null) { - mThemeResource = Resources.selectDefaultTheme(mThemeResource, - getOuterContext().getApplicationInfo().targetSdkVersion); mTheme = mResources.newTheme(); - mTheme.applyStyle(mThemeResource, true); } - return mTheme; + mTheme.applyStyle(mThemeResource, true); } @Override diff --git a/core/java/android/view/ContextThemeWrapper.java b/core/java/android/view/ContextThemeWrapper.java index 9047b1d..ce50091 100644 --- a/core/java/android/view/ContextThemeWrapper.java +++ b/core/java/android/view/ContextThemeWrapper.java @@ -87,9 +87,12 @@ public class ContextThemeWrapper extends ContextWrapper { } } - @Override public void setTheme(int resid) { - mThemeResource = resid; - initializeTheme(); + @Override + public void setTheme(int resid) { + if (mThemeResource != resid) { + mThemeResource = resid; + initializeTheme(); + } } /** @hide */ |