optimize db access

itemized2sql
Georg Lukas 2010-12-13 16:50:25 +01:00
rodzic bd8b30e4ed
commit 041c7c7602
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -113,7 +113,8 @@ class StationOverlay(icons : Drawable) extends ItemizedOverlay[Station](icons) {
} }
def loadDb(db : StorageDatabase) { def loadDb(db : StorageDatabase) {
val c = db.getPositions(null, null, "100") stations.clear()
val c = db.getPositions(null, null, null)
c.moveToFirst() c.moveToFirst()
while (!c.isAfterLast()) { while (!c.isAfterLast()) {
val call = c.getString(c.getColumnIndexOrThrow(StorageDatabase.Position.CALL)) val call = c.getString(c.getColumnIndexOrThrow(StorageDatabase.Position.CALL))
@ -125,6 +126,8 @@ class StationOverlay(icons : Drawable) extends ItemizedOverlay[Station](icons) {
c.moveToNext() c.moveToNext()
} }
c.close() c.close()
setLastFocusedIndex(-1)
populate()
Log.d("StationOverlay", "total %d items".format(size())) Log.d("StationOverlay", "total %d items".format(size()))
} }
@ -133,7 +136,6 @@ class StationOverlay(icons : Drawable) extends ItemizedOverlay[Station](icons) {
// return // return
//calls.add(sta.getTitle(), true) //calls.add(sta.getTitle(), true)
stations.add(sta) stations.add(sta)
populate()
} }
def addStation(post : String) { def addStation(post : String) {