Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Redirect single person search result to activity (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
OliHalu-zz authored and pfent committed Nov 12, 2017
1 parent 62d737f commit 474eeef
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ public void onStartSearch(String query) {
requestFetch();
}

private void proceedToPersonDetails(PersonList response ) {
lvPersons.setAdapter(null);
Bundle bundle = new Bundle();
bundle.putSerializable("personObject", response.getPersons().get(0));
Intent intent = new Intent(this, PersonsDetailsActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}

/**
* Handles the XML response from TUMOnline by de-serializing the information
* to model entities.
Expand All @@ -130,8 +139,10 @@ public void onStartSearch(String query) {
*/
@Override
public void onLoadFinished(PersonList response) {
if (response.getPersons() == null) {
if (response.getPersons() == null || response.getPersons().isEmpty()) {
lvPersons.setAdapter(new NoResultsAdapter(this));
} else if (response.getPersons().size() == 1){
proceedToPersonDetails(response);
} else {
ListAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, response.getPersons());
lvPersons.setAdapter(adapter);
Expand Down

0 comments on commit 474eeef

Please sign in to comment.