forked from upstream-mirrors/OpenTracks
Cleanup: ContentProviderUtils.getMarkerCursor() has an optional parameter.
This commit is contained in:
@@ -255,7 +255,7 @@ public class ContentProviderUtils {
|
|||||||
* @param selectionArgs the selection arguments. Can be null
|
* @param selectionArgs the selection arguments. Can be null
|
||||||
* @param sortOrder the sort order. Can be null
|
* @param sortOrder the sort order. Can be null
|
||||||
*/
|
*/
|
||||||
public Cursor getTrackCursor(String selection, String[] selectionArgs, String sortOrder) {
|
Cursor getTrackCursor(String selection, String[] selectionArgs, String sortOrder) {
|
||||||
return contentResolver.query(TracksColumns.CONTENT_URI, null, selection, selectionArgs, sortOrder);
|
return contentResolver.query(TracksColumns.CONTENT_URI, null, selection, selectionArgs, sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,6 +322,7 @@ public class ContentProviderUtils {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Align with fillTrackPoint
|
||||||
public Marker createMarker(Cursor cursor) {
|
public Marker createMarker(Cursor cursor) {
|
||||||
int idIndex = cursor.getColumnIndexOrThrow(MarkerColumns._ID);
|
int idIndex = cursor.getColumnIndexOrThrow(MarkerColumns._ID);
|
||||||
int nameIndex = cursor.getColumnIndexOrThrow(MarkerColumns.NAME);
|
int nameIndex = cursor.getColumnIndexOrThrow(MarkerColumns.NAME);
|
||||||
@@ -430,6 +431,10 @@ public class ContentProviderUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cursor getMarkerCursor(@NonNull Track.Id trackId) {
|
||||||
|
return getMarkerCursor(trackId, -1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The caller owns the returned cursor and is responsible for closing it.
|
* The caller owns the returned cursor and is responsible for closing it.
|
||||||
*
|
*
|
||||||
@@ -450,7 +455,7 @@ public class ContentProviderUtils {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public List<Marker> getMarkers(Track.Id trackId) {
|
public List<Marker> getMarkers(Track.Id trackId) {
|
||||||
ArrayList<Marker> markers = new ArrayList<>();
|
ArrayList<Marker> markers = new ArrayList<>();
|
||||||
try (Cursor cursor = getMarkerCursor(trackId, -1)) {
|
try (Cursor cursor = getMarkerCursor(trackId)) {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
markers.add(createMarker(cursor));
|
markers.add(createMarker(cursor));
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ public class GPXTrackExporter implements TrackExporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeMarkers(Track track) throws InterruptedException {
|
private void writeMarkers(Track track) throws InterruptedException {
|
||||||
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId(), -1)) {
|
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId())) {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
for (int i = 0; i < cursor.getCount(); i++) {
|
for (int i = 0; i < cursor.getCount(); i++) {
|
||||||
if (Thread.interrupted()) {
|
if (Thread.interrupted()) {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class KMLTrackExporter implements TrackExporter {
|
|||||||
|
|
||||||
private void writeMarkers(Track track) throws InterruptedException {
|
private void writeMarkers(Track track) throws InterruptedException {
|
||||||
boolean hasMarkers = false;
|
boolean hasMarkers = false;
|
||||||
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId(), -1)) {
|
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId())) {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
for (int i = 0; i < cursor.getCount(); i++) {
|
for (int i = 0; i < cursor.getCount(); i++) {
|
||||||
if (Thread.interrupted()) {
|
if (Thread.interrupted()) {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class KMZTrackExporter implements TrackExporter {
|
|||||||
|
|
||||||
private void addImages(Context context, List<Track> tracks, ZipOutputStream zipOutputStream) throws InterruptedException, IOException {
|
private void addImages(Context context, List<Track> tracks, ZipOutputStream zipOutputStream) throws InterruptedException, IOException {
|
||||||
for (Track track : tracks) {
|
for (Track track : tracks) {
|
||||||
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId(), -1)) {
|
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId())) {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
for (int i = 0; i < cursor.getCount(); i++) {
|
for (int i = 0; i < cursor.getCount(); i++) {
|
||||||
if (Thread.interrupted()) {
|
if (Thread.interrupted()) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package de.dennisguse.opentracks.io.file.importer;
|
package de.dennisguse.opentracks.io.file.importer;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class MarkerDetailActivity extends AbstractActivity implements DeleteMark
|
|||||||
Marker marker = contentProviderUtils.getMarker(markerId);
|
Marker marker = contentProviderUtils.getMarker(markerId);
|
||||||
|
|
||||||
//TODO only load used data: ID + name
|
//TODO only load used data: ID + name
|
||||||
cursor = contentProviderUtils.getMarkerCursor(marker.getTrackId(), -1);
|
cursor = contentProviderUtils.getMarkerCursor(marker.getTrackId());
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user