Skip to content

Commit

Permalink
2.5.0. ScaleType methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dexafree committed Jul 30, 2015
1 parent 51fa7ce commit c101bc0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# MaterialListView Changelog

## 2.5.0
* Now Cards that have an Image (Such as BigImageCard or BigImageButtonsCard) provide methods to choose the ScaleType (CENTER_CROP, FIT_XY...). By default is set to `CENTER_CROP`

## 2.4.6
* Now `BigImageCard` and `BigImageButtonsCard` center the image and crop it.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ In order to use MaterialList, you can either clone the project and import it as
```groovy
dependencies {
...
compile 'com.github.dexafree:materiallist:2.4.6'
compile 'com.github.dexafree:materiallist:2.5.0'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.dexafree.materialList.cards.BasicButtonsCard;
Expand Down Expand Up @@ -106,6 +107,7 @@ private Card getRandomCard(final int position) {
//card.setDrawable(R.drawable.photo);
card.setDrawable("https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png");
card.setTag("BIG_IMAGE_CARD");
card.setImageScaleType(ImageView.ScaleType.CENTER_INSIDE);
return card;

case 2:
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=2.4.6
VERSION_CODE=246
VERSION_NAME=2.5.0
VERSION_CODE=250
GROUP=com.github.dexafree

POM_DESCRIPTION=Android library aimed to get the beautiful CardViews that Google shows at its official design specifications
Expand Down
4 changes: 2 additions & 2 deletions materialList/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 10
targetSdkVersion 21
versionCode 246
versionName "2.4.6"
versionCode 250
versionName "2.5.0"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.dexafree.materialList.events.BusProvider;

/**
* The SimpleCard defines a title, description and (if it is set on the layout) an image.
*/
public abstract class SimpleCard extends BasicCard {

private String mTitle;
private int mTitleColor = -1;
private String mDescription;
private int mDescriptionColor = -1;
private Drawable mDrawable;
private String urlImage;
private ImageView.ScaleType imageScaleType = ImageView.ScaleType.CENTER_CROP;

public SimpleCard(Context context) {
super(context);
Expand Down Expand Up @@ -93,4 +96,12 @@ public void setDescriptionColorRes(int colorId) {
setDescriptionColor(getResources().getColor(colorId));
}

public ImageView.ScaleType getImageScaleType() {
return imageScaleType;
}

public void setImageScaleType(ImageView.ScaleType scaleType) {
this.imageScaleType = scaleType;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ public void build(T card) {
// Image
ImageView imageView = (ImageView) findViewById(R.id.imageView);
if (imageView != null) {

ImageView.ScaleType scaleType = card.getImageScaleType();
imageView.setScaleType(scaleType);

if(card.getUrlImage() == null || card.getUrlImage().isEmpty()) {
imageView.setImageDrawable(card.getDrawable());
} else {
Picasso.with(getContext()).load(card.getUrlImage()).into(imageView);

//into(imageView);
}
}

Expand Down

0 comments on commit c101bc0

Please sign in to comment.