Refactor onRequestPermissionsResult to be simpler (#2965)

onRequestPermissionsResult has a switch statement with a single case, and a functionally empty default; this patch refactors it into an if statement to simplify the code. This patch also changes a C-style array declaration (String permissions[]) to the more standard Java style (String[] permissions).
This commit is contained in:
Dan Garry 2019-05-24 10:56:55 +01:00 committed by neslihanturan
parent ab783a445f
commit 5f3510226a

View file

@ -470,9 +470,8 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case LOCATION_REQUEST: {
String[] permissions, int[] grantResults) {
if (requestCode == LOCATION_REQUEST) {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
@ -487,11 +486,6 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
// TODO: If contrib fragment is visible and location permission is not given, display permission request button
}
}
return;
}
default:
return;
}
}