use of org.gateshipone.malp.application.listviewitems.GenericGridItem in project malp by gateship-one.
the class AlbumsAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MPDAlbum album = (MPDAlbum) getItem(position);
String label = album.getName();
if (label.isEmpty()) {
label = mContext.getResources().getString(R.string.no_album_tag);
}
String albumArtist = album.getArtistName();
if (mUseList) {
// Check if a view can be recycled
ImageListItem listItem;
if (convertView != null) {
listItem = (ImageListItem) convertView;
// Make sure to reset the layoutParams in case of change (rotation for example)
listItem.setText(label);
listItem.setDetails(albumArtist);
} else {
// Create new view if no reusable is available
listItem = new ImageListItem(mContext, label, albumArtist, this);
}
// This will prepare the view for fetching the image from the internet if not already saved in local database.
listItem.prepareArtworkFetching(mArtworkManager, album);
// Check if the scroll speed currently is already 0, then start the image task right away.
if (mScrollSpeed == 0) {
listItem.setImageDimension(mListItemHeight, mListItemHeight);
listItem.startCoverImageTask();
}
return listItem;
} else {
GenericGridItem gridItem;
ViewGroup.LayoutParams layoutParams;
int width = ((GridView) mListView).getColumnWidth();
// Check if a view can be recycled
if (convertView == null) {
// Create new view if no reusable is available
gridItem = new GenericGridItem(mContext, label, this);
layoutParams = new android.widget.AbsListView.LayoutParams(width, width);
} else {
gridItem = (GenericGridItem) convertView;
gridItem.setTitle(label);
layoutParams = gridItem.getLayoutParams();
layoutParams.height = width;
layoutParams.width = width;
}
// Make sure to reset the layoutParams in case of change (rotation for example)
gridItem.setLayoutParams(layoutParams);
// This will prepare the view for fetching the image from the internet if not already saved in local database.
gridItem.prepareArtworkFetching(mArtworkManager, album);
// Check if the scroll speed currently is already 0, then start the image task right away.
if (mScrollSpeed == 0) {
gridItem.setImageDimension(width, width);
gridItem.startCoverImageTask();
}
return gridItem;
}
}
use of org.gateshipone.malp.application.listviewitems.GenericGridItem in project malp by gateship-one.
the class ArtistsAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MPDArtist artist = (MPDArtist) getItem(position);
String label = artist.getArtistName();
if (label.isEmpty()) {
label = mContext.getResources().getString(R.string.no_artist_tag);
}
if (mUseList) {
// Check if a view can be recycled
ImageListItem listItem;
if (convertView != null) {
listItem = (ImageListItem) convertView;
// Make sure to reset the layoutParams in case of change (rotation for example)
listItem.setText(label);
} else {
// Create new view if no reusable is available
listItem = new ImageListItem(mContext, label, null, this);
}
// This will prepare the view for fetching the image from the internet if not already saved in local database.
listItem.prepareArtworkFetching(mArtworkManager, artist);
// Check if the scroll speed currently is already 0, then start the image task right away.
if (mScrollSpeed == 0) {
listItem.setImageDimension(mListItemHeight, mListItemHeight);
listItem.startCoverImageTask();
}
return listItem;
} else {
GenericGridItem gridItem;
ViewGroup.LayoutParams layoutParams;
int width = ((GridView) mListView).getColumnWidth();
// Check if a view can be recycled
if (convertView == null) {
// Create new view if no reusable is available
gridItem = new GenericGridItem(mContext, label, this);
layoutParams = new android.widget.AbsListView.LayoutParams(width, width);
} else {
gridItem = (GenericGridItem) convertView;
gridItem.setTitle(label);
layoutParams = gridItem.getLayoutParams();
layoutParams.height = width;
layoutParams.width = width;
}
// Make sure to reset the layoutParams in case of change (rotation for example)
gridItem.setLayoutParams(layoutParams);
// This will prepare the view for fetching the image from the internet if not already saved in local database.
gridItem.prepareArtworkFetching(mArtworkManager, artist);
// Check if the scroll speed currently is already 0, then start the image task right away.
if (mScrollSpeed == 0) {
gridItem.setImageDimension(width, width);
gridItem.startCoverImageTask();
}
return gridItem;
}
}
Aggregations