Skip to content

Commit

Permalink
avoid use of non existent location handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Sep 4, 2016
1 parent 0cd23c6 commit 437c674
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
applicationId "org.blitzortung.android.app"
minSdkVersion 8
targetSdkVersion 23
versionCode 186
versionName "1.5.15"
versionCode 187
versionName "1.5.16"
multiDexEnabled true
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class LocationProvider(protected val locationUpdate: (Location?) -> Uni

open fun start() {
isRunning = true

Log.v(Main.LOG_TAG, "LocationProvider.start() type: $type" )
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.location.Location
import android.location.LocationListener
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import org.blitzortung.android.app.Main
import org.jetbrains.anko.locationManager

Expand Down Expand Up @@ -33,7 +34,13 @@ abstract class ManagerLocationProvider(
super.start()

Log.v(Main.LOG_TAG, "ManagerLocationProvider.start() background: $backgroundMode, type: $type, minTime: $minTime, minDistance: $minDistance")
locationManager.requestLocationUpdates(type, minTime, minDistance, this)
if (locationManager.getAllProviders().contains(type)) {
locationManager.requestLocationUpdates(type, minTime, minDistance, this)
} else {
val message = "location provider ${type} is not available"
Toast.makeText(context, "Warning:\n$message", Toast.LENGTH_LONG).show()
Log.w(Main.LOG_TAG, message)
}
}

override fun onLocationChanged(location: Location?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class VersionComponentTest {
}

companion object {
val CURRENT_VERSION_CODE = 186
val CURRENT_VERSION_NAME = "1.5.15"
val CURRENT_VERSION_CODE = 187
val CURRENT_VERSION_NAME = "1.5.16"
}
}

0 comments on commit 437c674

Please sign in to comment.