Skip to content

Commit

Permalink
add setScaleType method
Browse files Browse the repository at this point in the history
  • Loading branch information
daimajia committed Jun 20, 2014
1 parent 3c91d42 commit d498795
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {
textSliderView
.description(name)
.image(file_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(this);

//add your extra information
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# org.gradle.parallel=true


VERSION_NAME=1.0.6
VERSION_CODE=7
VERSION_NAME=1.0.7
VERSION_CODE=8
GROUP=com.daimajia.slider

POM_DESCRIPTION=An amazing and convenient Android image slider.
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 7
versionName "1.0.6"
versionCode 8
versionName "1.0.7"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public abstract class BaseSliderView {

private String mDescription;

/**
* Scale type of the image.
*/
private ScaleType mScaleType = ScaleType.Fit;

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

protected BaseSliderView(Context context) {
mContext = context;
this.mBundle = new Bundle();
Expand Down Expand Up @@ -195,7 +204,18 @@ protected void loadImage(ImageView targetImageView){
if(getError() != 0){
rq.error(getError());
}
rq.fit();

switch (mScaleType){
case Fit:
rq.fit();
break;
case CenterCrop:
rq.fit().centerCrop();
break;
case CenterInside:
rq.fit().centerInside();
break;
}

rq.into(targetImageView,new Callback() {
@Override
Expand All @@ -213,6 +233,17 @@ public void onError() {
});
}



public BaseSliderView setScaleType(ScaleType type){
mScaleType = type;
return this;
}

public ScaleType getScaleType(){
return mScaleType;
}

private View progressBar = null;
/**
* when you want to extends this class, you must call this method to bind click event to your view.
Expand Down

0 comments on commit d498795

Please sign in to comment.