use of com.yydcdut.note.presenters.IPresenter in project PhotoNoter by yydcdut.
the class PermissionAspect method aroundCheckAndRequestPermission.
@Around("pointcut2CheckAndRequestPermissions(aspectPermission)")
public void aroundCheckAndRequestPermission(ProceedingJoinPoint proceedingJoinPoint, AspectPermission aspectPermission) {
if (aspectPermission == null) {
return;
}
IPresenter iPresenter = (IPresenter) proceedingJoinPoint.getTarget();
int value = aspectPermission.value();
switch(value) {
case PermissionUtils.CODE_CAMERA:
case PermissionUtils.CODE_ADJUST_CAMERA:
{
if (hasPermission4Camera(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getContext() instanceof Activity) {
requestPermissions((Activity) iPresenter.getContext(), PermissionInstance.context.getString(R.string.permission_camera_init), PermissionUtils.PERMISSION_CAMERA, value);
} else {
YLog.i(TAG, "iPresenter.getContext() instanceof Activity --> false");
}
}
}
break;
case PermissionUtils.CODE_STORAGE:
{
if (hasPermission4Storage(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getContext() instanceof Activity) {
requestPermissions((Activity) iPresenter.getContext(), PermissionInstance.context.getString(R.string.permission_storage_init), PermissionUtils.PERMISSION_STORAGE, value);
} else {
YLog.i(TAG, "iPresenter.getContext() instanceof Activity --> false");
}
}
}
break;
case PermissionUtils.CODE_LOCATION_AND_CAMERA:
{
if (hasPermission4LocationAndCamera(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getContext() instanceof Activity) {
requestPermissions((Activity) iPresenter.getContext(), PermissionInstance.context.getString(R.string.permission_location), PermissionUtils.PERMISSION_LOCATION_AND_CAMERA, value);
} else {
YLog.i(TAG, "iPresenter.getContext() instanceof Activity --> false");
}
}
}
break;
case PermissionUtils.CODE_AUDIO:
{
if (hasPermission4Audio(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getContext() instanceof Activity) {
requestPermissions((Activity) iPresenter.getContext(), PermissionInstance.context.getString(R.string.permission_audio), PermissionUtils.PERMISSION_AUDIO, value);
} else {
YLog.i(TAG, "iPresenter.getContext() instanceof Activity --> false");
}
}
}
break;
case PermissionUtils.CODE_PHONE_STATE:
{
if (hasPermission4PhoneState(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getContext() instanceof Activity) {
requestPermissions((Activity) iPresenter.getContext(), PermissionInstance.context.getString(R.string.permission_phone_state), PermissionUtils.PERMISSION_PHONE_STATE, value);
} else {
YLog.i(TAG, "iPresenter.getContext() instanceof Activity --> false");
}
}
}
break;
}
}
use of com.yydcdut.note.presenters.IPresenter in project PhotoNoter by yydcdut.
the class PermissionAspect method aroundCheckAndRequestPermission.
@Around("pointcut2CheckAndRequestPermissions(permission)")
public void aroundCheckAndRequestPermission(ProceedingJoinPoint proceedingJoinPoint, Permission permission) {
if (permission == null) {
return;
}
IPresenter iPresenter = (IPresenter) proceedingJoinPoint.getTarget();
int value = permission.value();
switch(value) {
case PermissionUtils.CODE_CAMERA:
case PermissionUtils.CODE_ADJUST_CAMERA:
{
if (hasPermission4Camera(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getIView().getRequestType().isActivity()) {
requestPermissions4Activity(iPresenter.getIView().getRequestType().getActivity(), PermissionInstance.context.getString(R.string.permission_camera_init), PermissionUtils.PERMISSION_CAMERA, value);
} else {
requestPermissions4Fragment(iPresenter.getIView().getRequestType().getFragment(), PermissionInstance.context.getString(R.string.permission_camera_init), PermissionUtils.PERMISSION_CAMERA, value);
}
}
}
break;
case PermissionUtils.CODE_STORAGE:
{
if (hasPermission4Storage(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getIView().getRequestType().isActivity()) {
requestPermissions4Activity(iPresenter.getIView().getRequestType().getActivity(), PermissionInstance.context.getString(R.string.permission_storage_init), PermissionUtils.PERMISSION_STORAGE, value);
} else {
requestPermissions4Fragment(iPresenter.getIView().getRequestType().getFragment(), PermissionInstance.context.getString(R.string.permission_storage_init), PermissionUtils.PERMISSION_STORAGE, value);
}
}
}
break;
case PermissionUtils.CODE_LOCATION_AND_CAMERA:
{
if (hasPermission4LocationAndCamera(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getIView().getRequestType().isActivity()) {
requestPermissions4Activity(iPresenter.getIView().getRequestType().getActivity(), PermissionInstance.context.getString(R.string.permission_location), PermissionUtils.PERMISSION_LOCATION_AND_CAMERA, value);
} else {
requestPermissions4Fragment(iPresenter.getIView().getRequestType().getFragment(), PermissionInstance.context.getString(R.string.permission_location), PermissionUtils.PERMISSION_LOCATION_AND_CAMERA, value);
}
}
}
break;
case PermissionUtils.CODE_AUDIO:
{
if (hasPermission4Audio(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getIView().getRequestType().isActivity()) {
requestPermissions4Activity(iPresenter.getIView().getRequestType().getActivity(), PermissionInstance.context.getString(R.string.permission_audio), PermissionUtils.PERMISSION_AUDIO, value);
} else {
requestPermissions4Fragment(iPresenter.getIView().getRequestType().getFragment(), PermissionInstance.context.getString(R.string.permission_audio), PermissionUtils.PERMISSION_AUDIO, value);
}
}
}
break;
case PermissionUtils.CODE_PHONE_STATE:
{
if (hasPermission4PhoneState(PermissionInstance.context)) {
try {
proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
YLog.e(throwable);
}
} else {
if (iPresenter.getIView().getRequestType().isActivity()) {
requestPermissions4Activity(iPresenter.getIView().getRequestType().getActivity(), PermissionInstance.context.getString(R.string.permission_phone_state), PermissionUtils.PERMISSION_PHONE_STATE, value);
} else {
requestPermissions4Fragment(iPresenter.getIView().getRequestType().getFragment(), PermissionInstance.context.getString(R.string.permission_phone_state), PermissionUtils.PERMISSION_PHONE_STATE, value);
}
}
}
break;
}
}
Aggregations