kopia lustrzana https://github.com/ge0rg/aprsdroid
add 'toggle objects' menu to map
rodzic
43ddb3989c
commit
7631b358eb
|
@ -7,6 +7,10 @@
|
|||
android:title="@string/show_log"
|
||||
android:alphabeticShortcut="l"
|
||||
android:icon="@android:drawable/ic_menu_revert" />
|
||||
<item android:id="@+id/toggleobjects"
|
||||
android:title="@string/show_objects"
|
||||
android:alphabeticShortcut="o"
|
||||
android:icon="@android:drawable/ic_menu_myplaces" />
|
||||
<item android:id="@+id/startstopbtn"
|
||||
android:title="@string/startlog"
|
||||
android:alphabeticShortcut="s"
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<string name="about">About</string>
|
||||
<string name="show_map">Show Map</string>
|
||||
<string name="show_log">Show Log</string>
|
||||
<string name="show_objects">Toggle Objects</string>
|
||||
<string name="quit">Quit</string>
|
||||
<string name="preferences">Preferences</string>
|
||||
<!-- preferences -->
|
||||
|
|
|
@ -20,9 +20,11 @@ class MapAct extends MapActivity {
|
|||
lazy val db = StorageDatabase.open(this)
|
||||
lazy val staoverlay = new StationOverlay(allicons, this, db)
|
||||
|
||||
var showObjects = false
|
||||
|
||||
lazy val locReceiver = new LocationReceiver(new Handler(), () => {
|
||||
Benchmark("loadDb") {
|
||||
staoverlay.loadDb()
|
||||
staoverlay.loadDb(showObjects)
|
||||
}
|
||||
mapview.invalidate()
|
||||
//postlist.setSelection(0)
|
||||
|
@ -33,7 +35,7 @@ class MapAct extends MapActivity {
|
|||
setContentView(R.layout.mapview)
|
||||
mapview.setBuiltInZoomControls(true)
|
||||
|
||||
staoverlay.loadDb()
|
||||
staoverlay.loadDb(showObjects)
|
||||
mapview.getOverlays().add(staoverlay)
|
||||
|
||||
// listen for new positions
|
||||
|
@ -74,6 +76,11 @@ class MapAct extends MapActivity {
|
|||
stopService(AprsService.intent(this, AprsService.SERVICE))
|
||||
}
|
||||
true
|
||||
case R.id.toggleobjects =>
|
||||
showObjects = !showObjects
|
||||
staoverlay.loadDb(showObjects)
|
||||
mapview.invalidate()
|
||||
true
|
||||
case R.id.quit =>
|
||||
stopService(AprsService.intent(this, AprsService.SERVICE))
|
||||
finish();
|
||||
|
@ -198,9 +205,10 @@ class StationOverlay(icons : Drawable, context : Context, db : StorageDatabase)
|
|||
}
|
||||
}
|
||||
|
||||
def loadDb() {
|
||||
def loadDb(showObjects : Boolean) {
|
||||
stations.clear()
|
||||
val c = db.getPositions(null, null, null)
|
||||
val filter = if (showObjects) null else "ORIGIN IS NULL"
|
||||
val c = db.getPositions(filter, null, null)
|
||||
c.moveToFirst()
|
||||
while (!c.isAfterLast()) {
|
||||
val call = c.getString(StorageDatabase.Position.COLUMN_CALL)
|
||||
|
|
Ładowanie…
Reference in New Issue