use of com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener in project Timber by naman14.
the class PlaylistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
final Playlist localItem = arraylist.get(i);
itemHolder.title.setText(localItem.name);
String s = getAlbumArtUri(i, localItem.id);
itemHolder.albumArt.setTag(firstAlbumID);
ImageLoader.getInstance().displayImage(s, itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (isGrid) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
int color = swatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(swatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.setTextColor(textColor);
} else {
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
if (mutedSwatch != null) {
int color = mutedSwatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(mutedSwatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.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.title.setTextColor(textColorPrimary);
itemHolder.artist.setTextColor(textColorPrimary);
}
}
}
});
itemHolder.artist.setText(" " + String.valueOf(songCountInt) + " " + mContext.getString(R.string.songs) + " - " + TimberUtils.makeShortTimeString(mContext, totalRuntime));
if (TimberUtils.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
use of com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener 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.SimpleImageLoadingListener in project 9GAG by stormzhang.
the class ImageViewActivity method onCreate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_imageview);
ButterKnife.inject(this);
setTitle(R.string.view_big_image);
mAttacher = new PhotoViewAttacher(photoView);
mAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
finish();
}
});
String imageUrl = getIntent().getStringExtra(IMAGE_URL);
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisc(true).considerExifParams(true).build();
ImageLoader.getInstance().displayImage(imageUrl, photoView, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
progressWheel.setVisibility(View.GONE);
mAttacher.update();
}
}, new ImageLoadingProgressListener() {
@Override
public void onProgressUpdate(String imageUri, View view, int current, int total) {
progressWheel.setProgress(360 * current / total);
}
});
}
use of com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener in project CustomViews by AndroidStudy233.
the class ViewPagerFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewPager = (OverScrollViewPager) view.findViewById(R.id.viewpager_piclooker);
tips = (TextView) view.findViewById(R.id.tv_piclooker_index);
mask = view.findViewById(R.id.view_piclooker_back);
runEnterAnimation();
Bundle bundle = getArguments();
imgs = bundle.getStringArrayList("imgs");
imageInfo = bundle.getParcelable("info");
imageInfos = bundle.getParcelableArrayList("infos");
position = bundle.getInt("position", 0);
tips.setText((position + 1) + "/" + imgs.size());
viewPager.setpagerCount(imgs.size());
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return imgs.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int pos) {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.layout_view_detail, null, false);
final PhotoView myPhotoView = (PhotoView) view.findViewById(R.id.iv_piclooker_detail);
final MaterialProgressBar progressBar = (MaterialProgressBar) view.findViewById(R.id.pb_piclooker);
if (position == pos && ImageLoader.getInstance().getDiscCache().get(imgs.get(pos)) != null) {
// only animate when position equals u click in pre layout
myPhotoView.animaFrom(imageInfo);
}
// load pic from remote
ImageLoader.getInstance().displayImage(imgs.get(pos), myPhotoView, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
progressBar.setVisibility(View.GONE);
}
});
// force to get focal point,to listen key listener
myPhotoView.setFocusableInTouchMode(true);
myPhotoView.requestFocus();
// add key listener to listen back press
myPhotoView.setOnKeyListener(pressKeyListener);
myPhotoView.setOnClickListener(onClickListener);
myPhotoView.setTag(pos);
myPhotoView.enable();
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
});
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
tips.setText((position + 1) + "/" + imgs.size());
viewPager.updateCurrentIndex(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
// set current position
// viewPager.getOverscrollView().setCurrentItem(position);
viewPager.setCurrentItem(position);
}
use of com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener in project Slide by ccrama.
the class Image method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.submission_imagecard, container, false);
final SubsamplingScaleImageView image = rootView.findViewById(R.id.image);
TextView title = rootView.findViewById(R.id.title);
TextView desc = rootView.findViewById(R.id.desc);
title.setVisibility(View.GONE);
desc.setVisibility(View.GONE);
((Reddit) getContext().getApplicationContext()).getImageLoader().loadImage(url, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
image.setImage(ImageSource.bitmap(loadedImage));
}
});
return rootView;
}
Aggregations