
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
78 lines
1.7 KiB
Plaintext
78 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
In certain Android methods, calls to the ``++super++`` version of the method should always come first. Otherwise, you risk leaving the job half-done.
|
|
|
|
|
|
This rule raises an issue when the following ``++Activity++`` methods do not begin with a call to ``++super++``:
|
|
|
|
* ``++onCreate++``
|
|
* ``++onConfigurationChanged++``
|
|
* ``++onPostCreate++``
|
|
* ``++onPostResume++``
|
|
* ``++onRestart++``
|
|
* ``++onRestoreInstanceState++``
|
|
* ``++onResume++``
|
|
* ``++onStart++``
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
public void onCreate(Bundle bundle) { // Noncompliant; super call missing
|
|
doSomething();
|
|
}
|
|
|
|
public void onPostCreate(Bundle bundle) {
|
|
doSomethingElse();
|
|
super.onPostCreate(bundle); // Noncompliant; should be first statement
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
doSomething();
|
|
}
|
|
|
|
public void onPostCreate(Bundle bundle) {
|
|
super.onPostCreate(bundle);
|
|
doSomethingElse();
|
|
}
|
|
----
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
* Move this "super" call to the beginning of the method.
|
|
* Add a "super" call at the beginning of the method.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 16 Jun 2015, 13:20:35 Nicolas Peru wrote:
|
|
The spec needs precision to be implemented : on which object are those methods defined ?
|
|
|
|
=== on 16 Jun 2015, 13:40:29 Ann Campbell wrote:
|
|
Honestly [~nicolas.peru], I had been hoping you'd know. :)
|
|
|
|
After a little research, it seems that it's ``++Activity++`` (sub)classes. I've updated accordingly.
|
|
|
|
=== on 16 Jun 2015, 14:28:21 Nicolas Peru wrote:
|
|
Looks good !
|
|
|
|
endif::env-github,rspecator-view[]
|