Fix database
This commit is contained in:
parent
075fcf7806
commit
50ebbeefd6
3 changed files with 42 additions and 10 deletions
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
public class GPXDatabase {
|
||||
|
||||
private static final String DB_NAME = "gpx_database";
|
||||
private static final int DB_VERSION = 4;
|
||||
private static final int DB_VERSION = 5;
|
||||
private static final String GPX_TABLE_NAME = "gpxTable";
|
||||
private static final String GPX_COL_NAME = "fileName";
|
||||
private static final String GPX_COL_DIR = "fileDir";
|
||||
|
@ -184,12 +184,44 @@ public class GPXDatabase {
|
|||
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double");
|
||||
}
|
||||
|
||||
if (oldVersion < 3) {
|
||||
if (oldVersion < 5) {
|
||||
boolean colorColumnExists = false;
|
||||
boolean fileLastModifiedTimeColumnExists = false;
|
||||
boolean splitTypeColumnExists = false;
|
||||
boolean splitIntervalColumnExists = false;
|
||||
SQLiteCursor cursor = db.rawQuery("PRAGMA table_info(" + GPX_TABLE_NAME + ")", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
String columnName = cursor.getString(1);
|
||||
if (!colorColumnExists && columnName.equals(GPX_COL_COLOR)) {
|
||||
colorColumnExists = true;
|
||||
} else if (!fileLastModifiedTimeColumnExists && columnName.equals(GPX_COL_FILE_LAST_MODIFIED_TIME)) {
|
||||
fileLastModifiedTimeColumnExists = true;
|
||||
} else if (!splitTypeColumnExists && columnName.equals(GPX_COL_SPLIT_TYPE)) {
|
||||
splitTypeColumnExists = true;
|
||||
} else if (!splitIntervalColumnExists && columnName.equals(GPX_COL_SPLIT_INTERVAL)) {
|
||||
splitIntervalColumnExists = true;
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
if (!colorColumnExists) {
|
||||
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_COLOR + " TEXT");
|
||||
}
|
||||
if (!fileLastModifiedTimeColumnExists) {
|
||||
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_FILE_LAST_MODIFIED_TIME + " long");
|
||||
List<GpxDataItem> items = getItems();
|
||||
for (GpxDataItem item : items) {
|
||||
updateLastModifiedTime(item);
|
||||
}
|
||||
}
|
||||
if (!splitTypeColumnExists) {
|
||||
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_TYPE + " int");
|
||||
}
|
||||
if (!splitIntervalColumnExists) {
|
||||
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updateLastModifiedTime(GpxDataItem item) {
|
||||
|
|
|
@ -165,7 +165,7 @@ public class DashTrackFragment extends DashBaseFragment {
|
|||
info.subfolder = "";
|
||||
info.file = f;
|
||||
View v = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
|
||||
AvailableGPXFragment.udpateGpxInfoView(v, info, app, true);
|
||||
AvailableGPXFragment.updateGpxInfoView(v, info, app, true);
|
||||
|
||||
v.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -257,7 +257,7 @@ public class DashTrackFragment extends DashBaseFragment {
|
|||
AvailableGPXFragment.GpxInfo info = new AvailableGPXFragment.GpxInfo();
|
||||
info.subfolder = "";
|
||||
info.file = f;
|
||||
AvailableGPXFragment.udpateGpxInfoView(pView, info, app, true);
|
||||
AvailableGPXFragment.updateGpxInfoView(pView, info, app, true);
|
||||
updateShowOnMap(app, f, v, showOnMap);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1048,7 +1048,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false);
|
||||
}
|
||||
udpateGpxInfoView(v, child, app, false);
|
||||
updateGpxInfoView(v, child, app, false);
|
||||
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
ImageButton options = (ImageButton) v.findViewById(R.id.options);
|
||||
|
@ -1752,7 +1752,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public static void udpateGpxInfoView(View v, GpxInfo child, OsmandApplication app, boolean isDashItem) {
|
||||
public static void updateGpxInfoView(View v, GpxInfo child, OsmandApplication app, boolean isDashItem) {
|
||||
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
||||
if (!isDashItem) {
|
||||
v.findViewById(R.id.divider_list).setVisibility(View.VISIBLE);
|
||||
|
|
Loading…
Reference in a new issue