Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new scale type OnlyScaleDown #194

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ public abstract class BaseSliderView {
*/
private ScaleType mScaleType = ScaleType.Fit;

private int resizeWidth = -1;
private int resizeHeight = -1;

public void setResizeDimensions(int resizeWidth, int resizeHeight) {
this.resizeHeight = resizeHeight;
this.resizeWidth = resizeWidth;
}

public enum ScaleType{
CenterCrop, CenterInside, Fit, FitCenterCrop
CenterCrop, CenterInside, Fit, FitCenterCrop, OnlyScaleDown
}

protected BaseSliderView(Context context) {
Expand Down Expand Up @@ -241,6 +249,13 @@ public void onClick(View v) {
case CenterInside:
rq.fit().centerInside();
break;
case OnlyScaleDown:
if (resizeWidth == -1 && resizeHeight == -1) {
throw new IllegalArgumentException("At least one dimension has to be a positive number");
}
rq.resize(resizeWidth, resizeHeight)
.onlyScaleDown();
break;
}

rq.into(targetImageView,new Callback() {
Expand Down