diff options
Diffstat (limited to 'main/src/cgeo/geocaching/cgData.java')
| -rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 37b20ad..1724fdd 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -221,6 +221,7 @@ public class cgData { public boolean initialized = false; private SQLiteStatement statementDescription; private SQLiteStatement statementLogCount; + private static boolean newlyCreatedDatabase = false; public cgData(Context contextIn) { context = contextIn; @@ -385,6 +386,7 @@ public class cgData { @Override public void onCreate(SQLiteDatabase db) { + newlyCreatedDatabase = true; db.execSQL(dbCreateCaches); db.execSQL(dbCreateLists); db.execSQL(dbCreateAttributes); @@ -1554,9 +1556,9 @@ public class cgData { values.clear(); values.put("geocode", geocode); values.put("updated", timeStamp); - values.put("url", oneSpoiler.url); - values.put("title", oneSpoiler.title); - values.put("description", oneSpoiler.description); + values.put("url", oneSpoiler.getUrl()); + values.put("title", oneSpoiler.getTitle()); + values.put("description", oneSpoiler.getDescription()); databaseRW.insert(dbTableSpoilers, null, values); } @@ -1608,8 +1610,8 @@ public class cgData { for (cgImage img : log.logImages) { values.clear(); values.put("log_id", log_id); - values.put("title", img.title); - values.put("url", img.url); + values.put("title", img.getTitle()); + values.put("url", img.getUrl()); databaseRW.insert(dbTableLogImages, null, values); } } @@ -2226,7 +2228,7 @@ public class cgData { waypoint.setId(cursor.getInt(cursor.getColumnIndex("_id"))); waypoint.setGeocode(cursor.getString(cursor.getColumnIndex("geocode"))); - waypoint.setWaypointType(WaypointType.FIND_BY_ID.get(cursor.getString(cursor.getColumnIndex("type")))); + waypoint.setWaypointType(WaypointType.findById(cursor.getString(cursor.getColumnIndex("type")))); waypoint.setPrefix(cursor.getString(cursor.getColumnIndex("prefix"))); waypoint.setLookup(cursor.getString(cursor.getColumnIndex("lookup"))); waypoint.setName(cursor.getString(cursor.getColumnIndex("name"))); @@ -2263,10 +2265,7 @@ public class cgData { int indexDescription = cursor.getColumnIndex("description"); do { - cgImage spoiler = new cgImage(); - spoiler.url = cursor.getString(indexUrl); - spoiler.title = cursor.getString(indexTitle); - spoiler.description = cursor.getString(indexDescription); + cgImage spoiler = new cgImage(cursor.getString(indexUrl), cursor.getString(indexTitle), cursor.getString(indexDescription)); spoilers.add(spoiler); } while (cursor.moveToNext()); @@ -2382,18 +2381,12 @@ public class cgData { logs.add(log); } if (!cursor.isNull(indexLogImagesId)) { - final cgImage log_img = new cgImage(); - log_img.title = cursor.getString(indexTitle); - if (log_img.title == null) { - log_img.title = ""; - } - log_img.url = cursor.getString(indexUrl); - if (log_img.url == null) { - log_img.url = ""; - } + String title = cursor.getString(indexTitle); + String url = cursor.getString(indexUrl); if (log.logImages == null) { log.logImages = new ArrayList<cgImage>(); } + final cgImage log_img = new cgImage(url, title); log.logImages.add(log_img); } } @@ -3373,4 +3366,20 @@ public class cgData { return null; } + + /** + * checks if this is a newly created database + * + * @return + */ + public static boolean isNewlyCreatedDatebase() { + return newlyCreatedDatabase; + } + + /** + * resets flag for newly created database to avoid asking the user multiple times + */ + public static void resetNewlyCreatedDatabase() { + newlyCreatedDatabase = false; + } } |
