Fixing some StrictMode violations, making it softer for others which the Android runtime itself triggers.

This commit is contained in:
Rodrigo Damazio
2010-12-10 16:40:22 -02:00
parent 6b4ea71404
commit 607b174c5f
4 changed files with 15 additions and 10 deletions
@@ -316,6 +316,8 @@ public class TrackWriter {
isLastValid = isValid;
} while (locationsCursor.moveToNext());
locationsCursor.close();
if (segmentOpen) {
writer.writeCloseSegment();
segmentOpen = false;
@@ -19,7 +19,6 @@ public class GingerbreadPlatformAdapter extends EclairPlatformAdapter {
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.penaltyDeath()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
@@ -824,14 +824,18 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public List<Track> getAllTracks() {
Cursor cursor = getTracksCursor(null);
if (cursor == null || !cursor.moveToFirst()) {
return new ArrayList<Track>();
}
ArrayList<Track> tracks = new ArrayList<Track>();
if (cursor != null) {
tracks.ensureCapacity(cursor.getCount());
List<Track> tracks = new ArrayList<Track>(cursor.getCount());
do {
tracks.add(createTrack(cursor));
} while(cursor.moveToNext());
if (cursor.moveToFirst()) {
do {
tracks.add(createTrack(cursor));
} while(cursor.moveToNext());
}
cursor.close();
}
return tracks;
}