@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { User listSelectedUser = (User) parent.getItemAtPosition(position); User newSelectedUser = selectedUser == listSelectedUser ? null : listSelectedUser; // Unset if is already selected user setChatTarget(newSelectedUser); channelProvider.setChatTarget(newSelectedUser); };
/** Updates the users display with the data from the channelProvider. */ public void updateChannel() { // We need to make sure the fragment has been attached and is shown before updating the users. usersAdapter.setVisibleChannel(channelProvider.getChannel().id); usersAdapter.setUsers(channelProvider.getChannelUsers()); usersAdapter.notifyDataSetChanged(); }