本文整理汇总了Java中com.theartofdev.edmodo.cropper.CropImage.ActivityBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java CropImage.ActivityBuilder方法的具体用法?Java CropImage.ActivityBuilder怎么用?Java CropImage.ActivityBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.theartofdev.edmodo.cropper.CropImage
的用法示例。
在下文中一共展示了CropImage.ActivityBuilder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPostExecute
import com.theartofdev.edmodo.cropper.CropImage; //导入方法依赖的package包/类
@Override
protected void onPostExecute(final Pair<CopyResult[], Exception> result) {
mActivity.dismissProgressDialog(TAG_COPYING_IMAGE);
if (result.first != null) {
CopyResult[] copyResults = result.first;
final Intent callingIntent = mActivity.getIntent();
final boolean supportsCrop = copyResults.length == 1;
final boolean hasCropParameters = callingIntent.hasExtra(EXTRA_ASPECT_X) && callingIntent.hasExtra(EXTRA_ASPECT_Y)
|| callingIntent.hasExtra(EXTRA_MAX_WIDTH) && callingIntent.hasExtra(EXTRA_MAX_HEIGHT);
if (supportsCrop && mNeedsCrop && hasCropParameters) {
final Uri tempImageUri;
try {
tempImageUri = mActivity.createTempMediaUri(copyResults[0].extension);
} catch (IOException e) {
Toast.makeText(mActivity, R.string.pnc__error_cannot_open_file, Toast.LENGTH_SHORT).show();
return;
}
CropImage.ActivityBuilder crop = CropImage.activity(copyResults[0].uri);
crop.setAutoZoomEnabled(true);
crop.setMultiTouchEnabled(true);
crop.setOutputUri(tempImageUri);
final int aspectX = callingIntent.getIntExtra(EXTRA_ASPECT_X, -1);
final int aspectY = callingIntent.getIntExtra(EXTRA_ASPECT_Y, -1);
if (aspectX > 0 && aspectY > 0) {
crop.setAspectRatio(aspectX, aspectY);
}
final int maxWidth = callingIntent.getIntExtra(EXTRA_MAX_WIDTH, -1);
final int maxHeight = callingIntent.getIntExtra(EXTRA_MAX_HEIGHT, -1);
if (maxWidth > 0 && maxHeight > 0) {
crop.setRequestedSize(maxWidth, maxHeight, RequestSizeOptions.RESIZE_FIT);
}
final String outputFormat = callingIntent.getStringExtra(EXTRA_OUTPUT_FORMAT);
if (outputFormat != null) {
crop.setOutputCompressFormat(Bitmap.CompressFormat.valueOf(outputFormat));
}
final int outputQuality = callingIntent.getIntExtra(EXTRA_OUTPUT_QUALITY, -1);
if (outputQuality >= 0) {
crop.setOutputCompressQuality(outputQuality);
}
final Intent cropIntent = crop.getIntent(mActivity);
cropIntent.setClassName(mActivity, callingIntent.getStringExtra(EXTRA_CROP_ACTIVITY_CLASS));
mActivity.startActivityForResult(cropIntent, REQUEST_CROP);
return;
}
final Intent data = new Intent();
data.setData(copyResults[0].uri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ClipData clipData = ClipData.newUri(mActivity.getContentResolver(),
mActivity.getString(R.string.pnc__label_media), copyResults[0].uri);
for (int i = 1, j = copyResults.length; i < j; i++) {
Uri dstUri = copyResults[i].uri;
clipData.addItem(new ClipData.Item(dstUri));
}
data.setClipData(clipData);
}
data.putExtra(EXTRA_EXTRAS, mActivity.getIntent().getBundleExtra(EXTRA_EXTRAS));
mActivity.setResult(RESULT_OK, data);
} else if (result.second != null) {
Log.w(LOGTAG, result.second);
Toast.makeText(mActivity, R.string.pnc__error_cannot_open_file, Toast.LENGTH_SHORT).show();
}
mActivity.finish();
}