本文整理汇总了Java中com.hujiang.permissiondispatcher.PermissionListener类的典型用法代码示例。如果您正苦于以下问题:Java PermissionListener类的具体用法?Java PermissionListener怎么用?Java PermissionListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PermissionListener类属于com.hujiang.permissiondispatcher包,在下文中一共展示了PermissionListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCheckPermissionOnActivity
import com.hujiang.permissiondispatcher.PermissionListener; //导入依赖的package包/类
private static void processCheckPermissionOnActivity(final Activity target, String[] permissions, String rationalMessage, String rationalButton
, String deniedMessage, String deniedButton, String settingText, boolean needGotoSetting, final boolean runIgnorePermission) {
Assert.assertTrue(permissions != null && permissions.length > 0);
PermissionItem permissionItem = new PermissionItem(permissions);
if (!TextUtils.isEmpty(rationalMessage)
&& !TextUtils.isEmpty(rationalButton)) {
permissionItem.rationalMessage(rationalMessage).rationalButton(rationalButton);
}
if (!TextUtils.isEmpty(deniedMessage)
&& !TextUtils.isEmpty(deniedButton)) {
permissionItem.deniedMessage(deniedMessage).deniedButton(deniedButton);
}
if (!TextUtils.isEmpty(settingText)) {
permissionItem.settingText(settingText);
}
permissionItem.needGotoSetting(needGotoSetting);
CheckPermission.instance(target).check(permissionItem, new PermissionListener() {
@Override
public void permissionGranted() {
sActivitySessions.remove(target.getClass().getName());
}
@Override
public void permissionDenied() {
sActivitySessions.remove(target.getClass().getName());
if (!runIgnorePermission) {
target.finish();
}
}
});
}
示例2: grantPermission
import com.hujiang.permissiondispatcher.PermissionListener; //导入依赖的package包/类
void grantPermission(final TextView textView, final String permission) {
CheckPermission.instance(MainActivity.this).check(new PermissionItem(permission).needGotoSetting(true), new PermissionListener() {
@Override
public void permissionGranted() {
updatePermissionItemInfo(textView, permission);
startBActivity();
}
@Override
public void permissionDenied() {
updatePermissionItemInfo(textView, permission);
}
});
}
示例3: adviceOnNeedPermissionMethod
import com.hujiang.permissiondispatcher.PermissionListener; //导入依赖的package包/类
@Around("pointcutOnNeedPermissionMethod(needPermission)")
public void adviceOnNeedPermissionMethod(final ProceedingJoinPoint joinPoint, final NeedPermission needPermission) throws Throwable {
try {
if (needPermission == null) {
joinPoint.proceed();
return;
}
if (needPermission.runIgnorePermission()) {
joinPoint.proceed();
}
String[] permissions = needPermission.permissions();
if (permissions != null && permissions.length > 0) {
Context context = PermissionCheckSDK.application;
PermissionItem permissionItem = new PermissionItem(permissions);
String rationalMsg = chooseContent(context, needPermission.rationalMessage(), needPermission.rationalMsgResId());
String rationalBtn = chooseContent(context, needPermission.rationalButton(), needPermission.rationalBtnResId());
String deniedMsg = chooseContent(context, needPermission.deniedMessage(), needPermission.deniedMsgResId());
String deniedBtn = chooseContent(context, needPermission.deniedButton(), needPermission.deniedBtnResId());
String settingBtn = chooseContent(context, needPermission.settingText(), needPermission.settingResId());
if (!TextUtils.isEmpty(rationalMsg)
&& !TextUtils.isEmpty(rationalBtn)) {
permissionItem.rationalMessage(rationalMsg).rationalButton(rationalBtn);
}
if (!TextUtils.isEmpty(deniedMsg)
&& !TextUtils.isEmpty(deniedBtn)) {
permissionItem.deniedMessage(deniedMsg).deniedButton(deniedBtn);
}
if (!TextUtils.isEmpty(settingBtn)) {
permissionItem.settingText(settingBtn);
}
permissionItem.needGotoSetting(needPermission.needGotoSetting());
CheckPermission.instance(context).check(permissionItem, new PermissionListener() {
@Override
public void permissionGranted() {
if (!needPermission.runIgnorePermission()) {
try {
joinPoint.proceed();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
@Override
public void permissionDenied() {
}
});
}
} catch (NoSuchMethodException e) {
joinPoint.proceed();
}
}
示例4: onClick
import com.hujiang.permissiondispatcher.PermissionListener; //导入依赖的package包/类
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.btn_calendar_req) {
onCalendarClick(v);
} else if (id == R.id.btn_writesetting_req) {
onWriteSettingClick(v);
} else if (id == R.id.btn_sysalertwindow_req) {
onSysWindowClick(v);
} else if (id == R.id.btn_sms_req) {
onSMSClick(v);
} else if (id == R.id.btn_bodysensor_req) {
onBodySensorClick(v);
} else if (id == R.id.btn_camera_req) {
onCameraClick(v);
} else if (id == R.id.btn_contact_req) {
onContactClick(v);
} else if (id == R.id.btn_extstorage_req) {
onExtStorageClick(v);
} else if (id == R.id.btn_location_req) {
onLocationClick(v);
} else if (id == R.id.btn_micphone_req) {
onMicPhoneClick(v);
} else if (id == R.id.btn_mix_permission) {
CheckPermission.instance(this).check(new PermissionItem(Manifest.permission.CAMERA
, Manifest.permission.READ_CONTACTS
, Manifest.permission.WRITE_SETTINGS
, Manifest.permission.SYSTEM_ALERT_WINDOW)
.needGotoSetting(true), new PermissionListener() {
@Override
public void permissionGranted() {
startBActivity();
}
@Override
public void permissionDenied() {
}
});
}
}