mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
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:
parent
ab783a445f
commit
5f3510226a
1 changed files with 13 additions and 19 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue