mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 16:48:49 +00:00
QueryHistoryProvider: Fix mapping of null coord to 0/0 ints.
This commit is contained in:
parent
1ded58bc56
commit
78fdf6d43f
3 changed files with 44 additions and 25 deletions
|
@ -1299,22 +1299,31 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
||||||
final String fromName = cursor.getString(fromNameC);
|
final String fromName = cursor.getString(fromNameC);
|
||||||
if (fromName.toLowerCase(Constants.DEFAULT_LOCALE)
|
if (fromName.toLowerCase(Constants.DEFAULT_LOCALE)
|
||||||
.contains(constraintStr.toLowerCase(Constants.DEFAULT_LOCALE))) {
|
.contains(constraintStr.toLowerCase(Constants.DEFAULT_LOCALE))) {
|
||||||
final Location location = new Location(
|
final LocationType fromType = QueryHistoryProvider
|
||||||
QueryHistoryProvider.convert(cursor.getInt(fromTypeC)),
|
.convert(cursor.getInt(fromTypeC));
|
||||||
cursor.getString(fromIdC),
|
final String fromId = cursor.getString(fromIdC);
|
||||||
Point.from1E6(cursor.getInt(fromLatC), cursor.getInt(fromLonC)),
|
final int fromLat = cursor.getInt(fromLatC);
|
||||||
cursor.getString(fromPlaceC), fromName);
|
final int fromLon = cursor.getInt(fromLonC);
|
||||||
|
final Point fromCoord = fromLat != 0 || fromLon != 0
|
||||||
|
? Point.from1E6(fromLat, fromLon) : null;
|
||||||
|
final String fromPlace = cursor.getString(fromPlaceC);
|
||||||
|
final Location location = new Location(fromType, fromId, fromCoord, fromPlace,
|
||||||
|
fromName);
|
||||||
if (!results.contains(location))
|
if (!results.contains(location))
|
||||||
results.add(location);
|
results.add(location);
|
||||||
}
|
}
|
||||||
final String toName = cursor.getString(toNameC);
|
final String toName = cursor.getString(toNameC);
|
||||||
if (toName.toLowerCase(Constants.DEFAULT_LOCALE)
|
if (toName.toLowerCase(Constants.DEFAULT_LOCALE)
|
||||||
.contains(constraintStr.toLowerCase(Constants.DEFAULT_LOCALE))) {
|
.contains(constraintStr.toLowerCase(Constants.DEFAULT_LOCALE))) {
|
||||||
final Location location = new Location(
|
final LocationType toType = QueryHistoryProvider
|
||||||
QueryHistoryProvider.convert(cursor.getInt(toTypeC)),
|
.convert(cursor.getInt(toTypeC));
|
||||||
cursor.getString(toIdC),
|
final String toId = cursor.getString(toIdC);
|
||||||
Point.from1E6(cursor.getInt(toLatC), cursor.getInt(toLonC)),
|
final int toLat = cursor.getInt(toLatC);
|
||||||
cursor.getString(toPlaceC), toName);
|
final int toLon = cursor.getInt(toLonC);
|
||||||
|
final Point toCoord = toLat != 0 || toLon != 0 ? Point.from1E6(toLat, toLon)
|
||||||
|
: null;
|
||||||
|
final String toPlace = cursor.getString(toPlaceC);
|
||||||
|
final Location location = new Location(toType, toId, toCoord, toPlace, toName);
|
||||||
if (!results.contains(location))
|
if (!results.contains(location))
|
||||||
results.add(location);
|
results.add(location);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,8 @@ public class QueryHistoryProvider extends ContentProvider {
|
||||||
|
|
||||||
if (cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_FROM_LAT)) == 0
|
if (cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_FROM_LAT)) == 0
|
||||||
&& cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_FROM_LON)) == 0) {
|
&& cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_FROM_LON)) == 0) {
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_LAT, from.getLatAs1E6());
|
values.put(QueryHistoryProvider.KEY_FROM_LAT, from.hasCoord() ? from.getLatAs1E6() : 0);
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_LON, from.getLonAs1E6());
|
values.put(QueryHistoryProvider.KEY_FROM_LON, from.hasCoord() ? from.getLonAs1E6() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_TO_ID)) == 0)
|
if (cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_TO_ID)) == 0)
|
||||||
|
@ -105,8 +105,8 @@ public class QueryHistoryProvider extends ContentProvider {
|
||||||
|
|
||||||
if (cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_TO_LAT)) == 0
|
if (cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_TO_LAT)) == 0
|
||||||
&& cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_TO_LON)) == 0) {
|
&& cursor.getInt(cursor.getColumnIndexOrThrow(QueryHistoryProvider.KEY_TO_LON)) == 0) {
|
||||||
values.put(QueryHistoryProvider.KEY_TO_LAT, to.getLatAs1E6());
|
values.put(QueryHistoryProvider.KEY_TO_LAT, to.hasCoord() ? to.getLatAs1E6() : 0);
|
||||||
values.put(QueryHistoryProvider.KEY_TO_LON, to.getLonAs1E6());
|
values.put(QueryHistoryProvider.KEY_TO_LON, to.hasCoord() ? to.getLonAs1E6() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (favorite != null)
|
if (favorite != null)
|
||||||
|
@ -125,14 +125,14 @@ public class QueryHistoryProvider extends ContentProvider {
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_TYPE, QueryHistoryProvider.convert(from.type));
|
values.put(QueryHistoryProvider.KEY_FROM_TYPE, QueryHistoryProvider.convert(from.type));
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_ID, from.id);
|
values.put(QueryHistoryProvider.KEY_FROM_ID, from.id);
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_LAT, from.getLatAs1E6());
|
values.put(QueryHistoryProvider.KEY_FROM_LAT, from.hasCoord() ? from.getLatAs1E6() : 0);
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_LON, from.getLonAs1E6());
|
values.put(QueryHistoryProvider.KEY_FROM_LON, from.hasCoord() ? from.getLonAs1E6() : 0);
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_PLACE, from.place);
|
values.put(QueryHistoryProvider.KEY_FROM_PLACE, from.place);
|
||||||
values.put(QueryHistoryProvider.KEY_FROM_NAME, from.name);
|
values.put(QueryHistoryProvider.KEY_FROM_NAME, from.name);
|
||||||
values.put(QueryHistoryProvider.KEY_TO_TYPE, QueryHistoryProvider.convert(to.type));
|
values.put(QueryHistoryProvider.KEY_TO_TYPE, QueryHistoryProvider.convert(to.type));
|
||||||
values.put(QueryHistoryProvider.KEY_TO_ID, to.id);
|
values.put(QueryHistoryProvider.KEY_TO_ID, to.id);
|
||||||
values.put(QueryHistoryProvider.KEY_TO_LAT, to.getLatAs1E6());
|
values.put(QueryHistoryProvider.KEY_TO_LAT, to.hasCoord() ? to.getLatAs1E6() : 0);
|
||||||
values.put(QueryHistoryProvider.KEY_TO_LON, to.getLonAs1E6());
|
values.put(QueryHistoryProvider.KEY_TO_LON, to.hasCoord() ? to.getLonAs1E6() : 0);
|
||||||
values.put(QueryHistoryProvider.KEY_TO_PLACE, to.place);
|
values.put(QueryHistoryProvider.KEY_TO_PLACE, to.place);
|
||||||
values.put(QueryHistoryProvider.KEY_TO_NAME, to.name);
|
values.put(QueryHistoryProvider.KEY_TO_NAME, to.name);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import de.schildbach.oeffi.directions.QueryHistoryProvider;
|
||||||
import de.schildbach.oeffi.stations.FavoriteStationsProvider;
|
import de.schildbach.oeffi.stations.FavoriteStationsProvider;
|
||||||
import de.schildbach.pte.NetworkId;
|
import de.schildbach.pte.NetworkId;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.Point;
|
import de.schildbach.pte.dto.Point;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
@ -184,13 +185,22 @@ public class QueryHistoryAdapter extends RecyclerView.Adapter<QueryHistoryViewHo
|
||||||
public void onBindViewHolder(final QueryHistoryViewHolder holder, final int position) {
|
public void onBindViewHolder(final QueryHistoryViewHolder holder, final int position) {
|
||||||
cursor.moveToPosition(position);
|
cursor.moveToPosition(position);
|
||||||
final long rowId = cursor.getLong(rowIdColumn);
|
final long rowId = cursor.getLong(rowIdColumn);
|
||||||
final Location from = new Location(QueryHistoryProvider.convert(cursor.getInt(fromTypeColumn)),
|
final LocationType fromType = QueryHistoryProvider.convert(cursor.getInt(fromTypeColumn));
|
||||||
cursor.getString(fromIdColumn),
|
final String fromId = cursor.getString(fromIdColumn);
|
||||||
Point.from1E6(cursor.getInt(fromLatColumn), cursor.getInt(fromLonColumn)),
|
final int fromLat = cursor.getInt(fromLatColumn);
|
||||||
cursor.getString(fromPlaceColumn), cursor.getString(fromNameColumn));
|
final int fromLon = cursor.getInt(fromLonColumn);
|
||||||
final Location to = new Location(QueryHistoryProvider.convert(cursor.getInt(toTypeColumn)),
|
final Point fromCoord = fromLat != 0 || fromLon != 0 ? Point.from1E6(fromLat, fromLon) : null;
|
||||||
cursor.getString(toIdColumn), Point.from1E6(cursor.getInt(toLatColumn), cursor.getInt(toLonColumn)),
|
final String fromPlace = cursor.getString(fromPlaceColumn);
|
||||||
cursor.getString(toPlaceColumn), cursor.getString(toNameColumn));
|
final String fromName = cursor.getString(fromNameColumn);
|
||||||
|
final Location from = new Location(fromType, fromId, fromCoord, fromPlace, fromName);
|
||||||
|
final LocationType toType = QueryHistoryProvider.convert(cursor.getInt(toTypeColumn));
|
||||||
|
final String toId = cursor.getString(toIdColumn);
|
||||||
|
final int toLat = cursor.getInt(toLatColumn);
|
||||||
|
final int toLon = cursor.getInt(toLonColumn);
|
||||||
|
final Point toCoord = toLat != 0 || toLon != 0 ? Point.from1E6(toLat, toLon) : null;
|
||||||
|
final String toPlace = cursor.getString(toPlaceColumn);
|
||||||
|
final String toName = cursor.getString(toNameColumn);
|
||||||
|
final Location to = new Location(toType, toId, toCoord, toPlace, toName);
|
||||||
final boolean isFavorite = cursor.getInt(favoriteColumn) == 1;
|
final boolean isFavorite = cursor.getInt(favoriteColumn) == 1;
|
||||||
final long savedTripDepartureTime = cursor.getLong(savedTripDepartureTimeColumn);
|
final long savedTripDepartureTime = cursor.getLong(savedTripDepartureTimeColumn);
|
||||||
final byte[] serializedSavedTrip = cursor.getBlob(savedTripColumn);
|
final byte[] serializedSavedTrip = cursor.getBlob(savedTripColumn);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue