Skip to content

Commit

Permalink
修复权限拦截器导致的内存泄漏的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
getActivity committed Aug 24, 2021
1 parent e6d3bf6 commit b530422
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Apache License
Version 2.0, January 2004
Version 2.0, June 2018
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Expand Down Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2018 Huang JinQun

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.hjq.permissions.demo"
minSdkVersion 14
targetSdkVersion 30
versionCode 1180
versionName "11.8"
versionCode 1200
versionName "12.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {

defaultConfig {
minSdkVersion 11
versionCode 1180
versionName "11.8"
versionCode 1200
versionName "12.0"
}

// 使用 JDK 1.8
Expand Down
15 changes: 11 additions & 4 deletions library/src/main/java/com/hjq/permissions/XXPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ public static void setInterceptor(IPermissionInterceptor interceptor) {
sInterceptor = interceptor;
}

/**
* 获取全局权限请求拦截器
*/
public static IPermissionInterceptor getInterceptor() {
if (sInterceptor == null) {
sInterceptor = new IPermissionInterceptor() {};
}
return sInterceptor;
}

/** Context 对象 */
private final Context mContext;

Expand Down Expand Up @@ -131,10 +141,7 @@ public void request(OnPermissionCallback callback) {
}

if (mInterceptor == null) {
if (sInterceptor == null) {
sInterceptor = new IPermissionInterceptor() {};
}
mInterceptor = sInterceptor;
mInterceptor = getInterceptor();
}

// 当前是否为调试模式
Expand Down

0 comments on commit b530422

Please sign in to comment.