From 474eeefbd63f11db6ec6ca9734917e500c0460a9 Mon Sep 17 00:00:00 2001 From: OliHalu <33519938+OliHalu@users.noreply.github.com> Date: Sun, 12 Nov 2017 13:32:56 +0100 Subject: [PATCH] Redirect single person search result to activity (#579) --- .../activities/PersonsSearchActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/activities/PersonsSearchActivity.java b/app/src/main/java/de/tum/in/tumcampusapp/activities/PersonsSearchActivity.java index 84b615d2e6..b287f09fc0 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/activities/PersonsSearchActivity.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/activities/PersonsSearchActivity.java @@ -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. @@ -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);