Skip to content

Commit 75c1ba3

Browse files
committed
add ReceiverAction
1 parent 56d85fa commit 75c1ba3

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

  • AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* Copyright (C) 2010-2014 eBusiness Information, Excilys Group
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed To in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.androidannotations.annotations;
17+
18+
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
21+
import java.lang.annotation.Target;
22+
23+
/**
24+
* <p>
25+
* Should be used on a method that must respond to a specific action in an
26+
* {@link EReceiver} annotated class. The method name will be used as action
27+
* name unless the {@link #value()} field is set.
28+
* </p>
29+
* <p>
30+
* The method could contain any type or parameters.
31+
* </p>
32+
* <p>
33+
* The class MAY contain several {@link ReceiverAction} annotated methods.
34+
* </p>
35+
* <p>
36+
* You MAY use the {@link ReceiverAction.Extra} annotation on parameters to
37+
* define a different extra name.
38+
* </p>
39+
* <blockquote>
40+
*
41+
* Example :
42+
*
43+
* <pre>
44+
* &#064;EReceiver
45+
* public class MyIntentService extends BroadcastReceiver {
46+
*
47+
* &#064;ReceiverAction
48+
* void mySimpleAction() {
49+
* // ...
50+
* }
51+
*
52+
* &#064;ReceiverAction
53+
* void myAction(String valueString, long valueLong) {
54+
* // ...
55+
* }
56+
*
57+
* &#064;ReceiverAction
58+
* void anotherAction(@ReceiverAction.Extra(&quot;specialExtraName&quot;) String valueString, long valueLong) {
59+
* // ...
60+
* }
61+
* }
62+
* </pre>
63+
*
64+
* </blockquote>
65+
*
66+
* @see EIntentService
67+
*/
68+
@Retention(RetentionPolicy.CLASS)
69+
@Target(ElementType.METHOD)
70+
public @interface ReceiverAction {
71+
72+
/**
73+
* Define the action's name. If this field isn't set the annotated method
74+
* name will be used.
75+
*
76+
* @return the action's name
77+
*/
78+
String value() default "";
79+
80+
@Retention(RetentionPolicy.CLASS)
81+
@Target(ElementType.PARAMETER)
82+
public @interface Extra {
83+
84+
/**
85+
* Define the extra's name. If this parameter isn't set the annotated
86+
* parameter name will be used.
87+
*
88+
* @return the extra's name
89+
*/
90+
String value() default "";
91+
}
92+
}

0 commit comments

Comments
 (0)