use of com.sleepycookie.stillstanding.data.AppDatabase in project stillStanding by katsik.
the class IncidentHistory method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
// Get a support ActionBar corresponding to this toolbar
ActionBar ab = getSupportActionBar();
// Enable the Up button
ab.setDisplayHomeAsUpEnabled(true);
AppDatabase db = AppDatabase.getInstance(this);
final ArrayList<Incident> incidents = new ArrayList<Incident>();
Collections.addAll(incidents, db.incidentDao().loadAllIncidents());
IncidentAdapter adapter = new IncidentAdapter(this, incidents);
ListView listView = (ListView) findViewById(R.id.history);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
long viewId = view.getId();
if (viewId == R.id.incident_location) {
Incident tempIncident = incidents.get(position);
StringBuffer url = new StringBuffer();
url.append("http://maps.google.com?q=");
url.append(String.format("%.7f", tempIncident.getLatitude()));
url.append(",");
url.append(String.format("%.7f", tempIncident.getLongitude()));
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url.toString()));
startActivity(i);
} else if (viewId == R.id.list_item) {
}
}
});
}
Aggregations