use of com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener in project AndroidStudy by tinggengyan.
the class UILGroupDisplayActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_textview);
this.textViewMain = (TextView) findViewById(R.id.textViewMain);
this.linearLayoutRoot = findViewById(R.id.linearLayoutRoot);
options = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.ic_stub).showImageForEmptyUri(R.drawable.ic_empty).showImageOnFail(R.drawable.ic_error).cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();
ImageLoader.getInstance().loadImage("http://b.hiphotos.baidu.com/image/pic/item/32fa828ba61ea8d34c95be1b950a304e251f587e.jpg", options, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
BitmapDrawable background = new BitmapDrawable(loadedImage);
linearLayoutRoot.setBackgroundDrawable(background);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
super.onLoadingFailed(imageUri, view, failReason);
textViewMain.setText(failReason.toString());
}
@Override
public void onLoadingStarted(String imageUri, View view) {
super.onLoadingStarted(imageUri, view);
textViewMain.setText("start");
}
});
}
use of com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener in project android by testpress.
the class ProfilePhotoActivity method onCreate.
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.profile_image_view_layout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
progressBar = (ProgressBar) findViewById(R.id.pb_loading);
progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.primary), PorterDuff.Mode.SRC_IN);
final TextView emptyView = (TextView) findViewById(R.id.empty);
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).resetViewBeforeLoading(true).build();
ImageLoader.getInstance().loadImage(getIntent().getStringExtra("profilePhoto"), options, new SimpleImageLoadingListener() {
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
progressBar.setVisibility(View.GONE);
if (failReason.getType().equals(FailReason.FailType.IO_ERROR)) {
emptyView.setVisibility(View.VISIBLE);
emptyView.setText(R.string.no_internet);
} else {
emptyView.setVisibility(View.VISIBLE);
emptyView.setText(failReason.getCause().getMessage());
}
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
progressBar.setVisibility(View.GONE);
((TouchImageView) findViewById(R.id.image)).setImageBitmap(loadedImage);
}
});
}
use of com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener in project Timber by naman14.
the class ArtistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
final Artist localItem = arraylist.get(i);
itemHolder.name.setText(localItem.name);
String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, localItem.albumCount);
String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
itemHolder.albums.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(localItem.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
if (artist != null && artist.mArtwork != null) {
if (isGrid) {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(2).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnLoading(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (isGrid && loadedImage != null) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
int color = palette.getVibrantColor(Color.parseColor("#66000000"));
itemHolder.footer.setBackgroundColor(color);
Palette.Swatch swatch = palette.getVibrantSwatch();
int textColor;
if (swatch != null) {
textColor = getOpaqueColor(swatch.getTitleTextColor());
} else
textColor = Color.parseColor("#ffffff");
itemHolder.name.setTextColor(textColor);
itemHolder.albums.setTextColor(textColor);
}
});
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (isGrid) {
itemHolder.footer.setBackgroundColor(0);
if (mContext != null) {
int textColorPrimary = Config.textColorPrimary(mContext, Helpers.getATEKey(mContext));
itemHolder.name.setTextColor(textColorPrimary);
itemHolder.albums.setTextColor(textColorPrimary);
}
}
}
});
} else {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnLoading(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
}
}
}
@Override
public void artistInfoFailed() {
}
});
if (TimberUtils.isLollipop())
itemHolder.artistImage.setTransitionName("transition_artist_art" + i);
}
Aggregations