当前位置: 首页>>代码示例>>Java>>正文


Java CropImage.isReadExternalStoragePermissionsRequired方法代码示例

本文整理汇总了Java中com.theartofdev.edmodo.cropper.CropImage.isReadExternalStoragePermissionsRequired方法的典型用法代码示例。如果您正苦于以下问题:Java CropImage.isReadExternalStoragePermissionsRequired方法的具体用法?Java CropImage.isReadExternalStoragePermissionsRequired怎么用?Java CropImage.isReadExternalStoragePermissionsRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.theartofdev.edmodo.cropper.CropImage的用法示例。


在下文中一共展示了CropImage.isReadExternalStoragePermissionsRequired方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == AppCompatActivity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage,
        // but we don't know if we need to for the URI so the simplest is to try open the stream and see if we get error.
        boolean requirePermissions = false;
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {

            // request permissions and handle the result in onRequestPermissionsResult()
            requirePermissions = true;
            mCropImageUri = imageUri;
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {

            mCurrentFragment.setImageUri(imageUri);
        }
    }
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:24,代码来源:MainActivity.java

示例2: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        if (isImageFileValid(imageUri)) {
            this.imageUri = imageUri;
        }

        // For API >= 23 we need to check specifically that we have permissions to read external storage.
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {
            // no permissions required or already grunted
            onImagePikedAction();
        }
    }
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:22,代码来源:PickImageActivity.java

示例3: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage,
        // but we don't know if we need to for the URI so the simplest is to try open the stream and see if we get error.
        boolean requirePermissions = false;
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {

            // request permissions and handle the result in onRequestPermissionsResult()
            requirePermissions = true;
            mCropImageUri = imageUri;
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
        } else {

            mCurrentFragment.setImageUri(imageUri);
        }
    }
}
 
开发者ID:enjoyproduct,项目名称:ImageCroper,代码行数:22,代码来源:MainActivity.java

示例4: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            Uri imageUri = CropImage.getPickImageResultUri(this, data);

            if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
                cropImageUri = imageUri;
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
            } else {
                startCropImageActivity(imageUri);
            }
        } else {
            Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_fail, ""), Snackbar.LENGTH_SHORT).show();
        }
    } else if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            vehiclePicturePath = result.getUri().getPath();
            Picasso.with(getApplicationContext()).load(new File(vehiclePicturePath)).into(imgCarPhoto);
            imgCarPhoto.setAlpha(REMOVE_PHOTO_ALPHA_CHANNEL);
            imgCarPhotoRemove.setVisibility(View.VISIBLE);
            Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_success), Snackbar.LENGTH_SHORT).show();
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            Snackbar.make(findViewById(android.R.id.content), getString(R.string.addVehicle_picture_add_fail, error), Snackbar.LENGTH_SHORT).show();

        }
    }
}
 
开发者ID:piskula,项目名称:FuelUp,代码行数:32,代码来源:VehicleAbstractActivity.java

示例5: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        this.imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage.
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {
            // no permissions required or already grunted, can start crop image activity
            startCropper(imageUri);
        }
    }

    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        Uri resultUri = result.getUri();

        // Start creator
        new CustomCreator(this, resultUri).setListener(this).execute();
    }

    if (requestCode == PreviewActivity.PREVIEW_ACTIVITY_REQUEST_CODE && resultCode == PreviewActivity.RESULT_OK) {
        if (data != null) {
            CatalogItem catalogItem = data.getParcelableExtra(PreviewActivity.EXTRA_CATALOG_ITEM);
            if (catalogItem != null) {
                downloadBackground(catalogItem);
            }
        }
    }
}
 
开发者ID:lucasax,项目名称:Zero,代码行数:35,代码来源:MainActivity.java

示例6: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE1 && resultCode == Activity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
        } else {
            startCropImageActivity(imageUri,CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE1);
        }
    }
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE1) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            realFilePath = FileUtils.getRealFilePath(ResumeActivity.this, result.getUri());
            Bitmap bitmap=BitmapUtils.compressBitmap(realFilePath,1080, 720);
            imgHead.setImageBitmap(bitmap);
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
        }
    }

     if (requestCode == 1) {
        tvBirthday.setText(data.getStringExtra("date"));
    } else if (requestCode == 2) {
        tvDate.setText(data.getStringExtra("date"));
    } else if (requestCode == 3) {
        if (resultCode == RESULT_OK) {
            tvSchool.setText(data.getStringExtra("school"));
        }

    }
}
 
开发者ID:woniukeji,项目名称:jianguo,代码行数:33,代码来源:ResumeActivity.java

示例7: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    // handle result of pick image chooser
    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage.
        boolean requirePermissions = false;
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requirePermissions = true;
            mCropImageUri = imageUri;
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
        } else {
            // no permissions required or already grunted, can start crop image activity
            startCropImageActivity(imageUri);
        }
    }

    // handle result of CropImageActivity
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            ((ImageView) findViewById(R.id.quick_start_cropped_image)).setImageURI(result.getUri());
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:enjoyproduct,项目名称:ImageCroper,代码行数:32,代码来源:MainActivity.java

示例8: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);

  if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE
      && resultCode == AppCompatActivity.RESULT_OK) {
    Uri imageUri = CropImage.getPickImageResultUri(this, data);

    // For API >= 23 we need to check specifically that we have permissions to read external
    // storage,
    // but we don't know if we need to for the URI so the simplest is to try open the stream and
    // see if we get error.
    boolean requirePermissions = false;
    if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {

      // request permissions and handle the result in onRequestPermissionsResult()
      requirePermissions = true;
      mCropImageUri = imageUri;
      requestPermissions(
          new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
          CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
    } else {

      mCurrentFragment.setImageUri(imageUri);
    }
  }
}
 
开发者ID:ArthurHub,项目名称:Android-Image-Cropper,代码行数:29,代码来源:MainActivity.java


注:本文中的com.theartofdev.edmodo.cropper.CropImage.isReadExternalStoragePermissionsRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。