本文整理汇总了Java中com.soundcloud.android.crop.Crop类的典型用法代码示例。如果您正苦于以下问题:Java Crop类的具体用法?Java Crop怎么用?Java Crop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Crop类属于com.soundcloud.android.crop包,在下文中一共展示了Crop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beginCrop
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
private void beginCrop(Uri source, int requestCode)
{
ContentResolver resolver = getActivity().getContentResolver();
boolean isSupport = imageTypeIsSupport(resolver, source);
if (isSupport) {
Uri destination = Uri.fromFile(new File(getActivity().getCacheDir(), String.valueOf(requestCode)));
if (requestCode == PICK_FACE1_REQUEST) {
Crop.of(source, destination).withAspect(160, 240).start(getActivity(), this, CROP_FACE1_REQUEST);
} else if (requestCode == PICK_FACE2_REQUEST) {
Crop.of(source, destination).withAspect(160, 240).start(getActivity(), this, CROP_FACE2_REQUEST);
}
} else {
Toast.makeText(getActivity(), R.string.error_img_type, Toast.LENGTH_SHORT).show();
}
}
示例2: cropWithOwnApp
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
/**
* 通过TakePhoto自带的裁切工具裁切图片
* @param contextWrap
* @param imageUri
* @param outPutUri
* @param options
*/
public static void cropWithOwnApp(TContextWrap contextWrap, Uri imageUri, Uri outPutUri, CropOptions options){
if (options.getAspectX()*options.getAspectY()>0){
if (contextWrap.getFragment()!=null){
Crop.of(imageUri, outPutUri).withAspect(options.getAspectX(),options.getAspectY()).start(contextWrap.getActivity(),contextWrap.getFragment());
}else {
Crop.of(imageUri, outPutUri).withAspect(options.getAspectX(),options.getAspectY()).start(contextWrap.getActivity());
}
}else if (options.getOutputX()*options.getOutputY()>0){
if (contextWrap.getFragment()!=null){
Crop.of(imageUri, outPutUri).withMaxSize(options.getOutputX(),options.getOutputY()).start(contextWrap.getActivity(),contextWrap.getFragment());
}else {
Crop.of(imageUri, outPutUri).withMaxSize(options.getOutputX(),options.getOutputY()).start(contextWrap.getActivity());
}
}else {
if (contextWrap.getFragment()!=null){
Crop.of(imageUri, outPutUri).asSquare().start(contextWrap.getActivity(),contextWrap.getFragment());
}else {
Crop.of(imageUri, outPutUri).asSquare().start(contextWrap.getActivity());
}
}
}
示例3: editHead
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
/**
* 编辑头像
*/
private void editHead() {
BottomSheetImagePicker
.getInstance()
.showImagePicker(BottomSheetImagePicker.PickerType.BOTH,
this,
bottomSheet,
new BottomSheetImagePicker.Listener() {
@Override
public void onImageArrived(Uri selectedImageUri) {
String imgPath = FileUtils.getImageAbsolutePath(EditUserInfoActivity.this, selectedImageUri);
if (FileUtils.isGif(imgPath)) {
presenter.requestChangeHeadPic(imgPath);
return;
}
Uri destination = Uri.fromFile(new File(getCacheDir(), "cropped"));
Crop.of(selectedImageUri, destination).asSquare().start(EditUserInfoActivity.this);
}
});
}
示例4: initializeResources
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
private void initializeResources() {
RecipientsEditor recipientsEditor = ViewUtil.findById(this, R.id.recipients_text);
PushRecipientsPanel recipientsPanel = ViewUtil.findById(this, R.id.recipients);
lv = ViewUtil.findById(this, R.id.selected_contacts_list);
avatar = ViewUtil.findById(this, R.id.avatar);
groupName = ViewUtil.findById(this, R.id.group_name);
creatingText = ViewUtil.findById(this, R.id.creating_group_text);
SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(this);
adapter.setOnRecipientDeletedListener(this);
lv.setAdapter(adapter);
recipientsEditor.setHint(R.string.recipients_panel__add_members);
recipientsPanel.setPanelChangeListener(this);
findViewById(R.id.contacts_button).setOnClickListener(new AddRecipientButtonListener());
avatar.setImageDrawable(ContactPhotoFactory.getDefaultGroupPhoto()
.asDrawable(this, ContactColors.UNKNOWN_COLOR.toConversationColor(this)));
avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Crop.pickImage(GroupCreateActivity.this);
}
});
}
示例5: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Crop.REQUEST_PICK) {
photoImageView.setClickable(true);
if (resultCode == Activity.RESULT_OK) {
// 选择图片后
beginCrop(data.getData());
}
} else if (requestCode == Crop.REQUEST_CROP) {
// 图片编辑完后
handleCrop(resultCode, data);
}
}
示例6: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
/* Changed by Sharath Pandeshwar on 05/03/2014 */
//Changed to CreateEditWallPostFragment
if (requestCode == Crop.REQUEST_PICK) {
((CreateEditWallPostFragment) getSupportFragmentManager().findFragmentByTag(AppConstants.FragmentTags.POST_ON_WALL)).onActivityResult(requestCode, resultCode, data);
Logger.d(TAG, "REQUEST PICK");
} else if (requestCode == Crop.REQUEST_CROP) {
((CreateEditWallPostFragment) getSupportFragmentManager().findFragmentByTag(AppConstants.FragmentTags.POST_ON_WALL)).onActivityResult(requestCode, resultCode, data);
Logger.d(TAG, "REQUEST CROP");
}
/* End of modification by Sharath Pandeshwar on 05/03/2014 */
}
示例7: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_GALLERY && resultCode == Activity.RESULT_OK) {
tempAvatarPath = Files.getInternalTempFile("avatar", "jpg");
Crop.of(data.getData(), Uri.fromFile(new File(tempAvatarPath)))
.asSquare()
.start(this);
return;
} else if (requestCode == REQUEST_PHOTO && resultCode == Activity.RESULT_OK) {
tempAvatarPath = Files.getInternalTempFile("avatar", "jpg");
Crop.of(Uri.fromFile(new File(externalFile)), Uri.fromFile(new File(tempAvatarPath)))
.asSquare()
.start(this);
return;
} else if (requestCode == Crop.REQUEST_CROP && resultCode == Activity.RESULT_OK) {
setResult(RESULT_OK, new Intent()
.putExtra(Intents.EXTRA_RESULT, Intents.RESULT_IMAGE)
.putExtra(Intents.EXTRA_IMAGE, tempAvatarPath));
finish();
return;
}
setResult(RESULT_CANCELED);
finish();
}
示例8: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_GALLERY && resultCode == Activity.RESULT_OK) {
avatarPath = Files.getInternalTempFile("avatar", "jpg");
Crop.of(data.getData(), Uri.fromFile(new File(avatarPath)))
.asSquare()
.start(this);
} else if (requestCode == REQUEST_PHOTO && resultCode == Activity.RESULT_OK) {
avatarPath = Files.getInternalTempFile("avatar", "jpg");
Crop.of(Uri.fromFile(new File(externalFile)), Uri.fromFile(new File(avatarPath)))
.asSquare()
.start(this);
} else if (requestCode == Crop.REQUEST_CROP && resultCode == Activity.RESULT_OK) {
if (avatarPath == null) {
return;
}
if (peer.getPeerType() == PeerType.PRIVATE) {
if (peer.getPeerId() == myUid()) {
messenger().changeMyAvatar(avatarPath);
}
} else if (peer.getPeerType() == PeerType.GROUP) {
messenger().changeGroupAvatar(peer.getPeerId(), avatarPath);
}
}
}
示例9: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_GALLERY && resultCode == Activity.RESULT_OK) {
avatarPath = AppContext.getInternalTempFile("avatar", "jpg");
Crop.of(data.getData(), Uri.fromFile(new File(avatarPath)))
.asSquare()
.start(this);
} else if (requestCode == REQUEST_PHOTO && resultCode == Activity.RESULT_OK) {
avatarPath = AppContext.getInternalTempFile("avatar", "jpg");
Crop.of(Uri.fromFile(new File(externalFile)), Uri.fromFile(new File(avatarPath)))
.asSquare()
.start(this);
} else if (requestCode == Crop.REQUEST_CROP && resultCode == Activity.RESULT_OK) {
if (peer.getPeerType() == PeerType.PRIVATE) {
if (peer.getPeerId() == myUid()) {
messenger().changeMyAvatar(avatarPath);
}
} else if (peer.getPeerType() == PeerType.GROUP) {
messenger().changeGroupAvatar(peer.getPeerId(), avatarPath);
}
}
}
示例10: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_GALLERY && resultCode == Activity.RESULT_OK) {
tempAvatarPath = AppContext.getInternalTempFile("avatar", "jpg");
Crop.of(data.getData(), Uri.fromFile(new File(tempAvatarPath)))
.asSquare()
.start(this);
return;
} else if (requestCode == REQUEST_PHOTO && resultCode == Activity.RESULT_OK) {
tempAvatarPath = AppContext.getInternalTempFile("avatar", "jpg");
Crop.of(Uri.fromFile(new File(externalFile)), Uri.fromFile(new File(tempAvatarPath)))
.asSquare()
.start(this);
return;
} else if (requestCode == Crop.REQUEST_CROP && resultCode == Activity.RESULT_OK) {
setResult(RESULT_OK, new Intent()
.putExtra(Intents.EXTRA_RESULT, Intents.RESULT_IMAGE)
.putExtra(Intents.EXTRA_IMAGE, tempAvatarPath));
finish();
return;
}
setResult(RESULT_CANCELED);
finish();
}
示例11: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Crop.REQUEST_CROP && resultCode == Activity.RESULT_OK) {
Rect rect = Crop.getRect(data);
Boundary b = new Boundary(rect.left, rect.top, rect.width(), rect.height());
requestBounds(b);
}
else if (resultCode == Crop.RESULT_REFRESH)
{
takePhoto();
}
else {
mListener.onSetupServerAborted();
}
}
示例12: initializeResources
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
private void initializeResources() {
recipientsEditor = ViewUtil.findById(this, R.id.recipients_text);
PushRecipientsPanel recipientsPanel = ViewUtil.findById(this, recipients);
lv = ViewUtil.findById(this, R.id.selected_contacts_list);
avatar = ViewUtil.findById(this, R.id.avatar);
groupName = ViewUtil.findById(this, R.id.group_name);
groupName.setEnabled(false);
countValue = ViewUtil.findById(this, R.id.Label_count_value);
creatingText = ViewUtil.findById(this, R.id.creating_group_text);
contactsButton = ViewUtil.findById(this, R.id.contacts_button);
SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(this);
adapter.setOnRecipientDeletedListener(this);
lv.setAdapter(adapter);
recipientsEditor.setVisibility(View.GONE);
recipientsEditor.setHint(R.string.recipients_panel__add_members);
recipientsPanel.setPanelChangeListener(this);
contactsButton.setVisibility(View.GONE);
contactsButton.setOnClickListener(new AddRecipientButtonListener());
avatar.setImageDrawable(ContactPhotoFactory.getDefaultGroupPhoto()
.asDrawable(this, ContactColors.UNKNOWN_COLOR.toConversationColor(this)));
avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Crop.pickImage(GroupCreateActivity.this);
}
});
avatar.setEnabled(false);
}
示例13: onActivityResult
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
@Override
public void onActivityResult(int reqCode, int resultCode, final Intent data) {
super.onActivityResult(reqCode, resultCode, data);
Uri outputFile = Uri.fromFile(new File(getCacheDir(), "cropped"));
if (data == null || resultCode != Activity.RESULT_OK)
return;
switch (reqCode) {
case PICK_CONTACT:
List<String> selected = data.getStringArrayListExtra("contacts");
for (String contact : selected) {
final Recipient recipient = RecipientFactory.getRecipientsFromString(this, contact, false).getPrimaryRecipient();
if (recipient != null) addSelectedContacts(recipient);
}
break;
case Crop.REQUEST_PICK:
new Crop(data.getData()).output(outputFile).asSquare().start(this);
break;
case Crop.REQUEST_CROP:
Glide.with(this).load(Crop.getOutput(data)).asBitmap()
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.centerCrop().override(AVATAR_SIZE, AVATAR_SIZE)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
setAvatar(Crop.getOutput(data), resource);
}
});
}
}
示例14: processCroppedPhoto
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
private void processCroppedPhoto(int resultCode, Intent data){
if (resultCode == Crop.RESULT_ERROR)
{
uiHelper.dismissProgressCard();
return;
}
try
{
// If enabled we will save the image to the app
// directory in gallery else we will save it in the cache dir.
File dir;
if (BDefines.Options.SaveImagesToDir)
dir = Utils.ImageSaver.getAlbumStorageDir(activity.get(), Utils.ImageSaver.IMAGE_DIR_NAME);
else
dir = this.activity.get().getCacheDir();
if (dir == null)
{
uiHelper.dismissProgressCard();
uiHelper.showAlertToast(R.string.unable_to_fetch_image);
return;
}
File image = new File(dir, mFileName + ".jpeg");
selectedFilePath = image.getPath();
// Scanning the image so it would be visible in the gallery images.
if (BDefines.Options.SaveImagesToDir)
ImageUtils.scanFilePathForGallery(activity.get(), selectedFilePath);
sendImageMessage(image.getPath());
}
catch (NullPointerException e){
uiHelper.showAlertToast(R.string.unable_to_fetch_image);
}
}
示例15: processPickedPhoto
import com.soundcloud.android.crop.Crop; //导入依赖的package包/类
private void processPickedPhoto(int resultCode, Intent data){
switch (resultCode)
{
case Activity.RESULT_OK:
Uri uri = data.getData();
mFileName = DaoCore.generateEntity();
// If enabled we will save the image to the app
// directory in gallery else we will save it in the cache dir.
File dir;
if (BDefines.Options.SaveImagesToDir)
dir = Utils.ImageSaver.getAlbumStorageDir(activity.get(), Utils.ImageSaver.IMAGE_DIR_NAME);
else
dir = this.activity.get().getCacheDir();
if (dir == null)
{
uiHelper.dismissProgressCard();
uiHelper.showAlertToast(R.string.unable_to_fetch_image);
return;
}
Uri outputUri = Uri.fromFile(new File(dir, mFileName + ".jpeg"));
crop = new Cropper(uri);
Intent cropIntent = crop.getAdjustIntent(this.activity.get(), outputUri);
int request = Crop.REQUEST_CROP + PHOTO_PICKER_ID;
activity.get().startActivityForResult(cropIntent, request);
return;
case Activity.RESULT_CANCELED:
uiHelper.dismissProgressCard();
}
}