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

fix #262 #264

Merged
merged 1 commit into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dexter/src/main/java/com/karumi/dexter/Dexter.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,15 @@ static void onActivityReady(Activity activity) {

/**
* Method called whenever the DexterActivity has been destroyed.
* @param oldActivity the DexterActivity that was destroyed
*/
static void onActivityDestroyed() {
static void onActivityDestroyed(DexterActivity oldActivity) {
/* Check against null values because sometimes the DexterActivity can call these internal
methods when the DexterInstance has been cleaned up.
Refer to this commit message for a more detailed explanation of the issue.
*/
if (instance != null) {
instance.onActivityDestroyed();
instance.onActivityDestroyed(oldActivity);
}
}

Expand Down
2 changes: 1 addition & 1 deletion dexter/src/main/java/com/karumi/dexter/DexterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class DexterActivity extends Activity

@Override protected void onDestroy() {
super.onDestroy();
Dexter.onActivityDestroyed();
Dexter.onActivityDestroyed(this);
}

@Override protected void onNewIntent(Intent intent) {
Expand Down
7 changes: 4 additions & 3 deletions dexter/src/main/java/com/karumi/dexter/DexterInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ void onActivityReady(Activity activity) {

/**
* Method called whenever the inner activity has been destroyed.
* @param oldActivity the DexterActivity that was destroyed
*/
void onActivityDestroyed() {
if (activity != null) {
void onActivityDestroyed(Activity oldActivity) {
if (activity == oldActivity) {
activity = null;
isRequestingPermission.set(false);
rationaleAccepted.set(false);
Expand Down Expand Up @@ -318,7 +319,7 @@ private void checkMultiplePermissions(final MultiplePermissionsListener listener
}

if (activity != null && activity.isFinishing()) {
onActivityDestroyed();
onActivityDestroyed(activity);
}

pendingPermissions.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void onCheckPermissionMoreThanOnceThenThrowException() {
givenPermissionIsAlreadyDenied(ANY_PERMISSION);

whenCheckPermission(permissionListener, ANY_PERMISSION);
dexter.onActivityDestroyed();
dexter.onActivityDestroyed(activity);
whenCheckPermission(permissionListener, ANY_PERMISSION);

verifyRequestPermissions(new String[]{ANY_PERMISSION}, 2);
Expand Down