利用androidannotations的@Backgroud及@UiThread注解替换原生AsyncTask的写法
... @Overridepublic void onStart() {super.onStart();showLoadingProgressDialog();downloadUsersTask();}@Backgroundvoid downloadUsersTask() {ResponseEntity<User[]> responseEntity = restApiService.getUsersByStatus();List<User> users = Arrays.asList(responseEntity.getBody());testTismissProgressDialog(users);}@UiThreadvoid testTismissProgressDialog(List<User> users) {dismissProgressDialog();refreshResult(users);}private void refreshResult(List<User> users) {if(users == null) {return;}UserListAdapter adapter = new UserListAdapter(this,users);setListAdapter(adapter);}...
?
是不是清晰、简洁了很多~
?
相关参考:
https://github.com/excilys/androidannotations/wiki/WorkingWithThreads