Skip to content

Commit

Permalink
Merge pull request #56 from IsseiAoki/1.1.2
Browse files Browse the repository at this point in the history
1.1.2
  • Loading branch information
igreenwood committed Apr 26, 2016
2 parents a1e964e + 05579ca commit 05bfb7d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change Log
=========
## Version 1.1.2
* Fix bug image ratio collapse with FREE as cropMode
* Fix bug can't parcel a recycled bitmap

## Version 1.1.1
* Fix bug EXIF orientation not applied

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ repositories {
jcenter()
}
dependencies {
compile 'com.isseiaoki:simplecropview:1.1.1'
compile 'com.isseiaoki:simplecropview:1.1.2'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
bindViews(view);
// apply custom font
FontUtils.setFont(mRootLayout);

// mCropView.setDebug(true);
// mCropView.setDebug(true);
// set bitmap to CropImageView
if (mCropView.getImageBitmap() == null) {
mCropView.setImageResource(R.drawable.sample5);
Expand All @@ -83,7 +82,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent result) {
if (requestCode == REQUEST_PICK_IMAGE && resultCode == Activity.RESULT_OK) {
showProgress();
mCropView.startLoad(result.getData(), mLoadCallback);
}else if(requestCode == REQUEST_SAF_PICK_IMAGE && resultCode == Activity.RESULT_OK){
} else if (requestCode == REQUEST_SAF_PICK_IMAGE && resultCode == Activity.RESULT_OK) {
showProgress();
mCropView.startLoad(Utils.ensureUriPermission(getContext(), result), mLoadCallback);
}
Expand Down Expand Up @@ -135,12 +134,12 @@ public void cropImage() {
}

@OnShowRationale(Manifest.permission.READ_EXTERNAL_STORAGE)
public void showRationaleForPick(PermissionRequest request){
public void showRationaleForPick(PermissionRequest request) {
showRationaleDialog(R.string.permission_pick_rationale, request);
}

@OnShowRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)
public void showRationaleForCrop(PermissionRequest request){
public void showRationaleForCrop(PermissionRequest request) {
showRationaleDialog(R.string.permission_crop_rationale, request);
}

Expand All @@ -149,7 +148,7 @@ public void showProgress() {
getFragmentManager()
.beginTransaction()
.add(f, PROGRESS_DIALOG)
.commit();
.commitAllowingStateLoss();
}

public void dismissProgress() {
Expand All @@ -158,7 +157,7 @@ public void dismissProgress() {
if (manager == null) return;
ProgressDialogFragment f = (ProgressDialogFragment) manager.findFragmentByTag(PROGRESS_DIALOG);
if (f != null) {
getFragmentManager().beginTransaction().remove(f).commit();
getFragmentManager().beginTransaction().remove(f).commitAllowingStateLoss();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public LoadScaledImageTask(Context context, Uri uri, ImageView imageView, int wi
@Override
public void run() {
final int exifRotation = Utils.getExifOrientation(context, uri);
Log.d(TAG, "exifRotation = "+exifRotation);
int maxSize = Utils.getMaxSize();
int requestSize = Math.min(width, maxSize);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,9 @@ private Bitmap decodeRegion() {
cropped = decoder.decodeRegion(cropRect, new BitmapFactory.Options());
if (mAngle != 0) {
Bitmap rotated = getRotatedBitmap(cropped);
cropped.recycle();
if(cropped != getBitmap() && cropped != rotated){
cropped.recycle();
}
cropped = rotated;
}
} catch (IOException e) {
Expand Down Expand Up @@ -1279,7 +1281,7 @@ private Bitmap scaleBitmapIfNeeded(Bitmap cropped) {
int height = cropped.getHeight();
int outWidth = 0;
int outHeight = 0;
float imageRatio = getRatioX() / getRatioY();
float imageRatio = getRatioX(mFrameRect.width()) / getRatioY(mFrameRect.height());

if (mOutputWidth > 0) {
outWidth = mOutputWidth;
Expand All @@ -1303,7 +1305,7 @@ private Bitmap scaleBitmapIfNeeded(Bitmap cropped) {

if (outWidth > 0 && outHeight > 0) {
Bitmap scaled = Utils.getScaledBitmap(cropped, outWidth, outHeight);
if (cropped != scaled) {
if (cropped != getBitmap() && cropped != scaled) {
cropped.recycle();
}
cropped = scaled;
Expand Down Expand Up @@ -1538,12 +1540,16 @@ public Bitmap getCroppedBitmap() {
null,
false
);
if (rotated != source) {
if (cropped != source && cropped != rotated) {
rotated.recycle();
}

if (mCropMode == CropMode.CIRCLE) {
cropped = getCircularBitmap(cropped);
Bitmap circle = getCircularBitmap(cropped);
if(cropped != getBitmap()){
cropped.recycle();
}
cropped = circle;
}
return cropped;
}
Expand Down Expand Up @@ -1572,8 +1578,6 @@ public Bitmap getCircularBitmap(Bitmap square) {
canvas.drawCircle(halfWidth, halfHeight, Math.min(halfWidth, halfHeight), paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(square, rect, rect, paint);

square.recycle();
return output;
}

Expand Down Expand Up @@ -1607,7 +1611,11 @@ public void run() {
else {
cropped = decodeRegion();
if (mCropMode == CropMode.CIRCLE) {
cropped = getCircularBitmap(cropped);
Bitmap circle = getCircularBitmap(cropped);
if(cropped != getBitmap()){
cropped.recycle();
}
cropped = circle;
}
}

Expand Down

0 comments on commit 05bfb7d

Please sign in to comment.