use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project SimplifyReader by chentao0707.
the class MusicsFragment method refreshPageInfo.
@Override
public void refreshPageInfo(MusicsListEntity entity, int totalDuration) {
toggleShowLoading(false, null);
mPlayerDiscView.startPlay();
mPlayerCtrlBtn.setImageResource(R.drawable.btn_pause_selector);
if (null != entity) {
mTitle.setText(entity.getTitle());
StringBuilder sb = new StringBuilder();
sb.append("--\t");
sb.append(entity.getArtist());
sb.append("\t--");
mSonger.setText(sb.toString().trim());
}
if (totalDuration > 0) {
mPlayerSeekBar.setMax(totalDuration);
}
String imageUrl = entity.getPicture();
if (!CommonUtils.isEmpty(imageUrl)) {
mPlayerDiscView.loadAlbumCover(imageUrl);
ImageLoader.getInstance().loadImage(imageUrl, 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) {
Bitmap bitmap = ImageBlurManager.doBlurJniArray(loadedImage, BLUR_RADIUS, false);
mBackgroundImage.setImageBitmap(bitmap);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else {
Bitmap bitmap = ImageBlurManager.doBlurJniArray(BitmapFactory.decodeResource(getResources(), R.drawable.player_bg), BLUR_RADIUS, false);
mBackgroundImage.setImageBitmap(bitmap);
}
String totalTime = CommonUtils.convertTime(totalDuration);
if (null != totalTime && !TextUtils.isEmpty(totalTime)) {
mTotalTime.setText(totalTime);
}
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project howabout-android by recomio.
the class TrackListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View trackListItemView;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
trackListItemView = inflater.inflate(R.layout.track_list_item, parent, false);
} else {
trackListItemView = convertView;
}
final ProgressBar progressBar = (ProgressBar) trackListItemView.findViewById(R.id.load);
final ImageView imageView = (ImageView) trackListItemView.findViewById(R.id.image);
final TextView trackTitle = (TextView) trackListItemView.findViewById(R.id.trackTitle);
final TextView artistName = (TextView) trackListItemView.findViewById(R.id.artistName);
final Track track = trackList.get(position);
trackTitle.setText(track.getTrackTitle());
artistName.setText(track.getArtistName());
String imageUrl = track.getThumbnailUrl();
imageLoader.displayImage(imageUrl, imageView, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
progressBar.setVisibility(View.VISIBLE);
imageView.setVisibility(View.INVISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
imageView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
progressBar.setVisibility(View.GONE);
}
});
final Button listenTrackButton = (Button) trackListItemView.findViewById(R.id.listenTrackButton);
final Button addTrackButton = (Button) trackListItemView.findViewById(R.id.addTrackButton);
// when click a 'listen' button.
listenTrackButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HowaboutApplication application = (HowaboutApplication) activity.getApplication();
application.getPlaylistAdapter().play(track);
}
});
// when click an 'add' button.
addTrackButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HowaboutApplication application = (HowaboutApplication) activity.getApplication();
application.getPlaylistAdapter().add(track);
}
});
return trackListItemView;
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project howabout-android by recomio.
the class ImageListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View imageListItemView;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
imageListItemView = inflater.inflate(R.layout.photo_list_item, parent, false);
} else {
imageListItemView = convertView;
}
final ImageView imageView = (ImageView) imageListItemView.findViewById(R.id.image);
final ProgressBar progressBar = (ProgressBar) imageListItemView.findViewById(R.id.load);
String imageUrl = imageList.get(position).getThumbmailUrl();
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) {
imageView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
progressBar.setVisibility(View.GONE);
}
});
// load more random images if needed.
if (position == getCount() - 1 && !isLoading) {
Log.i("ImageListAdapter", "need to load more images.");
isLoading = true;
((MainActivity) activity).getContentManager().execute(randomImagesRequest, new RandomImagesRequestListener());
}
return imageListItemView;
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Android-Universal-Image-Loader by nostra13.
the class ImageLoader method loadImage.
/**
* Adds load image task to execution pool. Image will be returned with
* {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
* <br />
* <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method call
*
* @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
* @param targetImageSize Minimal size for {@link Bitmap} which will be returned in
* {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View,
* android.graphics.Bitmap)} callback}. Downloaded image will be decoded
* and scaled to {@link Bitmap} of the size which is <b>equal or larger</b> (usually a bit
* larger) than incoming targetImageSize.
* @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
* decoding and displaying. If <b>null</b> - default display image options
* {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
* from configuration} will be used.<br />
* @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
* events on UI thread if this method is called on UI thread.
* @param progressListener {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
* Listener} for image loading progress. Listener fires events on UI thread if this method
* is called on UI thread. Caching on disk should be enabled in
* {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions options} to make
* this listener work.
* @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
*/
public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
checkConfiguration();
if (targetImageSize == null) {
targetImageSize = configuration.getMaxImageSize();
}
if (options == null) {
options = configuration.defaultDisplayImageOptions;
}
NonViewAware imageAware = new NonViewAware(uri, targetImageSize, ViewScaleType.CROP);
displayImage(uri, imageAware, options, listener, progressListener);
}
use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Slide by ccrama.
the class AlbumPager method loadImage.
public static void loadImage(final View rootView, Fragment f, String url, boolean single) {
final SubsamplingScaleImageView image = rootView.findViewById(R.id.image);
image.setMinimumDpi(70);
image.setMinimumTileDpi(240);
ImageView fakeImage = new ImageView(f.getActivity());
final TextView size = rootView.findViewById(R.id.size);
fakeImage.setLayoutParams(new LinearLayout.LayoutParams(image.getWidth(), image.getHeight()));
fakeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
((Reddit) f.getActivity().getApplication()).getImageLoader().displayImage(url, new ImageViewAware(fakeImage), new DisplayImageOptions.Builder().resetViewBeforeLoading(true).cacheOnDisk(true).imageScaleType(single ? ImageScaleType.NONE : ImageScaleType.NONE_SAFE).cacheInMemory(false).build(), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
size.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Log.v("Slide", "LOADING FAILED");
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
size.setVisibility(View.GONE);
image.setImage(ImageSource.bitmap(loadedImage));
(rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
Log.v("Slide", "LOADING CANCELLED");
}
}, new ImageLoadingProgressListener() {
@Override
public void onProgressUpdate(String imageUri, View view, int current, int total) {
size.setText(FileUtil.readableFileSize(total));
((ProgressBar) rootView.findViewById(R.id.progress)).setProgress(Math.round(100.0f * current / total));
}
});
}
Aggregations