Search in sources :

Example 1 with APermissionsAction

use of org.aisen.android.support.permissions.APermissionsAction in project AisenWeiBo by wangdan.

the class OtherItemFragment method checkPhotoPermission.

// private void setLanguage(int value) {
// String[] valueTitleArr = getResources().getStringArray(R.array.pLanguage);
// 
// pLanguage.setSummary(valueTitleArr[value]);
// }
public static void checkPhotoPermission(final BaseActivity activity, final boolean shownever) {
    APermissionsAction permissionsAction = new APermissionsAction(activity, null, activity.getActivityHelper(), Manifest.permission.CALL_PHONE) {

        @Override
        protected void onPermissionDenied(boolean alwaysDenied) {
            if (alwaysDenied) {
                if (shownever && ActivityHelper.getBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", false)) {
                    return;
                }
                MaterialDialog.Builder builder = new MaterialDialog.Builder(activity).forceStacking(true).content(R.string.crash_hint).negativeText(R.string.crash_settings).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        ActivityHelper.putBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", true);
                    }
                }).onNegative(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        AisenUtils.gotoSettings(activity);
                    }
                });
                if (shownever)
                    builder.positiveText(R.string.donnot_remind);
                builder.show();
            }
        }
    };
    // 开启日志上报
    new IAction(activity, permissionsAction) {

        @Override
        public void doAction() {
            Log.d("Main", "setupCrash");
            ((MyApplication) GlobalContext.getInstance()).setupCrash();
        }
    }.run();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IAction(org.aisen.android.support.action.IAction) DialogAction(com.afollestad.materialdialogs.DialogAction) APermissionsAction(org.aisen.android.support.permissions.APermissionsAction)

Aggregations

DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 IAction (org.aisen.android.support.action.IAction)1 APermissionsAction (org.aisen.android.support.permissions.APermissionsAction)1