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);
// Check insert was done.
assertEquals(contentProviderUtils.getMarkerCount(trackId), 1);
assertEquals(contentProviderUtils.getMarkers(trackId).size(), 1);
// Get marker id that needs to delete.
Marker.Id marker1Id = new Marker.Id(ContentUris.parseId(contentProviderUtils.insertMarker(marker1)));
@@ -530,7 +530,7 @@ public class CustomContentProviderUtilsTest {
contentProviderUtils.insertMarker(marker1);
// Check insert was done.
assertEquals(contentProviderUtils.getMarkerCount(trackId), 1);
assertEquals(contentProviderUtils.getMarkers(trackId).size(), 1);
// Get marker id that needs to delete.
Marker.Id marker1Id = new Marker.Id(ContentUris.parseId(contentProviderUtils.insertMarker(marker1)));
@@ -341,7 +341,7 @@ public class ExportImportTest {
}
private void assertMarkers() {
assertEquals(markers.size(), contentProviderUtils.getMarkerCount(importTrackId));
assertEquals(markers.size(), contentProviderUtils.getMarkers(importTrackId).size());
List<Marker> importedMarkers = contentProviderUtils.getMarkers(importTrackId);
for (int i = 0; i < markers.size(); i++) {
@@ -76,7 +76,7 @@ public class KMLImportTest {
assertEquals("", importedTrack.getIcon());
// 2. markers
assertEquals(0, contentProviderUtils.getMarkerCount(importTrackId));
assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
// 3. trackpoints
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
@@ -125,7 +125,7 @@ public class KMLImportTest {
assertEquals("", importedTrack.getIcon());
// 2. markers
assertEquals(0, contentProviderUtils.getMarkerCount(importTrackId));
assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
// 3. trackpoints
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
@@ -165,7 +165,7 @@ public class KMLImportTest {
assertEquals("UNKNOWN", importedTrack.getIcon());
// 2. markers
assertEquals(0, contentProviderUtils.getMarkerCount(importTrackId));
assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
// 3. trackpoints
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
@@ -22,7 +22,6 @@ import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;
import de.dennisguse.opentracks.content.data.Track;
@@ -42,7 +42,7 @@ public abstract class ShowOnMapProxyActivity extends AppCompatActivity {
* @param trackIds the track ids
*/
private static void showTrackfileFormat(Context context, TrackFileFormat trackFileFormat, Set<Track.Id> trackIds) {
if (trackIds.size() == 0) {
if (trackIds.isEmpty()) {
return;
}
@@ -416,21 +416,6 @@ public class ContentProviderUtils {
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.
*/
@@ -77,7 +77,7 @@ public class ShareContentProvider extends CustomContentProvider {
}
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();
}
@@ -64,7 +64,6 @@ public class IntervalsFragment extends Fragment {
/**
* 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.
* @return IntervalsFragment instance.
*/
@@ -136,7 +136,7 @@ public class IntentUtils {
uris.add(marker.getPhotoURI());
}
if (uris.size() == 0) {
if (uris.isEmpty()) {
return null;
}
@@ -37,7 +37,6 @@ public class IntervalStatistics {
/**
* Complete intervals with the tracks points from the iterator.
*
* @param trackPointIterator
* @return the last track point's id used to compute the intervals.
*/
public TrackPoint.Id addTrackPoints(TrackPointIterator trackPointIterator) {