本文整理汇总了Java中com.theartofdev.edmodo.cropper.CropImageView类的典型用法代码示例。如果您正苦于以下问题:Java CropImageView类的具体用法?Java CropImageView怎么用?Java CropImageView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CropImageView类属于com.theartofdev.edmodo.cropper包,在下文中一共展示了CropImageView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mCropImageView = (CropImageView) view.findViewById(R.id.cropImageView);
mCropImageView.setOnSetImageUriCompleteListener(this);
mCropImageView.setOnCropImageCompleteListener(this);
updateCurrentCropViewOptions();
if (savedInstanceState == null) {
if (mDemoPreset == CropDemoPreset.SCALE_CENTER_INSIDE) {
mCropImageView.setImageResource(R.drawable.cat_small);
} else {
mCropImageView.setImageResource(R.drawable.cat);
}
}
}
示例2: handleCropResult
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的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();
}
}
示例3: onActivityResult
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的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();
}
}
}
示例4: onActivityResult
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的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();
}
}
}
示例5: startCropImageActivity
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的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);
}
}
示例6: onCreate
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crop_and_rotate);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ViewCompat.setElevation(toolbar,10);
toolbar.setOnMenuItemClickListener(this);
Intent intent = getIntent();
message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
cropImageView = (CropImageView) findViewById(R.id.cropImageView);
cropImageView.setImageUriAsync(Uri.parse(message));
mFab = (FloatingActionButton) findViewById(R.id.nextStep);
mFab.setOnClickListener(this);
}
示例7: onViewCreated
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mCropImageView = (CropImageView) view.findViewById(R.id.cropImageView);
mCropImageView.setOnSetImageUriCompleteListener(this);
mCropImageView.setOnGetCroppedImageCompleteListener(this);
updateCurrentCropViewOptions();
if (savedInstanceState == null) {
if (mDemoPreset == CropDemoPreset.SCALE_CENTER_INSIDE) {
mCropImageView.setImageResource(R.drawable.cat_small);
} else {
mCropImageView.setImageResource(R.drawable.cat);
}
}
}
示例8: cropImage
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
private void cropImage(@NonNull Uri input) {
Timber.v("Uri.toString: %s", input.toString());
if (!MimeTypeUtils.isImage(getContext(), input)) {
mNotificationBar.showTemporaryInverse(getString(R.string.not_image_file));
return;
}
mUserAvatarFile = FileNameUtils.getJPEGFile(getContext());
CropImage.activity(input)
.setGuidelines(CropImageView.Guidelines.ON_TOUCH)
.setOutputUri(Uri.fromFile(mUserAvatarFile))
.setOutputCompressFormat(Bitmap.CompressFormat.JPEG)
.setMinCropResultSize(450, 450)
.setRequestedSize(512, 512)
.setMaxCropResultSize(768, 768)
.setCropShape(CropImageView.CropShape.OVAL)
.start(getContext(), this);
}
示例9: setScaleType
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
/**
* The initial scale type of the image in the crop image view<br>
* <i>Default: {@link #SCALE_TYPE_FIT_CENTER}</i>
*/
public Builder setScaleType(@ScaleTypes int scaleType) {
switch (scaleType) {
case SCALE_TYPE_CENTER:
mOptions.scaleType = CropImageView.ScaleType.CENTER;
break;
case SCALE_TYPE_CENTER_CROP:
mOptions.scaleType = CropImageView.ScaleType.CENTER_CROP;
break;
case SCALE_TYPE_CENTER_INSIDE:
mOptions.scaleType = CropImageView.ScaleType.CENTER_INSIDE;
break;
case SCALE_TYPE_FIT_CENTER:
mOptions.scaleType = CropImageView.ScaleType.FIT_CENTER;
break;
}
return this;
}
示例10: handleCropResult
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的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();
}
}
示例11: onActivityResult
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == GALLERY_REQUEST && resultCode == RESULT_OK) {
Uri imageUri = data.getData();
CropImage.activity(imageUri)
.setGuidelines(CropImageView.Guidelines.ON)
.setCropShape(CropImageView.CropShape.OVAL)
.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();
editProfilepic.setImageURI(mImageUri);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
Log.e(TAG + "crop_error", error.toString());
}
}
}
示例12: startCropImageActivity
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
/**
* Start crop image activity for the given image.
*/
private void startCropImageActivity(Uri imageUri) {
CropImage.activity(imageUri)
.setGuidelines(CropImageView.Guidelines.ON)
.setMultiTouchEnabled(true)
.start(this);
}
示例13: onSetImageUriComplete
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
@Override
public void onSetImageUriComplete(CropImageView view, Uri uri, Exception error) {
if (error == null) {
Toast.makeText(getActivity(), "Image load successful", Toast.LENGTH_SHORT).show();
} else {
Log.e("AIC", "Failed to load image by URI", error);
Toast.makeText(getActivity(), "Image load failed: " + error.getMessage(), Toast.LENGTH_LONG).show();
}
}
示例14: onContextItemSelected
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
int id = view_ShowMenu.getId();
int itemId = item.getItemId();
switch (id) {
case R.id.avatar:
switch (itemId) {
case R.id.menu_default:
changeImage(img_avatar, "");
break;
case R.id.menu_pic_custom:
FunctionHelper.startCropImageActivity(this, CropImageView.CropShape.OVAL, true);
break;
}
break;
case R.id.background:
switch (itemId) {
case R.id.menu_default:
changeImage(img_background, "");
break;
case R.id.menu_pic_custom:
FunctionHelper.startCropImageActivity(this, CropImageView.CropShape.RECTANGLE, false);
break;
}
break;
}
return super.onContextItemSelected(item);
}
示例15: cropImage
import com.theartofdev.edmodo.cropper.CropImageView; //导入依赖的package包/类
private void cropImage(Uri uri) {
int xAR = 3, yAR = 5;
CropImageView.CropShape cropShape = CropImageView.CropShape.RECTANGLE;
CropImage.activity(uri)
.setGuidelines(CropImageView.Guidelines.ON)
.setCropShape(cropShape)
.setAspectRatio(xAR, yAR)
.setBackgroundColor(Color.argb(100, 100, 100, 100))
//.setRequestedSize(250, 250, CropImageView.RequestSizeOptions.RESIZE_FIT)
.start(this);
}