Java Code Examples for com.luck.picture.lib.config.PictureConfig#APPLY_STORAGE_PERMISSIONS_CODE

The following examples show how to use com.luck.picture.lib.config.PictureConfig#APPLY_STORAGE_PERMISSIONS_CODE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhotoFragment.java    From PictureSelector with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case PictureConfig.APPLY_STORAGE_PERMISSIONS_CODE:
            // 存储权限
            for (int i = 0; i < grantResults.length; i++) {
                if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                    PictureFileUtils.deleteCacheDirFile(getContext(), PictureMimeType.ofImage());
                } else {
                    Toast.makeText(getContext(),
                            getString(R.string.picture_jurisdiction), Toast.LENGTH_SHORT).show();
                }
            }
            break;
    }
}
 
Example 2
Source File: MainActivity.java    From PictureSelector with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case PictureConfig.APPLY_STORAGE_PERMISSIONS_CODE:
            // 存储权限
            for (int i = 0; i < grantResults.length; i++) {
                if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                    PictureFileUtils.deleteCacheDirFile(getContext(), PictureMimeType.ofImage());
                } else {
                    Toast.makeText(MainActivity.this,
                            getString(R.string.picture_jurisdiction), Toast.LENGTH_SHORT).show();
                }
            }
            break;
    }
}
 
Example 3
Source File: PhotoFragmentActivity.java    From PictureSelector with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case PictureConfig.APPLY_STORAGE_PERMISSIONS_CODE:
            // 存储权限
            for (int i = 0; i < grantResults.length; i++) {
                if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                    PictureFileUtils.deleteCacheDirFile(PhotoFragmentActivity.this, PictureMimeType.ofImage());
                } else {
                    Toast.makeText(PhotoFragmentActivity.this,
                            getString(R.string.picture_jurisdiction), Toast.LENGTH_SHORT).show();
                }
            }
            break;
    }
}
 
Example 4
Source File: PictureExternalPreviewActivity.java    From PictureSelector with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case PictureConfig.APPLY_STORAGE_PERMISSIONS_CODE:
            // 存储权限
            for (int i = 0; i < grantResults.length; i++) {
                if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                    showDownLoadDialog();
                } else {
                    ToastUtils.s(getContext(), getString(R.string.picture_jurisdiction));
                }
            }
            break;
    }
}
 
Example 5
Source File: PictureSelectorCameraEmptyActivity.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case PictureConfig.APPLY_STORAGE_PERMISSIONS_CODE:
            // Store Permissions
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                PermissionChecker.requestPermissions(this,
                        new String[]{Manifest.permission.CAMERA}, PictureConfig.APPLY_CAMERA_PERMISSIONS_CODE);
            } else {
                ToastUtils.s(getContext(), getString(R.string.picture_jurisdiction));
                closeActivity();
            }
            break;
        case PictureConfig.APPLY_CAMERA_PERMISSIONS_CODE:
            // Camera Permissions
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                onTakePhoto();
            } else {
                closeActivity();
                ToastUtils.s(getContext(), getString(R.string.picture_camera));
            }
            break;
        case PictureConfig.APPLY_RECORD_AUDIO_PERMISSIONS_CODE:
            // Recording Permissions
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                onTakePhoto();
            } else {
                closeActivity();
                ToastUtils.s(getContext(), getString(R.string.picture_audio));
            }
            break;
    }
}
 
Example 6
Source File: PictureSelectorActivity.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case PictureConfig.APPLY_STORAGE_PERMISSIONS_CODE:
            // Store Permissions
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                readLocalMedia();
            } else {
                showPermissionsDialog(false, getString(R.string.picture_jurisdiction));
            }
            break;
        case PictureConfig.APPLY_CAMERA_PERMISSIONS_CODE:
            // Camera Permissions
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                onTakePhoto();
            } else {
                showPermissionsDialog(true, getString(R.string.picture_camera));
            }
            break;
        case PictureConfig.APPLY_CAMERA_STORAGE_PERMISSIONS_CODE:
            // Using the camera, retrieve the storage permission
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                startCamera();
            } else {
                showPermissionsDialog(false, getString(R.string.picture_jurisdiction));
            }
            break;
        case PictureConfig.APPLY_RECORD_AUDIO_PERMISSIONS_CODE:
            // Recording Permissions
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                startCustomCamera();
            } else {
                showPermissionsDialog(false, getString(R.string.picture_audio));
            }
            break;
    }
}
 
Example 7
Source File: PictureCustomCameraActivity.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    switch (requestCode) {
        case PictureConfig.APPLY_STORAGE_PERMISSIONS_CODE:
            // 存储权限
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                PermissionChecker.requestPermissions(this,
                        new String[]{Manifest.permission.CAMERA}, PictureConfig.APPLY_CAMERA_PERMISSIONS_CODE);
            } else {
                showPermissionsDialog(true, getString(R.string.picture_jurisdiction));
            }
            break;
        case PictureConfig.APPLY_CAMERA_PERMISSIONS_CODE:
            // 相机权限
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                boolean isRecordAudio = PermissionChecker.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);
                if (isRecordAudio) {
                    createCameraView();
                } else {
                    PermissionChecker.requestPermissions(this,
                            new String[]{Manifest.permission.RECORD_AUDIO}, PictureConfig.APPLY_RECORD_AUDIO_PERMISSIONS_CODE);
                }
            } else {
                showPermissionsDialog(true, getString(R.string.picture_camera));
            }
            break;
        case PictureConfig.APPLY_RECORD_AUDIO_PERMISSIONS_CODE:
            // 录音权限
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                createCameraView();
            } else {
                showPermissionsDialog(false, getString(R.string.picture_audio));
            }
            break;
    }
}