This commit is contained in:
Dennis Guse
2021-07-01 22:37:18 +02:00
parent 5899235b2b
commit c289fd174d
10 changed files with 9 additions and 27 deletions
@@ -503,7 +503,7 @@ public class CustomContentProviderUtilsTest {
contentProviderUtils.insertMarker(marker1); contentProviderUtils.insertMarker(marker1);
// Check insert was done. // Check insert was done.
assertEquals(contentProviderUtils.getMarkerCount(trackId), 1); assertEquals(contentProviderUtils.getMarkers(trackId).size(), 1);
// Get marker id that needs to delete. // Get marker id that needs to delete.
Marker.Id marker1Id = new Marker.Id(ContentUris.parseId(contentProviderUtils.insertMarker(marker1))); Marker.Id marker1Id = new Marker.Id(ContentUris.parseId(contentProviderUtils.insertMarker(marker1)));
@@ -530,7 +530,7 @@ public class CustomContentProviderUtilsTest {
contentProviderUtils.insertMarker(marker1); contentProviderUtils.insertMarker(marker1);
// Check insert was done. // Check insert was done.
assertEquals(contentProviderUtils.getMarkerCount(trackId), 1); assertEquals(contentProviderUtils.getMarkers(trackId).size(), 1);
// Get marker id that needs to delete. // Get marker id that needs to delete.
Marker.Id marker1Id = new Marker.Id(ContentUris.parseId(contentProviderUtils.insertMarker(marker1))); Marker.Id marker1Id = new Marker.Id(ContentUris.parseId(contentProviderUtils.insertMarker(marker1)));
@@ -341,7 +341,7 @@ public class ExportImportTest {
} }
private void assertMarkers() { private void assertMarkers() {
assertEquals(markers.size(), contentProviderUtils.getMarkerCount(importTrackId)); assertEquals(markers.size(), contentProviderUtils.getMarkers(importTrackId).size());
List<Marker> importedMarkers = contentProviderUtils.getMarkers(importTrackId); List<Marker> importedMarkers = contentProviderUtils.getMarkers(importTrackId);
for (int i = 0; i < markers.size(); i++) { for (int i = 0; i < markers.size(); i++) {
@@ -76,7 +76,7 @@ public class KMLImportTest {
assertEquals("", importedTrack.getIcon()); assertEquals("", importedTrack.getIcon());
// 2. markers // 2. markers
assertEquals(0, contentProviderUtils.getMarkerCount(importTrackId)); assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
// 3. trackpoints // 3. trackpoints
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId); List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
@@ -125,7 +125,7 @@ public class KMLImportTest {
assertEquals("", importedTrack.getIcon()); assertEquals("", importedTrack.getIcon());
// 2. markers // 2. markers
assertEquals(0, contentProviderUtils.getMarkerCount(importTrackId)); assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
// 3. trackpoints // 3. trackpoints
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId); List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
@@ -165,7 +165,7 @@ public class KMLImportTest {
assertEquals("UNKNOWN", importedTrack.getIcon()); assertEquals("UNKNOWN", importedTrack.getIcon());
// 2. markers // 2. markers
assertEquals(0, contentProviderUtils.getMarkerCount(importTrackId)); assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
// 3. trackpoints // 3. trackpoints
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId); List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
@@ -22,7 +22,6 @@ import androidx.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import de.dennisguse.opentracks.content.data.Track; import de.dennisguse.opentracks.content.data.Track;
@@ -42,7 +42,7 @@ public abstract class ShowOnMapProxyActivity extends AppCompatActivity {
* @param trackIds the track ids * @param trackIds the track ids
*/ */
private static void showTrackfileFormat(Context context, TrackFileFormat trackFileFormat, Set<Track.Id> trackIds) { private static void showTrackfileFormat(Context context, TrackFileFormat trackFileFormat, Set<Track.Id> trackIds) {
if (trackIds.size() == 0) { if (trackIds.isEmpty()) {
return; return;
} }
@@ -416,21 +416,6 @@ public class ContentProviderUtils {
return markers; return markers;
} }
//TODO Move to testing package
@Deprecated
public int getMarkerCount(Track.Id trackId) {
String[] projection = new String[]{"count(*) AS count"};
String selection = MarkerColumns.TRACKID + "=?";
String[] selectionArgs = new String[]{Long.toString(trackId.getId())};
try (Cursor cursor = contentResolver.query(MarkerColumns.CONTENT_URI, projection, selection, selectionArgs, MarkerColumns._ID)) {
if (cursor == null) {
return 0;
}
cursor.moveToFirst();
return cursor.getInt(0);
}
}
/** /**
* @return the content provider URI of the inserted marker. * @return the content provider URI of the inserted marker.
*/ */
@@ -77,7 +77,7 @@ public class ShareContentProvider extends CustomContentProvider {
} }
public static Pair<Uri, String> createURI(Set<Track.Id> trackIds, String trackName, @NonNull TrackFileFormat trackFileFormat) { public static Pair<Uri, String> createURI(Set<Track.Id> trackIds, String trackName, @NonNull TrackFileFormat trackFileFormat) {
if (trackIds.size() == 0) { if (trackIds.isEmpty()) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@@ -64,7 +64,6 @@ public class IntervalsFragment extends Fragment {
/** /**
* Creates an instance of this class. * Creates an instance of this class.
* *
* @param trackId
* @param fromTopToBottom If true then the intervals are shown from top to bottom (the first interval on top). Otherwise the intervals are shown from bottom to top. * @param fromTopToBottom If true then the intervals are shown from top to bottom (the first interval on top). Otherwise the intervals are shown from bottom to top.
* @return IntervalsFragment instance. * @return IntervalsFragment instance.
*/ */
@@ -136,7 +136,7 @@ public class IntentUtils {
uris.add(marker.getPhotoURI()); uris.add(marker.getPhotoURI());
} }
if (uris.size() == 0) { if (uris.isEmpty()) {
return null; return null;
} }
@@ -37,7 +37,6 @@ public class IntervalStatistics {
/** /**
* Complete intervals with the tracks points from the iterator. * Complete intervals with the tracks points from the iterator.
* *
* @param trackPointIterator
* @return the last track point's id used to compute the intervals. * @return the last track point's id used to compute the intervals.
*/ */
public TrackPoint.Id addTrackPoints(TrackPointIterator trackPointIterator) { public TrackPoint.Id addTrackPoints(TrackPointIterator trackPointIterator) {