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; isLastValid = isValid;
} while (locationsCursor.moveToNext()); } while (locationsCursor.moveToNext());
locationsCursor.close();
if (segmentOpen) { if (segmentOpen) {
writer.writeCloseSegment(); writer.writeCloseSegment();
segmentOpen = false; segmentOpen = false;
@@ -19,7 +19,6 @@ public class GingerbreadPlatformAdapter extends EclairPlatformAdapter {
.detectDiskWrites() .detectDiskWrites()
.detectNetwork() .detectNetwork()
.penaltyLog() .penaltyLog()
.penaltyDeath()
.build()); .build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll() .detectAll()
@@ -824,14 +824,18 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override @Override
public List<Track> getAllTracks() { public List<Track> getAllTracks() {
Cursor cursor = getTracksCursor(null); Cursor cursor = getTracksCursor(null);
if (cursor == null || !cursor.moveToFirst()) { ArrayList<Track> tracks = new ArrayList<Track>();
return new ArrayList<Track>(); if (cursor != null) {
} tracks.ensureCapacity(cursor.getCount());
List<Track> tracks = new ArrayList<Track>(cursor.getCount()); if (cursor.moveToFirst()) {
do { do {
tracks.add(createTrack(cursor)); tracks.add(createTrack(cursor));
} while(cursor.moveToNext()); } while(cursor.moveToNext());
}
cursor.close();
}
return tracks; return tracks;
} }