-
-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathWaypointList.java
More file actions
69 lines (55 loc) · 1.75 KB
/
WaypointList.java
File metadata and controls
69 lines (55 loc) · 1.75 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
package net.osmtracker.activity;
import net.osmtracker.db.TrackContentProvider;
import net.osmtracker.db.WaypointListAdapter;
import android.app.ListActivity;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.net.Uri;
import android.view.View;
import android.widget.CursorAdapter;
import android.widget.ListView;
import java.io.File;
/**
* Activity that lists the previous waypoints tracked by the user.
*
* @author Nicolas Guillaumin
*
*/
public class WaypointList extends ListActivity {
@Override
protected void onResume() {
Long trackId = getIntent().getExtras().getLong(TrackContentProvider.Schema.COL_TRACK_ID);
Cursor cursor = getContentResolver().query(TrackContentProvider.waypointsUri(trackId),
null, null, null, TrackContentProvider.Schema.COL_TIMESTAMP + " desc");
startManagingCursor(cursor);
setListAdapter(new WaypointListAdapter(WaypointList.this, cursor));
super.onResume();
}
@Override
protected void onListItemClick(ListView lv, View v, int pos, long id) {
WaypointListAdapter wpa = (WaypointListAdapter)getListAdapter();
if (wpa != null) {
String audioFile = getIntent().getExtras().getString(TrackContentProvider.Schema.COL_LINK);
if (audioFile!=null && audioFile.endsWith(".3gpp")) {
Uri u = Uri.fromFile(new File(audioFile));
MediaPlayer player = MediaPlayer.create(this, u);
if (player != null) {
player.setLooping(false);
player.start();
}
}
}
}
@Override
protected void onPause() {
CursorAdapter adapter = (CursorAdapter) getListAdapter();
if (adapter != null) {
// Properly close the adapter cursor
Cursor cursor = adapter.getCursor();
stopManagingCursor(cursor);
cursor.close();
setListAdapter(null);
}
super.onPause();
}
}