Skip to content

Commit

Permalink
Fix bug, before unregistering an activity check whether is the correc…
Browse files Browse the repository at this point in the history
…t one
  • Loading branch information
aitorvs committed Dec 7, 2015
1 parent 7d8100f commit 1fdf813
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;

import java.security.InvalidParameterException;
import java.util.ArrayList;
Expand All @@ -32,6 +33,7 @@

public class AllowMe {

private static final String TAG = AllowMe.class.getSimpleName();
private static AllowMe instance;

private Activity mActivity;
Expand All @@ -56,7 +58,11 @@ public static void registerActivity(@NonNull Activity activity) {
}

public static void unregisterActivity(@NonNull Activity activity) {
getInstance().mActivity = null;
if (activity == getInstance().mActivity) {
getInstance().mActivity = null;
} else {
Log.w(TAG, "unregisterActivity: Old activity is trying to unregister");
}

}

Expand Down

0 comments on commit 1fdf813

Please sign in to comment.