Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Rename method to continue pending requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Gutierrez committed Nov 30, 2015
1 parent d105db9 commit 828c62e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Dexter.checkPermissions(new CompositePermissionListener(snackbarMultiplePermissi
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_activity);
Dexter.checkPendingPermissions(permissionsListener);
Dexter.continuePendingRequestsIfPossible(permissionsListener);
}
```

Expand Down
12 changes: 7 additions & 5 deletions dexter/src/main/java/com/karumi/dexter/Dexter.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,21 @@ public static boolean isRequestOngoing() {
}

/**
* Method called whenever the DexterActivity has been created and is ready to be used
* Requests pending permissions if there were permissions lost. This method can be used to
* recover the Dexter state during a configuration change, for example when the device is
* rotated.
*/
public static void checkPendingPermissions(MultiplePermissionsListener listener) {
instance.checkPendingPermissions(listener);
public static void continuePendingRequestsIfPossible(MultiplePermissionsListener listener) {
instance.continuePendingRequestsIfPossible(listener);
}

/**
* Requests pending permission if there was a permissions lost. This method can be used to
* recover the Dexter state during a configuration change, for example when the device is
* rotated.
*/
public static void checkPendingPermission(PermissionListener listener) {
instance.checkPendingPermission(listener);
public static void continuePendingRequestIfPossible(PermissionListener listener) {
instance.continuePendingRequestIfPossible(listener);
}

/**
Expand Down
11 changes: 5 additions & 6 deletions dexter/src/main/java/com/karumi/dexter/DexterInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,20 @@ void checkPermissions(MultiplePermissionsListener listener, Collection<String> p
* Check if there is a permission pending to be confirmed by the user and restarts the
* request for permission process.
*/
void checkPendingPermission(PermissionListener listener) {
void continuePendingRequestIfPossible(PermissionListener listener) {
MultiplePermissionsListenerToPermissionListenerAdapter adapter =
new MultiplePermissionsListenerToPermissionListenerAdapter(listener);
checkPendingPermissions(adapter);
continuePendingRequestsIfPossible(adapter);
}

/**
* Check if there are some permissions pending to be confirmed by the user and restarts the
* request for permission process.
*/
void checkPendingPermissions(MultiplePermissionsListener listener) {
boolean shouldContinueRequestingPendingPermissions =
!pendingPermissions.isEmpty() && !rationaleAccepted.get();
void continuePendingRequestsIfPossible(MultiplePermissionsListener listener) {
boolean isShowingRationale = !pendingPermissions.isEmpty() && !rationaleAccepted.get();
this.listener = listener;
if (shouldContinueRequestingPendingPermissions) {
if (isShowingRationale) {
onActivityReady(activity);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void whenCheckPermission(PermissionListener permissionListener, String p
}

private void whenContinueWithTheCheckPermissionProcess(PermissionListener permissionListener) {
dexter.checkPendingPermission(permissionListener);
dexter.continuePendingRequestIfPossible(permissionListener);
}

private void thenPermissionIsGranted(String permission) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class SampleActivity extends Activity {
* to start with the check permission process without keep in an Android Bundle the state of
* the request permission process.
*/
Dexter.checkPendingPermissions(allPermissionsListener);
Dexter.continuePendingRequestsIfPossible(allPermissionsListener);
}

@OnClick(R.id.all_permissions_button) public void onAllPermissionsButtonClicked() {
Expand Down

0 comments on commit 828c62e

Please sign in to comment.