forked from bumptech/glide
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated g4 rollback of changelist 108724201.
*** Reason for rollback *** Rollforward with compatibility for apps targeting API 21 *** Original change description *** Automated g4 rollback of changelist 108709885. *** Reason for rollback *** Broke Street View *** Original change description *** MOE automated commit. Merge pull request bumptech#762 from vanniktech/master_clean_upload_script Clean upload script up ------------- Merge pull request bumptech#727 from josemontiel/master Implemented CENTER_INSIDE support ------------- Update Downsampler names. ------------- Merge pull request bumptech#758 from mullender/glide-issue-738 fix for issue bumptech#738 Some images simply do no... *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=108748541
- Loading branch information
Showing
10 changed files
with
373 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
library/src/main/java/com/bumptech/glide/load/resource/bitmap/CenterInside.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.bumptech.glide.load.resource.bitmap; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.support.annotation.NonNull; | ||
|
||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; | ||
|
||
import java.security.MessageDigest; | ||
|
||
/** | ||
* Returns the image with its original size if its dimensions match or are smaller | ||
* than the target's, couple with {@link android.widget.ImageView.ScaleType#CENTER_INSIDE} | ||
* in order to center it in Target. If not, then it is scaled so that one of the dimensions of | ||
* the image will be equal to the given dimension and the other will be less than the given | ||
* dimension (maintaining the image's aspect ratio). | ||
*/ | ||
public class CenterInside extends BitmapTransformation { | ||
private static final String ID = "com.bumptech.glide.load.resource.bitmap.CenterInside"; | ||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET); | ||
|
||
public CenterInside(Context context) { | ||
super(context); | ||
} | ||
|
||
public CenterInside(BitmapPool bitmapPool) { | ||
super(bitmapPool); | ||
} | ||
|
||
@Override | ||
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, | ||
int outHeight) { | ||
return TransformationUtils.centerInside(pool, toTransform, outWidth, outHeight); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
return o instanceof CenterInside; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return ID.hashCode(); | ||
} | ||
|
||
@Override | ||
public void updateDiskCacheKey(MessageDigest messageDigest) { | ||
messageDigest.update(ID_BYTES); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.