blob: d0ad64979775477f5e245c72c9575a8a8cda1bd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
/**
* A simple {@link Fragment} subclass.
*/
public class MyObservationsFragment extends Fragment {
public MyObservationsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.observations_list, container, false);
return rootView;
}
public void populateList(final Observation[] observations, final Bird[] birds) {
final ListView observationsListView = getView().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);
}
});
final ObservationsListAdapter adapter = new ObservationsListAdapter(getActivity(), observations, birds);
observationsListView.setAdapter(adapter);
}
}
|