|
| 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 | + * Should be used on editor action listener methods in enhanced classes with view support |
| 25 | + * |
| 26 | + * The method may have some parameters amoung : |
| 27 | + * - a TextView |
| 28 | + * - an int : the actionId |
| 29 | + * - a KeyEvent |
| 30 | + * |
| 31 | + * The annotation value should be one of R.id.* fields. If not set, the method |
| 32 | + * name will be used as the R.id.* field name. |
| 33 | + * |
| 34 | + */ |
| 35 | + |
| 36 | +/** |
| 37 | + * This annotation is intended to be used on methods to receive events defined |
| 38 | + * by |
| 39 | + * {@link android.widget.TextView.OnEditorActionListener#onEditorAction(android.widget.TextView, int, android.view.KeyEvent)} |
| 40 | + * when an action is performed on the editor. |
| 41 | + * <p/> |
| 42 | + * The annotation value should be one or several R.id.* fields that refers to |
| 43 | + * TextView or subclasses of TextView. If not set, the method name will be used |
| 44 | + * as the R.id.* field name. |
| 45 | + * <p/> |
| 46 | + * The method MAY have multiple parameter : |
| 47 | + * <ul> |
| 48 | + * <li>A {@link android.widget.TextView} parameter to know which view has |
| 49 | + * targeted this event |
| 50 | + * <li>An int parameter to get the actionId |
| 51 | + * <li>A {@link android.view.KeyEvent} parameter |
| 52 | + * </ul> |
| 53 | + * <p/> |
| 54 | + * <blockquote> |
| 55 | + * |
| 56 | + * Examples : |
| 57 | + * |
| 58 | + * <pre> |
| 59 | + * @EditorAction(<b>R.id.helloTextView</b>) |
| 60 | + * void onEditorActionsOnHelloTextView(TextView hello, int actionId, KeyEvent keyEvent) { |
| 61 | + * // Something Here |
| 62 | + * } |
| 63 | + * |
| 64 | + * @EditorAction |
| 65 | + * void <b>helloTextView</b>EditorAction(TextView hello) { |
| 66 | + * // Something Here |
| 67 | + * } |
| 68 | + * |
| 69 | + * @EditorAction(<b>{R.id.editText, R.id.helloTextView}</b>) |
| 70 | + * void onEditorActionsOnSomeTextViews(TextView tv, int actionId) { |
| 71 | + * // Something Here |
| 72 | + * } |
| 73 | + * |
| 74 | + * @EditorAction(<b>R.id.helloTextView</b>) |
| 75 | + * void onEditorActionsOnHelloTextView() { |
| 76 | + * // Something Here |
| 77 | + * } |
| 78 | + * </pre> |
| 79 | + * |
| 80 | + * </blockquote> |
| 81 | + */ |
| 82 | +@Retention(RetentionPolicy.CLASS) |
| 83 | +@Target(ElementType.METHOD) |
| 84 | +public @interface EditorAction { |
| 85 | + |
| 86 | + int[] value() default ResId.DEFAULT_VALUE; |
| 87 | + |
| 88 | + String[] resName() default ""; |
| 89 | + |
| 90 | +} |
0 commit comments