com.soundcloud.android.crop.Crop Java Examples
The following examples show how to use
com.soundcloud.android.crop.Crop.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DetailActivity.java From Dashboard with MIT License | 6 votes |
private void handleCrop(int resultCode, Intent result) { if (resultCode == RESULT_OK) { mImageView.setImageURI(Crop.getOutput(result)); WallpaperManager myWallpaperManager = WallpaperManager .getInstance(getApplicationContext()); try { Bitmap mBitmap = getImageBitmap(); myWallpaperManager.setBitmap(mBitmap); Toast.makeText(DetailActivity.this, "Wallpaper set", Toast.LENGTH_SHORT).show(); } catch (IOException e) { Toast.makeText(DetailActivity.this, "Error setting wallpaper", Toast.LENGTH_SHORT) .show(); } } else if (resultCode == Crop.RESULT_ERROR) { Toast.makeText(this, Crop.getError(result).getMessage(), Toast.LENGTH_SHORT).show(); } }
Example #2
Source File: DetailActivity.java From Dashboard with MIT License | 6 votes |
private void handleCrop(int resultCode, Intent result) { if (resultCode == RESULT_OK) { mImageView.setImageURI(Crop.getOutput(result)); WallpaperManager myWallpaperManager = WallpaperManager .getInstance(getApplicationContext()); try { Bitmap mBitmap = getImageBitmap(); myWallpaperManager.setBitmap(mBitmap); Toast.makeText(DetailActivity.this, "Wallpaper set", Toast.LENGTH_SHORT).show(); } catch (IOException e) { Toast.makeText(DetailActivity.this, "Error setting wallpaper", Toast.LENGTH_SHORT) .show(); } } else if (resultCode == Crop.RESULT_ERROR) { Toast.makeText(this, Crop.getError(result).getMessage(), Toast.LENGTH_SHORT).show(); } }
Example #3
Source File: TakePhotoActivity.java From actor-platform with GNU Affero General Public License v3.0 | 6 votes |
@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(); }
Example #4
Source File: ViewAvatarActivity.java From actor-platform with GNU Affero General Public License v3.0 | 6 votes |
@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); } } }
Example #5
Source File: CropHelper.java From FamilyChat with Apache License 2.0 | 6 votes |
/** * 跳转到裁剪图片的界面 * * @param fragment 上下文 * @param filePath 待裁剪图片绝对路径 * @param cachePath 缓存地址 * @param aspectX 裁剪比例X * @param aspectY 裁剪比例Y * @param maxX 裁剪后最大分辨率X * @param maxY 裁剪后最大分辨率Y */ public static void startCrop(Fragment fragment, String filePath, String cachePath , int aspectX, int aspectY, int maxX, int maxY) { Activity activity = fragment.getActivity(); if (activity == null) { Log.e(TAG, "CropHelper--->片段附着的Activity为空"); return; } Pair<Uri, Uri> uriPair = getUris(activity, filePath, cachePath); if (uriPair == null) return; Crop.of(uriPair.first, uriPair.second) .withAspect(aspectX, aspectY) .withMaxSize(maxX, maxY) .start(activity, fragment, REQUEST_CODE_CROP); }
Example #6
Source File: TUtils.java From TakePhoto with Apache License 2.0 | 6 votes |
/** * 通过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()); } } }
Example #7
Source File: CropHelper.java From FamilyChat with Apache License 2.0 | 6 votes |
/** * 跳转到裁剪矩形的界面 * * @param fragment 跳转的片段 * @param filePath 待裁剪图片绝对路径 * @param cachePath 缓存地址 * @param maxX 裁剪后最大分辨率X * @param maxY 裁剪后最大分辨率Y */ public static void startCropInRect(Fragment fragment, String filePath , String cachePath, int maxX, int maxY) { Activity activity = fragment.getActivity(); if (activity == null) { Log.e(TAG, "CropHelper--->片段附着的Activity为空"); return; } Pair<Uri, Uri> uriPair = getUris(activity, filePath, cachePath); if (uriPair == null) return; Crop.of(uriPair.first, uriPair.second) .asSquare().withMaxSize(maxX, maxY) .start(activity, fragment, REQUEST_CODE_CROP); }
Example #8
Source File: GroupCreateActivity.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
private void setAvatarView(Intent data) { final Uri output = Crop.getOutput(data); GlideApp.with(this) .asBitmap() .load(output) .skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.NONE) .centerCrop() .override(AVATAR_SIZE, AVATAR_SIZE) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { setAvatar(output, resource); } }); }
Example #9
Source File: GroupCreateActivity.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
private void initializeAvatarView() { boolean imageLoaded = false; if (groupChatId != 0) { String avatarPath = dcContext.getChat(groupChatId).getProfileImage(); File avatarFile = new File(avatarPath); if (avatarFile.exists()) { imageLoaded = true; GlideApp.with(this) .load(avatarFile) .circleCrop() .into(avatar); } } if (!imageLoaded) { avatar.setImageDrawable(new ResourceContactPhoto(R.drawable.ic_group_white_24dp).asDrawable(this, ThemeUtil.getDummyContactColor(this))); } avatar.setOnClickListener(view -> Crop.pickImage(GroupCreateActivity.this)); }
Example #10
Source File: UserProfileActivity.java From styT with Apache License 2.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE && resultCode == RESULT_CODE) { Bundle bundle = data.getExtras(); if (isUsername) { usernameText.setText(bundle.getString("username")); isChangeUsername = true; } else { personalityText.setText(bundle.getString("username")); } isChange = true; btnVisibility(); } else if (requestCode == Crop.REQUEST_PICK && resultCode == RESULT_OK) { beginCrop(data.getData()); } else if (requestCode == Crop.REQUEST_CROP) { handleCrop(resultCode, data); } }
Example #11
Source File: MyProfileActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
private void startCropActivity(Uri originalUri) { String extensionOriginalUri = originalUri.getPath().substring(originalUri.getPath().lastIndexOf(".")).toLowerCase(); canPerformLogout.set(false); imageUri = MediaUtils.getValidUri(new File(getCacheDir(), extensionOriginalUri), this); Crop.of(originalUri, imageUri).asSquare().start(this); }
Example #12
Source File: MyProfileActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
private void handleCrop(int resultCode, Intent result) { if (resultCode == RESULT_OK) { isNeedUpdateImage = true; photoImageView.setImageURI(imageUri); } else if (resultCode == Crop.RESULT_ERROR) { ToastUtils.longToast(Crop.getError(result).getMessage()); } canPerformLogout.set(true); }
Example #13
Source File: MyProfileActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Crop.REQUEST_CROP) { handleCrop(resultCode, data); } super.onActivityResult(requestCode, resultCode, data); }
Example #14
Source File: UserProfileActivity.java From styT with Apache License 2.0 | 5 votes |
private void handleCrop(int resultCode, Intent data) { if (resultCode == RESULT_OK) { // Log.e(TAG,"=====>Crop.getOutput(data)=====>"+Crop.getOutput(data)); // userImg.setImageURI(Crop.getOutput(data)); filePath = Crop.getOutput(data).getPath(); ImageLoader.getInstance(1, ImageLoader.Type.LIFO).loaderImage(filePath, userImg, false); //Log.e(TAG, "===filePath====" + filePath); isChangeUserImgNo = false; isChange = true; btnVisibility(); } else if (resultCode == Crop.RESULT_ERROR) { Toast.makeText(this, Crop.getError(data).getMessage(), Toast.LENGTH_SHORT).show(); } }
Example #15
Source File: SignUpActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Crop.REQUEST_CROP) { handleCrop(resultCode, data); } super.onActivityResult(requestCode, resultCode, data); }
Example #16
Source File: DetailActivity.java From Dashboard with MIT License | 5 votes |
private void beginCrop(Uri source) { Uri outputUri = Uri.parse("file:///sdcard/test.png"); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); int height = displaymetrics.heightPixels; int width = displaymetrics.widthPixels; Crop.of(source, outputUri).withMaxSize(width,height).start(this); }
Example #17
Source File: SignUpActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
private void handleCrop(int resultCode, Intent result) { if (resultCode == RESULT_OK) { isNeedUpdateImage = true; avatarImageView.setImageURI(imageUri); } else if (resultCode == Crop.RESULT_ERROR) { ToastUtils.longToast(Crop.getError(result).getMessage()); } }
Example #18
Source File: DetailActivity.java From Dashboard with MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent result) { if (requestCode == Crop.REQUEST_PICK && resultCode == RESULT_OK) { beginCrop(result.getData()); } else if (requestCode == Crop.REQUEST_CROP) { handleCrop(resultCode, result); } }
Example #19
Source File: CreateGroupDialogActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Crop.REQUEST_CROP) { handleCrop(resultCode, data); } super.onActivityResult(requestCode, resultCode, data); }
Example #20
Source File: CreateGroupDialogActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
private void startCropActivity(Uri originalUri) { canPerformLogout.set(false); String extensionOriginalUri = originalUri.getPath().substring(originalUri.getPath().lastIndexOf(".")).toLowerCase(); imageUri = MediaUtils.getValidUri(new File(getCacheDir(), extensionOriginalUri), this); Crop.of(originalUri, imageUri).asSquare().start(this); }
Example #21
Source File: CreateGroupDialogActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
private void handleCrop(int resultCode, Intent result) { if (resultCode == RESULT_OK) { if (imageUri != null) { photoImageView.setImageURI(imageUri); } } else if (resultCode == Crop.RESULT_ERROR) { ToastUtils.longToast(Crop.getError(result).getMessage()); } canPerformLogout.set(true); }
Example #22
Source File: GroupDialogDetailsActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Crop.REQUEST_CROP) { handleCrop(resultCode, data); canPerformLogout.set(true); } else if (requestCode == AddFriendsToGroupActivity.RESULT_ADDED_FRIENDS) { if (data != null) { handleAddedFriends(data); } canPerformLogout.set(true); } super.onActivityResult(requestCode, resultCode, data); }
Example #23
Source File: GroupDialogDetailsActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
private void handleCrop(int resultCode, Intent result) { if (resultCode == RESULT_OK) { isNeedUpdateImage = true; if (imageUri != null) { photoImageView.setImageURI(imageUri); } startAction(); } else if (resultCode == Crop.RESULT_ERROR) { ToastUtils.longToast(Crop.getError(result).getMessage()); } }
Example #24
Source File: UserInfoEditFragment.java From meiShi with Apache License 2.0 | 5 votes |
private void handleCrop(Intent result) { Uri uri = Crop.getOutput(result); newUserAvatarPath = UriUtils.getPath(getActivity(), uri); Bitmap avatorBitmap = BitmapFactory.decodeFile(newUserAvatarPath); Drawable drawable = DrawableUtils.roundedBitmap(avatorBitmap); mPreferenceUserAvatar.setIcon(drawable); }
Example #25
Source File: DetailActivity.java From Dashboard with MIT License | 5 votes |
private void beginCrop(Uri source) { Uri outputUri = Uri.parse("file:///sdcard/test.png"); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); int height = displaymetrics.heightPixels; int width = displaymetrics.widthPixels; Crop.of(source, outputUri).withMaxSize(width,height).start(this); }
Example #26
Source File: UserInfoEditFragment.java From meiShi with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent result) { super.onActivityResult(requestCode, resultCode, result); if (resultCode != Activity.RESULT_OK) return; if (requestCode == CAMERA_REQUEST_CODE) { beginCrop(Uri.fromFile(new File(IMAGNAME))); } else if (requestCode == Crop.REQUEST_PICK) { beginCrop(result.getData()); } else if (requestCode == Crop.REQUEST_CROP) { handleCrop(result); } }
Example #27
Source File: DetailActivity.java From Dashboard with MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent result) { if (requestCode == Crop.REQUEST_PICK && resultCode == RESULT_OK) { beginCrop(result.getData()); } else if (requestCode == Crop.REQUEST_CROP) { handleCrop(resultCode, result); } }
Example #28
Source File: CropHelper.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * 跳转到裁剪图片的界面 * * @param activity 跳转的片段 * @param filePath 待裁剪图片绝对路径 * @param cachePath 缓存地址 * @param aspectX 裁剪比例X * @param aspectY 裁剪比例Y * @param maxX 裁剪后最大分辨率X * @param maxY 裁剪后最大分辨率Y */ public static void startCrop(Activity activity, String filePath, String cachePath , int aspectX, int aspectY, int maxX, int maxY) { Pair<Uri, Uri> uriPair = getUris(activity, filePath, cachePath); if (uriPair == null) return; Crop.of(uriPair.first, uriPair.second) .withAspect(aspectX, aspectY) .withMaxSize(maxX, maxY) .start(activity, REQUEST_CODE_CROP); }
Example #29
Source File: CropHelper.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * 跳转到裁剪矩形的界面 * * @param activity 上下文 * @param filePath 待裁剪图片绝对路径 * @param cachePath 缓存地址 * @param maxX 裁剪后最大分辨率X * @param maxY 裁剪后最大分辨率Y */ public static void startCropInRect(Activity activity, String filePath , String cachePath, int maxX, int maxY) { Pair<Uri, Uri> uriPair = getUris(activity, filePath, cachePath); if (uriPair == null) return; Crop.of(uriPair.first, uriPair.second).asSquare() .withMaxSize(maxX, maxY).start(activity, REQUEST_CODE_CROP); }
Example #30
Source File: GroupCreateActivity.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@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) { if(contact!=null) { Address address = Address.fromSerialized(contact); Recipient recipient = Recipient.from(this, address); addSelectedContacts(recipient); } } break; case Crop.REQUEST_PICK: new Crop(data.getData()).output(outputFile).asSquare().start(this); break; case Crop.REQUEST_CROP: setAvatarView(data); } }