Skip to content

Commit

Permalink
fix no callback bug in listener callback
Browse files Browse the repository at this point in the history
  • Loading branch information
jokermonn committed Sep 3, 2017
1 parent ff031e3 commit 0e185d2
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,19 @@ public boolean isRequestUnderM() {
@Override
public void request() {
if (isRequestOnRationale()) {
addEntity(getRequestPermissions()[0], getRequestCodes()[0]);
addEntity(getRequestPermissions()[0], getRequestCodes()[0], false);
originalRequest();
} else {
PermissionRequestListener requestListener = getPermissionRequestListener();
if (requestListener != null) {
String[] permissions = getRequestPermissions();
Integer[] requestCodes = getRequestCodes();
for (int i = permissions.length - 1; i >= 0; i--) {
addEntity(permissions[i], requestCodes[i % requestCodes.length]);
requestPermissionWithListener();
addEntity(permissions[i], requestCodes[i % requestCodes.length], true);
}
requestPermissionWithListener();
} else {
addEntity(getRequestPermissions()[0], getRequestCodes()[0]);
addEntity(getRequestPermissions()[0], getRequestCodes()[0], true);
requestPermissionWithAnnotation();
}
}
Expand All @@ -225,13 +225,16 @@ public void request() {
*
* @param permission
* @param requestCode
* @param add
*/
private void addEntity(String permission, int requestCode) {
private void addEntity(String permission, int requestCode, boolean add) {
requestCode(requestCode);
requestPermission(permission);
// use a map to hold wrappers
Key key = new Key(getContext(), getRequestCode());
wrapperMap.put(key, new WeakReference<PermissionWrapper>(this));
if (add) {
Key key = new Key(getContext(), getRequestCode());
wrapperMap.put(key, new WeakReference<PermissionWrapper>(this));
}
}

void requestSync(Activity activity) {
Expand Down

0 comments on commit 0e185d2

Please sign in to comment.