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


Java CropImage类代码示例

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


CropImage类属于com.theartofdev.edmodo.cropper包,在下文中一共展示了CropImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: showChooserDialog

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
public static void showChooserDialog(final BaseActivity activity, final Callback callback) {
    PhotoHelper.callback = callback;

    Nammu.askForPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionCallback() {
        @Override
        public void permissionGranted() {
            Intent intent = CropImage.getPickImageChooserIntent(activity);
            activity.startActivityForResult(intent, CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE);
        }

        @Override
        public void permissionRefused() {
            callOnFailure(Failure.PERMISSION_DENIED);
        }
    });
}
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:17,代码来源:PhotoHelper.java

示例3: handleCropResult

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
private void handleCropResult(CropImageView.CropResult result) {
    if (result.getError() == null) {
        Intent intent = new Intent(getActivity(), CropResultActivity.class);
        intent.putExtra("SAMPLE_SIZE", result.getSampleSize());
        if (result.getUri() != null) {
            intent.putExtra("URI", result.getUri());
        } else {
            CropResultActivity.mImage = mCropImageView.getCropShape() == CropImageView.CropShape.OVAL
                    ? CropImage.toOvalBitmap(result.getBitmap())
                    : result.getBitmap();
        }
        startActivity(intent);
    } else {
        Log.e("AIC", "Failed to crop image", result.getError());
        Toast.makeText(getActivity(), "Image crop failed: " + result.getError().getMessage(), Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:18,代码来源:MainFragment.java

示例4: onRequestPermissionsResult

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    if (requestCode == CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            CropImage.startPickImageActivity(this);
        } else {
            Toast.makeText(this, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG).show();
        }
    }
    if (requestCode == CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) {
        if (mCropImageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            mCurrentFragment.setImageUri(mCropImageUri);
        } else {
            Toast.makeText(this, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:18,代码来源:MainActivity.java

示例5: 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 == GALLERY_REQUEST_CODE && resultCode == RESULT_OK){

        Uri imageUri = data.getData();
        CropImage.activity(imageUri)
                .setGuidelines(CropImageView.Guidelines.ON)
                .setAspectRatio(1,1)
                .start(this);
    }
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {

            mImageUri = result.getUri();
            mProfilePicture.setImageURI(mImageUri);

        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Toast.makeText(CreateProfileActivity.this, "Failed to get profile picture, Try Again.", Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:Socialate,项目名称:furry-sniffle,代码行数:25,代码来源:CreateProfileActivity.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 == GALLERY_REQUEST_CODE && resultCode == RESULT_OK){
        Uri ImageUri = data.getData();
        CropImage.activity(ImageUri)
                .setGuidelines(CropImageView.Guidelines.ON)
                .setAspectRatio(1,1)
                .start(this);
    }
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            imageUri = result.getUri();
            getProfilePicture.setImageURI(imageUri);

        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Toast.makeText(ViewEditProfileActivity.this, "Failed to get profile picture, please try again.", Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:Socialate,项目名称:furry-sniffle,代码行数:23,代码来源:ViewEditProfileActivity.java

示例7: startCropImageActivity

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
public static void startCropImageActivity(Activity activity, CropImageView.CropShape cropShape, boolean isAvatar) {
    if (isAvatar) {
        CropImage.activity()
                .setMinCropResultSize(300, 300)
                .setMaxCropResultSize(1280, 1280)
                .setCropMenuCropButtonIcon(R.drawable.ic_content_white_cut_24dp)
                .setCropShape(cropShape)
                .start(activity);
    } else {
        CropImage.activity()
                .setMinCropResultSize(1280, 720)
                .setMaxCropResultSize(3840, 2160)
                .setCropMenuCropButtonIcon(R.drawable.ic_content_white_cut_24dp)
                .setCropShape(cropShape)
                .start(activity);
    }

}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:19,代码来源:FunctionHelper.java

示例8: onActivityResult

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

        case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE:
            CropImage.ActivityResult result = CropImage.getActivityResult(data);
            if (resultCode == RESULT_OK) {
                Uri resultUri = result.getUri();
                File file = FunctionHelper.createFileFromUri(this, resultUri);
                if (file == null) return;
                if (view_ShowMenu == img_avatar) {
                    changeImage(img_avatar, file.getAbsolutePath());
                } else if (view_ShowMenu == img_background) {
                    changeImage(img_background, file.getAbsolutePath());
                }
                view_ShowMenu = null;

            } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                @SuppressWarnings("ThrowableNotThrown") Exception error = result.getError();
                Log.d(TAG, error.toString());
            }
            break;
    }
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:26,代码来源:DetailTeacherActivity.java

示例9: onActivityResult

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

    if (resultCode == RESULT_OK) {
        if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
            addImageLabel.setVisibility(View.GONE);
            CropImage.ActivityResult result = CropImage.getActivityResult(data);
            Uri resultUri = result.getUri();
            imageURi = resultUri;
            if (resultUri != null) {
                feedImage.setImageURI(resultUri);
            }
        }
    }
}
 
开发者ID:dev-prajwal21,项目名称:CustomerSupportDesk,代码行数:17,代码来源:AddCSFActivity.java

示例10: onRequestPermissionsResult

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    if (requestCode == CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            CropImage.startPickImageActivity(this);
        } else {
            Toast.makeText(this, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG).show();
        }
    }
    if (requestCode == CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) {
        if (cropImageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            // required permissions granted, start crop image activity
            startCropImageActivity(cropImageUri);
        } else {
            Toast.makeText(this, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:piskula,项目名称:FuelUp,代码行数:19,代码来源:VehicleAbstractActivity.java

示例11: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case GALLERY_CODE:
            if (data != null) {
                Uri uri = data.getData();
                cropImage(uri);
            }
            break;
        case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE:
            CropImage.ActivityResult result = CropImage.getActivityResult(data);
            if (resultCode == RESULT_OK) {
                Uri picUri = result.getUri();
                saveBImage(picUri);
                demoIv.setImageURI(picUri);
                //demoIv.setBackgroundColor(Color.TRANSPARENT);
            } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                Exception error = result.getError();
            }
            break;
    }
}
 
开发者ID:shivam301296,项目名称:2048-TimeKiller,代码行数:24,代码来源:Setting.java

示例12: 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

示例13: onRequestPermissionsResult

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
@Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        if (requestCode == CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) {
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                LogUtil.logDebug(TAG, "CAMERA_CAPTURE_PERMISSIONS granted");
                CropImage.startPickImageActivity(this);
            } else {
                showSnackBar(R.string.permissions_not_granted);
                LogUtil.logDebug(TAG, "CAMERA_CAPTURE_PERMISSIONS not granted");
            }
        }
        if (requestCode == CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) {
            if (imageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                // required permissions granted, start crop image activity
                LogUtil.logDebug(TAG, "PICK_IMAGE_PERMISSIONS granted");
//                if (isImageFileValid(imageUri)) {
                onImagePikedAction();
//                }
            } else {
                showSnackBar(R.string.permissions_not_granted);
                LogUtil.logDebug(TAG, "PICK_IMAGE_PERMISSIONS not granted");
            }
        }
    }
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:25,代码来源:PickImageActivity.java

示例14: handleCropImageResult

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
protected void handleCropImageResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            if (ValidationUtil.checkImageMinSize(result.getCropRect())) {
                imageUri = result.getUri();
                loadImageToImageView();
            } else {
                showSnackBar(R.string.error_smaller_image);
            }
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            LogUtil.logError(TAG, "crop image error", result.getError());
            showSnackBar(R.string.error_fail_crop_image);
        }
    }
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:17,代码来源:PickImageActivity.java

示例15: onActivityResult

import com.theartofdev.edmodo.cropper.CropImage; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE: {
            if (resultCode == RESULT_OK) {
                CropImage.activity(data.getData())
                        .setActivityTitle(getString(R.string.crop))
                        .setAspectRatio(1, 1)
                        .setFixAspectRatio(true)
                        .start(this);
            }
            break;
        }
        case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE: {
            if (resultCode == RESULT_OK) {
                CropImage.ActivityResult result = CropImage.getActivityResult(data);
                returnUri(result.getUri());
            }
            break;
        }
    }
}
 
开发者ID:richardchien,项目名称:jigsaw-android,代码行数:24,代码来源:ChooseActivity.java


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