Commit c547e625 authored by Geoffrey Métais's avatar Geoffrey Métais

New icons and better image scaling

parent 735097d7
...@@ -73,14 +73,21 @@ public class CardPresenter extends Presenter { ...@@ -73,14 +73,21 @@ public class CardPresenter extends Presenter {
Bitmap picture = null; Bitmap picture = null;
if (MediaWrapper.getType() == MediaWrapper.TYPE_AUDIO) { if (MediaWrapper.getType() == MediaWrapper.TYPE_AUDIO) {
picture = AudioUtil.getCover(sContext, MediaWrapper, 320); picture = AudioUtil.getCover(sContext, MediaWrapper, 320);
if (picture == null) if (picture == null) {
picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_song_big); mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
}else if (MediaWrapper.getType() == MediaWrapper.TYPE_VIDEO) { picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_browser_audio_big_normal);
}
} else if (MediaWrapper.getType() == MediaWrapper.TYPE_VIDEO) {
picture = sMediaDatabase.getPicture(sContext, MediaWrapper.getLocation()); picture = sMediaDatabase.getPicture(sContext, MediaWrapper.getLocation());
if (picture == null) if (picture == null){
picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_video_collection_big); mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
} else if (MediaWrapper.getType() == MediaWrapper.TYPE_DIR) picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_browser_video_big_normal);
picture = BitmapFactory.decodeResource(mRes, R.drawable.background_cone); }
} else if (MediaWrapper.getType() == MediaWrapper.TYPE_DIR) {
mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_menu_network_big);
} else
mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
if (picture != null && picture.getByteCount() > 4) if (picture != null && picture.getByteCount() > 4)
mCardView.setMainImage(new BitmapDrawable(mRes, picture)); mCardView.setMainImage(new BitmapDrawable(mRes, picture));
else else
...@@ -88,6 +95,7 @@ public class CardPresenter extends Presenter { ...@@ -88,6 +95,7 @@ public class CardPresenter extends Presenter {
} }
protected void updateCardViewImage(Drawable image) { protected void updateCardViewImage(Drawable image) {
mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
mCardView.setMainImage(image); mCardView.setMainImage(image);
} }
} }
...@@ -107,7 +115,6 @@ public class CardPresenter extends Presenter { ...@@ -107,7 +115,6 @@ public class CardPresenter extends Presenter {
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
ViewHolder holder = ((ViewHolder) viewHolder); ViewHolder holder = ((ViewHolder) viewHolder);
if (item instanceof MediaWrapper) { if (item instanceof MediaWrapper) {
holder.mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
MediaWrapper MediaWrapper = (MediaWrapper) item; MediaWrapper MediaWrapper = (MediaWrapper) item;
holder.mCardView.setTitleText(MediaWrapper.getTitle()); holder.mCardView.setTitleText(MediaWrapper.getTitle());
holder.mCardView.setContentText(MediaWrapper.getDescription()); holder.mCardView.setContentText(MediaWrapper.getDescription());
...@@ -117,19 +124,16 @@ public class CardPresenter extends Presenter { ...@@ -117,19 +124,16 @@ public class CardPresenter extends Presenter {
else else
holder.updateCardViewImage(MediaWrapper); holder.updateCardViewImage(MediaWrapper);
} else if (item instanceof MusicFragment.ListItem) { } else if (item instanceof MusicFragment.ListItem) {
holder.mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
MusicFragment.ListItem listItem = (MusicFragment.ListItem) item; MusicFragment.ListItem listItem = (MusicFragment.ListItem) item;
MediaWrapper MediaWrapper = listItem.mediaList.get(0); MediaWrapper MediaWrapper = listItem.mediaList.get(0);
holder.mCardView.setTitleText(listItem.mTitle); holder.mCardView.setTitleText(listItem.mTitle);
holder.mCardView.setContentText(listItem.mSubTitle); holder.mCardView.setContentText(listItem.mSubTitle);
holder.updateCardViewImage(MediaWrapper); holder.updateCardViewImage(MediaWrapper);
} else if (item instanceof SimpleCard){ } else if (item instanceof SimpleCard){
holder.mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
SimpleCard card = (SimpleCard) item; SimpleCard card = (SimpleCard) item;
holder.mCardView.setTitleText(card.getName()); holder.mCardView.setTitleText(card.getName());
holder.updateCardViewImage(mRes.getDrawable(card.getImageId())); holder.updateCardViewImage(mRes.getDrawable(card.getImageId()));
}else if (item instanceof String){ }else if (item instanceof String){
holder.mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
holder.mCardView.setTitleText((String) item); holder.mCardView.setTitleText((String) item);
holder.updateCardViewImage(sDefaultCardImage); holder.updateCardViewImage(sDefaultCardImage);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment