Merge "Add initInternal to ViewController."
This commit is contained in:
committed by
Android (Google) Code Review
commit
78bb2ffe5b
@@ -81,8 +81,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
abstract void resetState();
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
public void initInternal() {
|
||||
mMessageAreaController.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
||||
* Attach the controller to the view it relates to.
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
public void initInternal() {
|
||||
mKeyguardSliceViewController.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,8 +178,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
|
||||
}
|
||||
|
||||
/** Initialize the Controller. */
|
||||
public void init() {
|
||||
super.init();
|
||||
public void initInternal() {
|
||||
mKeyguardSecurityContainerController.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -190,8 +190,8 @@ public class KeyguardPatternViewController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
public void initInternal() {
|
||||
super.initInternal();
|
||||
mMessageAreaController.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -169,8 +169,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
public void initInternal() {
|
||||
mSecurityViewFlipperController.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
public void initInternal() {
|
||||
mKeyguardClockSwitchController.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@ public class QSContainerImplController extends ViewController<QSContainerImpl> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
public void initInternal() {
|
||||
mQuickStatusBarHeaderController.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T extends View> {
|
||||
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<T extends View> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user