82 lines
2.2 KiB
Java
82 lines
2.2 KiB
Java
package com.yanzhenjie.permission.runtime;
|
|
|
|
import com.yanzhenjie.permission.Action;
|
|
import com.yanzhenjie.permission.checker.PermissionChecker;
|
|
import com.yanzhenjie.permission.checker.StrictChecker;
|
|
import com.yanzhenjie.permission.source.Source;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes2.dex */
|
|
class LRequest implements PermissionRequest {
|
|
private static final PermissionChecker e = new StrictChecker();
|
|
private Source a;
|
|
private String[] b;
|
|
private Action<List<String>> c;
|
|
private Action<List<String>> d;
|
|
|
|
LRequest(Source source) {
|
|
this.a = source;
|
|
}
|
|
|
|
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
|
public PermissionRequest a(String... strArr) {
|
|
this.b = strArr;
|
|
return this;
|
|
}
|
|
|
|
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
|
public PermissionRequest b(Action<List<String>> action) {
|
|
this.d = action;
|
|
return this;
|
|
}
|
|
|
|
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
|
public void start() {
|
|
List<String> a = a(this.a, this.b);
|
|
if (a.isEmpty()) {
|
|
a();
|
|
} else {
|
|
a(a);
|
|
}
|
|
}
|
|
|
|
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
|
public PermissionRequest a(Action<List<String>> action) {
|
|
this.c = action;
|
|
return this;
|
|
}
|
|
|
|
private void a() {
|
|
if (this.c != null) {
|
|
List<String> asList = Arrays.asList(this.b);
|
|
try {
|
|
this.c.a(asList);
|
|
} catch (Exception unused) {
|
|
Action<List<String>> action = this.d;
|
|
if (action != null) {
|
|
action.a(asList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(List<String> list) {
|
|
Action<List<String>> action = this.d;
|
|
if (action != null) {
|
|
action.a(list);
|
|
}
|
|
}
|
|
|
|
private static List<String> a(Source source, String... strArr) {
|
|
ArrayList arrayList = new ArrayList(1);
|
|
for (String str : strArr) {
|
|
if (!e.a(source.a(), str)) {
|
|
arrayList.add(str);
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
}
|