diff options
author | James Lemieux <jplemieux@google.com> | 2016-08-03 21:49:52 -0700 |
---|---|---|
committer | James Lemieux <jplemieux@google.com> | 2016-08-04 18:44:50 -0700 |
commit | 310f96ed002219067d2e652e27d64d256e315832 (patch) | |
tree | 78be42ce60bb822777462f3e1648825d4b28cfdd /src/com/android/deskclock/controller/Controller.java | |
parent | 2e9223dc41d8ad89fc2fb18082d97d1325b6dbe2 (diff) |
Controller, DataModel and UiDataModel allow context to be replaced
Bug: 29538369
Adjusting the context within those classes connotes that their delegates
should be rebuilt using the new context.
Change-Id: If11e4f8a5e6c4fe870d9eb16c0e3b65ed0a32624
Diffstat (limited to 'src/com/android/deskclock/controller/Controller.java')
-rw-r--r-- | src/com/android/deskclock/controller/Controller.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/com/android/deskclock/controller/Controller.java b/src/com/android/deskclock/controller/Controller.java index 82487e0f7..5272bbe00 100644 --- a/src/com/android/deskclock/controller/Controller.java +++ b/src/com/android/deskclock/controller/Controller.java @@ -46,15 +46,14 @@ public final class Controller implements VoiceController { } public void setContext(Context context) { - if (mContext != null) { - throw new IllegalStateException("context has already been set"); - } - mContext = context; - if (Utils.isMOrLater()) { - mVoiceController = new DefaultVoiceController(); - } - if (Utils.isNMR1OrLater()) { - mShortcutController = new ShortcutController(mContext); + if (mContext != context) { + mContext = context.getApplicationContext(); + if (Utils.isMOrLater()) { + mVoiceController = new DefaultVoiceController(); + } + if (Utils.isNMR1OrLater()) { + mShortcutController = new ShortcutController(mContext); + } } } |