use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project LibreraReader by foobnix.
the class SearchAdapter method getView.
@Override
public View getView(final int i, View convertView, ViewGroup viewGroup) {
View browserItem = convertView;
if (browserItem != null && ((Holder) browserItem.getTag()).libMode != AppState.get().libraryMode) {
browserItem = null;
}
if (browserItem == null) {
if (AppState.get().libraryMode == AppState.MODE_GRID || AppState.get().libraryMode == AppState.MODE_COVERS) {
browserItem = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.browse_item_grid, viewGroup, false);
} else {
browserItem = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.browse_item_list, viewGroup, false);
}
Holder holder = new Holder();
holder.imageView = (ImageView) browserItem.findViewById(R.id.browserItemIcon);
holder.starIcon = (ImageView) browserItem.findViewById(R.id.starIcon);
holder.title1 = (TextView) browserItem.findViewById(R.id.title1);
holder.title2 = (TextView) browserItem.findViewById(R.id.title2);
holder.textPath = (TextView) browserItem.findViewById(R.id.browserPath);
holder.textSize = (TextView) browserItem.findViewById(R.id.browserSize);
holder.textDate = (TextView) browserItem.findViewById(R.id.browseDate);
holder.textExt = (TextView) browserItem.findViewById(R.id.browserExt);
holder.layoutBootom = browserItem.findViewById(R.id.layoutBootom);
holder.libMode = AppState.get().libraryMode;
View progresLayout = browserItem.findViewById(R.id.progresLayout);
if (progresLayout != null) {
progresLayout.setVisibility(View.GONE);
}
View delete = browserItem.findViewById(R.id.delete);
if (delete != null) {
delete.setVisibility(View.GONE);
}
browserItem.setTag(holder);
}
final Holder holder = (Holder) browserItem.getTag();
final FileMeta fileMeta = getItem(i);
ImageView menuIcon = (ImageView) browserItem.findViewById(R.id.itemMenu);
menuIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onMenuPressed != null) {
onMenuPressed.onResultRecive(new File(fileMeta.getPath()));
}
}
});
if (AppState.get().isCropBookCovers) {
holder.imageView.setScaleType(ScaleType.CENTER_CROP);
} else {
holder.imageView.setScaleType(ScaleType.FIT_CENTER);
}
holder.title1.setText(fileMeta.getTitle());
holder.title2.setText(fileMeta.getAuthor());
holder.textPath.setText(fileMeta.getPath());
holder.textSize.setText("" + fileMeta.getSize());
holder.textDate.setText("" + fileMeta.getDate());
holder.textExt.setText(fileMeta.getExt());
if (AppState.get().libraryMode == AppState.MODE_GRID || AppState.get().libraryMode == AppState.MODE_COVERS) {
holder.textPath.setVisibility(View.GONE);
holder.textSize.setVisibility(View.GONE);
IMG.updateImageSizeBig(holder.imageView);
IMG.updateImageSizeBig((View) holder.imageView.getParent());
if (AppState.get().libraryMode == AppState.MODE_COVERS) {
holder.layoutBootom.setVisibility(View.GONE);
}
} else {
holder.textPath.setVisibility(View.VISIBLE);
IMG.updateImageSizeSmall(holder.imageView);
IMG.updateImageSizeSmall((View) holder.imageView.getParent());
}
if (AppState.get().libraryMode == AppState.MODE_LIST && AppState.get().coverSmallSize >= IMG.TWO_LINE_COVER_SIZE) {
holder.title1.setSingleLine(false);
holder.title1.setLines(2);
} else {
holder.title1.setSingleLine(true);
holder.title1.setLines(1);
}
if (AppState.get().libraryMode == AppState.MODE_GRID && AppState.get().coverBigSize <= IMG.TWO_LINE_COVER_SIZE) {
holder.textDate.setVisibility(View.GONE);
} else {
holder.textDate.setVisibility(View.VISIBLE);
}
TintUtil.setTintImageWithAlpha(menuIcon);
// int size = AppState.get().libraryMode == AppState.MODE_LIST ?
// AppState.get().coverSmallSize : AppState.get().coverBigSize;
// StarsWrapper.addStars(holder.starIcon, info);
IMG.getCoverPageWithEffect(holder.imageView, fileMeta.getPath(), IMG.getImageSize(), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String arg0, View arg1) {
// TODO Auto-generated method stub
}
@Override
public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
// TODO Auto-generated method stub
}
@Override
public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
FileMeta fileMeta = getItem(i);
holder.title1.setText(fileMeta.getTitle());
holder.title2.setText(fileMeta.getAuthor());
holder.textPath.setText(fileMeta.getPath());
holder.textSize.setText("" + fileMeta.getSize());
holder.textDate.setText("" + fileMeta.getDate());
holder.textExt.setText(fileMeta.getExt());
if (TxtUtils.isEmpty(fileMeta.getAuthor()) && AppState.get().libraryMode == AppState.MODE_LIST) {
holder.title2.setVisibility(View.GONE);
} else {
holder.title2.setVisibility(View.VISIBLE);
}
}
@Override
public void onLoadingCancelled(String arg0, View arg1) {
// TODO Auto-generated method stub
}
});
return browserItem;
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Timber by naman14.
the class ImageUtils method loadAlbumArtFromLastfm.
private static void loadAlbumArtFromLastfm(long albumId, final ImageView albumArt, final ImageLoadingListener listener) {
Album album = AlbumLoader.getAlbum(albumArt.getContext(), albumId);
LastFmClient.getInstance(albumArt.getContext()).getAlbumInfo(new AlbumQuery(album.title, album.artistName), new AlbumInfoListener() {
@Override
public void albumInfoSuccess(final LastfmAlbum album) {
if (album != null) {
ImageLoader.getInstance().displayImage(album.mArtwork.get(4).mUrl, albumArt, lastfmDisplayImageOptions, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
listener.onLoadingComplete(imageUri, view, loadedImage);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
listener.onLoadingFailed(imageUri, view, failReason);
}
});
}
}
@Override
public void albumInfoFailed() {
}
});
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Timber by naman14.
the class QuickControlsFragment method updateNowplayingCard.
public void updateNowplayingCard() {
mTitle.setText(MusicPlayer.getTrackName());
mArtist.setText(MusicPlayer.getArtistName());
mTitleExpanded.setText(MusicPlayer.getTrackName());
mArtistExpanded.setText(MusicPlayer.getArtistName());
if (!duetoplaypause) {
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(MusicPlayer.getCurrentAlbumId()).toString(), mAlbumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build(), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Bitmap failedBitmap = ImageLoader.getInstance().loadImageSync("drawable://" + R.drawable.ic_empty_music2);
if (getActivity() != null)
new setBlurredAlbumArt().execute(failedBitmap);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (getActivity() != null)
new setBlurredAlbumArt().execute(loadedImage);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
duetoplaypause = false;
mProgress.setMax((int) MusicPlayer.duration());
mSeekBar.setMax((int) MusicPlayer.duration());
mProgress.postDelayed(mUpdateProgress, 10);
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project howabout-android by recomio.
the class ShowImageListAdapter method getView.
@Override
public View getView(int position, View convertView, final ViewGroup parent) {
final View showImageListItemView;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
showImageListItemView = inflater.inflate(R.layout.show_image_item, parent, false);
} else {
showImageListItemView = convertView;
}
final ImageView imageView = (ImageView) showImageListItemView.findViewById(R.id.image);
final ProgressBar progressBar = (ProgressBar) showImageListItemView.findViewById(R.id.load);
String imageUrl = imageList.get(position).getBasicUrl();
imageLoader.displayImage(imageUrl, imageView, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
progressBar.setVisibility(View.VISIBLE);
imageView.setVisibility(View.GONE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
// 스크린 width에 꽉 차게 view 리사이징.
float ratio = (float) parent.getWidth() / (float) loadedImage.getWidth();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(parent.getWidth(), (int) ((float) loadedImage.getHeight() * ratio));
imageView.setLayoutParams(lp);
// margin.
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(1, 1, 1, 1);
imageView.setLayoutParams(lp);
imageView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
progressBar.setVisibility(View.GONE);
}
});
return showImageListItemView;
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project howabout-android by recomio.
the class MusicPlaylistActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
imageLoader = ImageLoader.getInstance();
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
setAdsContainer(R.id.adView);
HowaboutApplication application = (HowaboutApplication) getApplication();
playlistAdapter = application.getPlaylistAdapter();
if (MusicPlayerService.isLoading()) {
loadingProgressBar.setVisibility(View.VISIBLE);
playPauseToggleButton.setVisibility(View.GONE);
} else {
if (MusicPlayerService.isPlaying()) {
playPauseToggleButton.setImageDrawable(pauseIcon);
} else {
playPauseToggleButton.setImageDrawable(playIcon);
}
loadingProgressBar.setVisibility(View.GONE);
playPauseToggleButton.setVisibility(View.VISIBLE);
}
listView.setAdapter(playlistAdapter);
playlistAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
try {
Track track = playlistAdapter.getCurrentItem();
actionBar.setTitle(track.getTrackTitle());
actionBar.setSubtitle(track.getArtistName());
if (MusicPlayerService.isLoading()) {
loadingProgressBar.setVisibility(View.VISIBLE);
playPauseToggleButton.setVisibility(View.GONE);
} else {
if (MusicPlayerService.isPlaying()) {
playPauseToggleButton.setImageDrawable(pauseIcon);
} else {
playPauseToggleButton.setImageDrawable(playIcon);
}
loadingProgressBar.setVisibility(View.GONE);
playPauseToggleButton.setVisibility(View.VISIBLE);
}
imageLoader.displayImage(track.getThumbnailUrl(), songImageView, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
String lyrics = playlistAdapter.getCurrentLyrics();
if (lyrics == null) {
lyricsScrollView.setVisibility(View.GONE);
lyricsTextView.setText("");
} else {
lyricsScrollView.setVisibility(View.VISIBLE);
lyricsTextView.setText(lyrics);
}
listView.invalidate();
} catch (Exception e) {
}
}
@Override
public void onInvalidated() {
}
});
playlistAdapter.notifyDataSetChanged();
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
playlistAdapter.play(position);
playlistAdapter.notifyDataSetChanged();
}
});
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
playlistAdapter.remove(position);
return true;
}
});
playPauseToggleButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
playlistAdapter.playPauseToggle();
if (MusicPlayerService.isPlaying()) {
playPauseToggleButton.setImageDrawable(pauseIcon);
} else {
playPauseToggleButton.setImageDrawable(playIcon);
}
}
});
prevButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
playlistAdapter.playPrev();
}
});
nextButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
playlistAdapter.playNext();
}
});
UpdateCurrentPositionTask updateCurrentPositionTask = new UpdateCurrentPositionTask();
updateCurrentPositionTimer.scheduleAtFixedRate(updateCurrentPositionTask, 0, 1000);
}
Aggregations