Skip to content

Commit

Permalink
Clean up options menu code
Browse files Browse the repository at this point in the history
Replaces permission check code with checkAppPermissions function.
  • Loading branch information
englehorn committed Jan 31, 2022
1 parent de21a71 commit 7021398
Showing 1 changed file with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,35 +275,15 @@ class TrafficMapFragment : DaggerFragment(), Injectable, OnMapReadyCallback,
when (item.itemId) {
R.id.action_my_location -> {
myLocationFineWithPermissionCheck()
if (activity?.let {
ContextCompat.checkSelfPermission(
it,
Manifest.permission.ACCESS_FINE_LOCATION)
}
== PackageManager.PERMISSION_GRANTED) {
myLocationFineWithPermissionCheck()
}
else if (activity?.let {
ContextCompat.checkSelfPermission(
it,
Manifest.permission.ACCESS_COARSE_LOCATION)
}
== PackageManager.PERMISSION_GRANTED) {
myLocationCoarseWithPermissionCheck()
}
}
else -> {
locationPermissionRequest.launch(
arrayOf(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION
)
)
checkAppPermissions()
}
}

return false

}


override fun onMapReady(map: GoogleMap) {

mMap = map as GoogleMap
Expand Down

0 comments on commit 7021398

Please sign in to comment.