Java Code Examples for me.iwf.photopicker.utils.PermissionsUtils

The following examples show how to use me.iwf.photopicker.utils.PermissionsUtils. These examples are extracted from open source projects. 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 Project: PhotoPicker   Source File: PhotoPickerFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (grantResults.length > 0
            && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        switch (requestCode) {
            case PermissionsConstant.REQUEST_CAMERA:
            case PermissionsConstant.REQUEST_EXTERNAL_WRITE:
                if (PermissionsUtils.checkWriteStoragePermission(this) &&
                        PermissionsUtils.checkCameraPermission(this)) {
                    openCamera();
                }
                break;
        }
    }
}
 
Example 2
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param fragment    Fragment to receive result
 * @param requestCode requestCode for result
 */
public void start(@NonNull Context context,
                  @NonNull android.support.v4.app.Fragment fragment, int requestCode) {
    if (PermissionsUtils.checkReadStoragePermission(fragment.getActivity())) {
        fragment.startActivityForResult(getIntent(context), requestCode);
    }
}
 
Example 3
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Send the Intent with a custom request code
 *
 * @param fragment Fragment to receive result
 */
public void start(@NonNull Context context,
                  @NonNull android.support.v4.app.Fragment fragment) {
    if (PermissionsUtils.checkReadStoragePermission(fragment.getActivity())) {
        fragment.startActivityForResult(getIntent(context), REQUEST_CODE);
    }
}
 
Example 4
Source Project: PhotoPicker   Source File: PhotoPickerFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (grantResults.length > 0
            && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        switch (requestCode) {
            case PermissionsConstant.REQUEST_CAMERA:
            case PermissionsConstant.REQUEST_EXTERNAL_WRITE:
                if (PermissionsUtils.checkWriteStoragePermission(this) &&
                        PermissionsUtils.checkCameraPermission(this)) {
                    openCamera();
                }
                break;
        }
    }
}
 
Example 5
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param fragment    Fragment to receive result
 * @param requestCode requestCode for result
 */
public void start(@NonNull Context context,
                  @NonNull android.support.v4.app.Fragment fragment, int requestCode) {
    if (PermissionsUtils.checkReadStoragePermission(fragment.getActivity())) {
        fragment.startActivityForResult(getIntent(context), requestCode);
    }
}
 
Example 6
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Send the Intent with a custom request code
 *
 * @param fragment Fragment to receive result
 */
public void start(@NonNull Context context,
                  @NonNull android.support.v4.app.Fragment fragment) {
    if (PermissionsUtils.checkReadStoragePermission(fragment.getActivity())) {
        fragment.startActivityForResult(getIntent(context), REQUEST_CODE);
    }
}
 
Example 7
Source Project: PhotoPicker   Source File: PhotoPickerFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  if (grantResults.length > 0
          && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
    switch (requestCode) {
      case PermissionsConstant.REQUEST_CAMERA:
      case PermissionsConstant.REQUEST_EXTERNAL_WRITE:
        if (PermissionsUtils.checkWriteStoragePermission(this) &&
                PermissionsUtils.checkCameraPermission(this)) {
          openCamera();
        }
        break;
    }
  }
}
 
Example 8
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param fragment    Fragment to receive result
 * @param requestCode requestCode for result
 */
public void start(@NonNull Context context,
                  @NonNull android.support.v4.app.Fragment fragment, int requestCode) {
  if (PermissionsUtils.checkReadStoragePermission(fragment.getActivity())) {
    fragment.startActivityForResult(getIntent(context), requestCode);
  }
}
 
Example 9
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Send the Intent with a custom request code
 *
 * @param fragment    Fragment to receive result
 */
public void start(@NonNull Context context,
                  @NonNull android.support.v4.app.Fragment fragment) {
  if (PermissionsUtils.checkReadStoragePermission(fragment.getActivity())) {
    fragment.startActivityForResult(getIntent(context), REQUEST_CODE);
  }
}
 
Example 10
Source Project: PhotoPicker   Source File: PhotoPickerFragment.java    License: Apache License 2.0 4 votes vote down vote up
public void activityCamera() {
    if (!PermissionsUtils.checkCameraPermission(PhotoPickerFragment.this)) return;
    if (!PermissionsUtils.checkWriteStoragePermission(PhotoPickerFragment.this)) return;
    openCamera();
}
 
Example 11
Source Project: PhotoPicker   Source File: PhotoPickerFragment.java    License: Apache License 2.0 4 votes vote down vote up
public void activityCamera() {
    if (!PermissionsUtils.checkCameraPermission(PhotoPickerFragment.this)) return;
    if (!PermissionsUtils.checkWriteStoragePermission(PhotoPickerFragment.this)) return;
    openCamera();
}
 
Example 12
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Send the Intent from an Activity with a custom request code
 *
 * @param activity    Activity to receive result
 * @param requestCode requestCode for result
 */
public void start(@NonNull Activity activity, int requestCode) {
    if (PermissionsUtils.checkReadStoragePermission(activity)) {
        activity.startActivityForResult(getIntent(activity), requestCode);
    }
}
 
Example 13
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Send the Intent from an Activity with a custom request code
 *
 * @param activity    Activity to receive result
 * @param requestCode requestCode for result
 */
public void start(@NonNull Activity activity, int requestCode) {
    if (PermissionsUtils.checkReadStoragePermission(activity)) {
        activity.startActivityForResult(getIntent(activity), requestCode);
    }
}
 
Example 14
Source Project: PhotoPicker   Source File: PhotoPicker.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Send the Intent from an Activity with a custom request code
 *
 * @param activity    Activity to receive result
 * @param requestCode requestCode for result
 */
public void start(@NonNull Activity activity, int requestCode) {
  if (PermissionsUtils.checkReadStoragePermission(activity)) {
    activity.startActivityForResult(getIntent(activity), requestCode);
  }
}