Created
August 4, 2017 08:32
-
-
Save AlexGladkov/944cf2b7161b2e8b894a08ace5d46a18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
switch (requestCode) { | |
case LOCATION_REQUEST: { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
viewModel.setLocationState(ComposeViewModel.LOCATION_ON); | |
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(mActivity); | |
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != | |
PackageManager.PERMISSION_GRANTED && | |
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != | |
PackageManager.PERMISSION_GRANTED) { | |
return; | |
} | |
mFusedLocationClient.getLastLocation().addOnCompleteListener(mActivity, new OnCompleteListener<Location>() { | |
@Override | |
public void onComplete(@NonNull Task<Location> task) { | |
currentLocation = task.getResult(); | |
viewModel.addLocation(task.getResult()); | |
} | |
}); | |
} else { | |
viewModel.setLocationState(ComposeViewModel.LOCATION_DISABLED); | |
} | |
return; | |
} | |
case PHOTO_REQUEST: { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment