use of com.nostra13.universalimageloader.core.assist.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.assist.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.assist.ImageLoadingListener in project QuickAndroid by ImKarl.
the class DefaultImage method load.
/**
* 加载图片
* @param view 将图片显示到该控件
* @param url
*/
@Override
public void load(final View view, String url) {
url = checkImageUri(url);
if (view instanceof ImageView) {
load((ImageView) view, url);
return;
}
getImageLoader().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View viewNull) {
showLoading(view);
}
@Override
public void onLoadingFailed(String imageUri, View viewNull, FailReason failReason) {
showLoadfail(view);
}
@SuppressWarnings("deprecation")
@Override
public void onLoadingComplete(String imageUri, View viewNull, Bitmap loadedImage) {
if (loadedImage == null) {
onLoadingFailed(imageUri, viewNull, new FailReason(FailType.UNKNOWN, new NullPointerException("'bitmap' is NULL.")));
return;
}
view.setBackgroundDrawable(new BitmapDrawable(view.getResources(), loadedImage));
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
showLoadfail(view);
}
});
}
use of com.nostra13.universalimageloader.core.assist.ImageLoadingListener in project Timber by naman14.
the class AlbumDetailFragment method setAlbumart.
private void setAlbumart() {
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(albumID).toString(), albumArt, 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) {
loadFailed = true;
MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(context).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
fab.setImageDrawable(builder.build());
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
try {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
primaryColor = swatch.getRgb();
collapsingToolbarLayout.setContentScrimColor(primaryColor);
if (getActivity() != null)
ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
} else {
Palette.Swatch swatchMuted = palette.getMutedSwatch();
if (swatchMuted != null) {
primaryColor = swatchMuted.getRgb();
collapsingToolbarLayout.setContentScrimColor(primaryColor);
if (getActivity() != null)
ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
}
}
MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setSizeDp(30);
if (primaryColor != -1) {
builder.setColor(TimberUtils.getBlackWhiteColor(primaryColor));
ATEUtils.setFabBackgroundTint(fab, primaryColor);
fab.setImageDrawable(builder.build());
} else {
if (context != null) {
ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
builder.setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
fab.setImageDrawable(builder.build());
}
}
}
});
} catch (Exception ignored) {
}
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
Aggregations