AndroidAnnotations - 提高 Android 应用开发效率的框架
jopen
12年前
Android Annotations 是一个开源的框架,采用注释来提高 Android 应用开发效率,可以让你把重点放在功能的实现上,简化了代码,提升了可维护性。
示例代码:
@NoTitle @Fullscreen @EActivity(R.layout.bookmarks) public class BookmarksToClipboardActivity extends Activity { BookmarkAdapter adapter; @ViewById ListView bookmarkList; @ViewById EditText search; @App BookmarkApplication application; @RestService BookmarkClient restClient; @AnimationRes Animation fadeIn; @SystemService ClipboardManager clipboardManager; @AfterViews void initBookmarkList() { adapter = new BookmarkAdapter(this); bookmarkList.setAdapter(adapter); } @Click({R.id.updateBookmarksButton1, R.id.updateBookmarksButton2}) void updateBookmarksClicked() { searchAsync(search.getText().toString(), application.getUserId()); } @Background void searchAsync(String searchString, String userId) { Bookmarks bookmarks = restClient.getBookmarks(searchString, userId); updateBookmarks(bookmarks); } @UiThread void updateBookmarks(Bookmarks bookmarks) { adapter.updateBookmarks(bookmarks); bookmarkList.startAnimation(fadeIn); } @ItemClick void bookmarkListItemClicked(Bookmark selectedBookmark) { clipboardManager.setText(selectedBookmark.getUrl()); } }
@Rest("http://www.bookmarks.com") public interface BookmarkClient { @Get("/bookmarks/{userId}?search={search}") Bookmarks getBookmarks(String search, String userId); }