Do not use hardcoded indexes
This commit is contained in:
parent
9573f7457e
commit
a7b07f3ce0
3 changed files with 22 additions and 14 deletions
|
@ -50,6 +50,8 @@ public interface SQLiteAPI {
|
||||||
byte[] getBlob(int ind);
|
byte[] getBlob(int ind);
|
||||||
|
|
||||||
boolean isNull(int ind);
|
boolean isNull(int ind);
|
||||||
|
|
||||||
|
int getColumnIndex(String columnName);
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package net.osmand.plus.api;
|
package net.osmand.plus.api;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
|
||||||
public class SQLiteAPIImpl implements SQLiteAPI {
|
public class SQLiteAPIImpl implements SQLiteAPI {
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
@ -84,6 +85,11 @@ public class SQLiteAPIImpl implements SQLiteAPI {
|
||||||
return c.isNull(ind);
|
return c.isNull(ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnIndex(String columnName) {
|
||||||
|
return c.getColumnIndex(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDouble(int ind) {
|
public double getDouble(int ind) {
|
||||||
|
|
|
@ -443,11 +443,11 @@ public class TravelLocalDataHelper {
|
||||||
private WikivoyageSearchHistoryItem readHistoryItem(SQLiteCursor cursor) {
|
private WikivoyageSearchHistoryItem readHistoryItem(SQLiteCursor cursor) {
|
||||||
WikivoyageSearchHistoryItem res = new WikivoyageSearchHistoryItem();
|
WikivoyageSearchHistoryItem res = new WikivoyageSearchHistoryItem();
|
||||||
|
|
||||||
res.cityId = cursor.getLong(0);
|
res.cityId = cursor.getLong(cursor.getColumnIndex(HISTORY_COL_CITY_ID));
|
||||||
res.articleTitle = cursor.getString(1);
|
res.articleTitle = cursor.getString(cursor.getColumnIndex(HISTORY_COL_ARTICLE_TITLE));
|
||||||
res.lang = cursor.getString(2);
|
res.lang = cursor.getString(cursor.getColumnIndex(HISTORY_COL_LANG));
|
||||||
res.isPartOf = cursor.getString(3);
|
res.isPartOf = cursor.getString(cursor.getColumnIndex(HISTORY_COL_IS_PART_OF));
|
||||||
res.lastAccessed = cursor.getLong(4);
|
res.lastAccessed = cursor.getLong(cursor.getColumnIndex(HISTORY_COL_LAST_ACCESSED));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -455,14 +455,14 @@ public class TravelLocalDataHelper {
|
||||||
private TravelArticle readSavedArticle(SQLiteCursor cursor) {
|
private TravelArticle readSavedArticle(SQLiteCursor cursor) {
|
||||||
TravelArticle res = new TravelArticle();
|
TravelArticle res = new TravelArticle();
|
||||||
|
|
||||||
res.tripId = cursor.getLong(0);
|
res.tripId = cursor.getLong(cursor.getColumnIndex(BOOKMARKS_COL_CITY_ID));
|
||||||
res.title = cursor.getString(1);
|
res.title = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_ARTICLE_TITLE));
|
||||||
res.lang = cursor.getString(2);
|
res.lang = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_LANG));
|
||||||
res.aggregatedPartOf = cursor.getString(3);
|
res.aggregatedPartOf = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_IS_PART_OF));
|
||||||
res.imageTitle = cursor.getString(4);
|
res.imageTitle = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_IMAGE_TITLE));
|
||||||
res.content = cursor.getString(5);
|
res.content = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_PARTIAL_CONTENT));
|
||||||
res.lat = cursor.getDouble(6);
|
res.lat = cursor.getDouble(cursor.getColumnIndex(BOOKMARKS_COL_LAT));
|
||||||
res.lon = cursor.getDouble(7);
|
res.lon = cursor.getDouble(cursor.getColumnIndex(BOOKMARKS_COL_LON));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue