Merge branch 'master' into fap

storage_ts_index
Georg Lukas 2011-02-05 14:41:14 +01:00
commit acc5b62abc
2 zmienionych plików z 32 dodań i 19 usunięć

Wyświetl plik

@ -181,14 +181,19 @@ class StationOverlay(icons : Drawable, context : Context, db : StorageDatabase)
val iconbitmap = icons.asInstanceOf[BitmapDrawable].getBitmap
val p = new Point()
val proj = m.getProjection()
val zoom = m.getZoomLevel()
val (width, height) = (m.getWidth(), m.getHeight())
for (s <- stations) {
m.getProjection().toPixels(s.point, p)
if (p.x >= 0 && p.y >= 0 && p.x < m.getWidth() && p.y < m.getHeight()) {
proj.toPixels(s.point, p)
if (p.x >= 0 && p.y >= 0 && p.x < width && p.y < height) {
val srcRect = symbol2rect(s.symbol)
val destRect = new Rect(p.x-8, p.y-8, p.x+8, p.y+8)
// first draw callsign and trace
if (m.getZoomLevel() >= 10) {
if (zoom >= 10) {
Benchmark("drawTrace") {
drawTrace(c, m, s.call)
}
c.drawText(s.call, p.x, p.y+20, strokePaint)
c.drawText(s.call, p.x, p.y+20, textPaint)
@ -196,7 +201,7 @@ class StationOverlay(icons : Drawable, context : Context, db : StorageDatabase)
// then the bitmap
c.drawBitmap(iconbitmap, srcRect, destRect, null)
// and finally the bitmap overlay, if any
if (m.getZoomLevel() >= 6 && symbolIsOverlayed(s.symbol)) {
if (zoom >= 6 && symbolIsOverlayed(s.symbol)) {
c.drawText(s.symbol(0).toString(), p.x, p.y+4, symbStrPaint)
c.drawText(s.symbol(0).toString(), p.x, p.y+4, symbPaint)
}

Wyświetl plik

@ -93,25 +93,31 @@ class StorageDatabase(context : Context) extends
db.execSQL(Position.TABLE_CREATE)
Array("call", "lat", "lon").map(col => db.execSQL(Position.TABLE_INDEX.format(col, col)))
}
def resetPositionsTable(db : SQLiteDatabase) {
db.execSQL(Position.TABLE_DROP)
db.execSQL(Position.TABLE_CREATE)
Array("call", "lat", "lon").map(col => db.execSQL(Position.TABLE_INDEX.format(col, col)))
return; // this code causes a too long wait in onUpgrade...
// we can not call getPosts() here due to recursion issues
val c = db.query(Post.TABLE, Post.COLUMNS, "TYPE = 0 OR TYPE = 3",
null, null, null, "_ID DESC", null)
c.moveToFirst()
while (!c.isAfterLast()) {
val message = c.getString(c.getColumnIndexOrThrow(Post.MESSAGE))
val ts = c.getLong(c.getColumnIndexOrThrow(Post.TS))
addPosition(ts, message)
c.moveToNext()
}
c.close()
}
def resetPositionsTable() : Unit = resetPositionsTable(getWritableDatabase())
override def onUpgrade(db: SQLiteDatabase, from : Int, to : Int) {
if (from == 1 && to >= 2) {
db.execSQL("ALTER TABLE %s ADD COLUMN %s".format(Post.TABLE, "TYPE INTEGER DEFAULT 0"))
}
if (from <= 4 && to >= 3) {
db.execSQL(Position.TABLE_DROP)
db.execSQL(Position.TABLE_CREATE)
Array("call", "lat", "lon").map(col => db.execSQL(Position.TABLE_INDEX.format(col, col)))
// we can not call getPosts() here due to recursion issues
val c = db.query(Post.TABLE, Post.COLUMNS, "TYPE = 0 OR TYPE = 3",
null, null, null, "_ID DESC", null)
c.moveToFirst()
while (!c.isAfterLast()) {
val message = c.getString(c.getColumnIndexOrThrow(Post.MESSAGE))
val ts = c.getLong(c.getColumnIndexOrThrow(Post.TS))
addPosition(ts, message)
c.moveToNext()
}
c.close()
resetPositionsTable(db)
}
}
@ -197,10 +203,12 @@ class StorageDatabase(context : Context) extends
cv.put(Post.TYPE, posttype.asInstanceOf[java.lang.Integer])
cv.put(Post.STATUS, status)
cv.put(Post.MESSAGE, message)
Log.d(TAG, "StorageDatabase.addPost: " + status + " - " + message)
getWritableDatabase().insertOrThrow(Post.TABLE, Post.MESSAGE, cv)
if (posttype == Post.TYPE_POST || posttype == Post.TYPE_INCMG) {
addPosition(ts, message)
} else {
// only log status messages
Log.d(TAG, "StorageDatabase.addPost: " + status + " - " + message)
}
if (Post.trimCounter == 0) {
trimPosts()