예제 #1
0
 private UserListService getUserListService() {
   UserListService userService = null;
   try {
     userService = userListServiceLocator.getService();
   } catch (ServiceNotBoundException e) {
     Log.w(TAG, "UserListService not bound");
   }
   return userService;
 }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    userAdapter = new UserListAdapter(getActivity(), new UserList(), true);
    userView = new LinearLayout(getActivity());

    userListServiceLocator =
        new ServiceLocator<UserListService>(
            this.getActivity(), UserListService.class, UserListService.UserListServiceBinder.class);

    // OnServiceBound needs the userAdapter so to avoid a race condition it
    // should be placed after the userAdapter is made.
    userListServiceLocator.setOnBindListener(
        new IOnBindListener() {
          @Override
          public void onServiceBound() {
            updateUserView();
          }
        });
    registerReceivers();
  }
예제 #3
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   userListServiceLocator.unbind();
   unregisterReceivers();
 }