diff options
author | marcinzelent <zelent.marcin@gmail.com> | 2018-04-19 23:03:13 +0200 |
---|---|---|
committer | marcinzelent <zelent.marcin@gmail.com> | 2018-04-19 23:03:13 +0200 |
commit | 4e6fc4fcdbcc3c75be13b3f8b80c24e4648fe354 (patch) | |
tree | 9588d81ee5e3e470d242f82b015fac6e34d54014 /app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java | |
parent | 7294c6bd32e362b4c0a64cadbf4dd2c191e1ad8e (diff) |
Added details view, improved observations list
Diffstat (limited to 'app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java')
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java b/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java index bcc9067..1d27e99 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java +++ b/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java @@ -1,11 +1,13 @@ package org.marcinzelent.liberavem; +import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @@ -18,7 +20,8 @@ import java.util.ArrayList; * A simple {@link Fragment} subclass. */ public class MyObservationsFragment extends Fragment { - + Observation[] observations; + Bird[] birds; public MyObservationsFragment() { // Required empty public constructor @@ -40,6 +43,22 @@ public class MyObservationsFragment extends Fragment { "String 3" }; ListView observationsListView = view.findViewById(R.id.observations_list_view); + + observationsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { + Intent detailsIntent = new Intent(getActivity(), ObservationDetailsActivity.class); + detailsIntent.putExtra("Observation", observations[position]); + + String photoUrl = ""; + for (Bird bird : birds) + if (bird.getId() == observations[position].getBirdId()) + photoUrl = bird.getPhotoUrl(); + detailsIntent.putExtra("Photo", photoUrl); + startActivity(detailsIntent); + } + }); + ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, list); observationsListView.setAdapter(adapter); } |