diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index 53f847434dccc..89911e01cde97 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -81,8 +81,7 @@ public abstract class KeyguardAbsKeyInputViewController } /** Initialize the Controller. */ - public void init() { - super.init(); + public void initInternal() { mKeyguardSecurityContainerController.init(); } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java index 3db9db7be00c6..94913c80ac5c3 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java @@ -190,8 +190,8 @@ public class KeyguardPatternViewController } @Override - public void init() { - super.init(); + public void initInternal() { + super.initInternal(); mMessageAreaController.init(); } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index 1c23605a8516b..e9173a3ca3a0b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -169,8 +169,7 @@ public class KeyguardSecurityContainerController extends ViewController { } @Override - public void init() { - super.init(); + public void initInternal() { mQuickStatusBarHeaderController.init(); } diff --git a/packages/SystemUI/src/com/android/systemui/util/ViewController.java b/packages/SystemUI/src/com/android/systemui/util/ViewController.java index 3dbc6f101a909..e8b837ee5bed1 100644 --- a/packages/SystemUI/src/com/android/systemui/util/ViewController.java +++ b/packages/SystemUI/src/com/android/systemui/util/ViewController.java @@ -26,8 +26,8 @@ import android.view.View.OnAttachStateChangeListener; * * Implementations should handle setup and teardown related activities inside of * {@link #onViewAttached()} and {@link #onViewDetached()}. Be sure to call {@link #init()} on - * any child controllers that this uses. This can be done in {@link init()} if the controllers - * are injected, or right after creation time of the child controller. + * any child controllers that this uses. This can be done in {@link #initInternal()} if the + * controllers are injected, or right after creation time of the child controller. * * Tip: View "attachment" happens top down - parents are notified that they are attached before * any children. That means that if you call a method on a child controller in @@ -62,11 +62,18 @@ public abstract class ViewController { mView = view; } - /** Call immediately after constructing Controller in order to handle view lifecycle events. */ + /** + * Call immediately after constructing Controller in order to handle view lifecycle events. + * + * Generally speaking, you don't want to override this method. Instead, override + * {@link #initInternal()} as a way to have an run-once idempotent method that you can use for + * setup of your ViewController. + */ public void init() { if (mInited) { return; } + initInternal(); mInited = true; if (mView != null) { @@ -77,6 +84,14 @@ public abstract class ViewController { } } + /** + * Run once when {@link #init()} is called. + * + * Override this to perform idempotent, one-time setup that your controller needs. It will + * be called before {@link #onViewAttached()}. + */ + protected void initInternal() {} + protected Context getContext() { return mView.getContext(); }