Search in sources :

Example 11 with SimpleImageLoadingListener

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);
}
Also used : Palette(androidx.palette.graphics.Palette) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Playlist(com.naman14.timber.models.Playlist) Bitmap(android.graphics.Bitmap) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 12 with SimpleImageLoadingListener

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() {
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) AlbumInfoListener(com.naman14.timber.lastfmapi.callbacks.AlbumInfoListener) Bitmap(android.graphics.Bitmap) LastfmAlbum(com.naman14.timber.lastfmapi.models.LastfmAlbum) AlbumQuery(com.naman14.timber.lastfmapi.models.AlbumQuery) Album(com.naman14.timber.models.Album) LastfmAlbum(com.naman14.timber.lastfmapi.models.LastfmAlbum) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View)

Example 13 with SimpleImageLoadingListener

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);
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ImageLoadingProgressListener(com.nostra13.universalimageloader.core.assist.ImageLoadingProgressListener) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) InjectView(butterknife.InjectView) PhotoView(uk.co.senab.photoview.PhotoView) View(android.view.View) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 14 with SimpleImageLoadingListener

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);
}
Also used : Bundle(android.os.Bundle) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager) OverScrollViewPager(com.shiqkuangsan.mycustomviews.ui.custom.OverScrollViewPager) PagerAdapter(android.support.v4.view.PagerAdapter) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) MaterialProgressBar(com.shiqkuangsan.mycustomviews.ui.custom.MaterialProgressBar) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 15 with SimpleImageLoadingListener

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;
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ViewGroup(android.view.ViewGroup) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) TextView(android.widget.TextView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)23 Bitmap (android.graphics.Bitmap)22 SimpleImageLoadingListener (com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener)22 TextView (android.widget.TextView)15 ImageView (android.widget.ImageView)14 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)11 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)8 RecyclerView (android.support.v7.widget.RecyclerView)4 Palette (androidx.palette.graphics.Palette)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Handler (android.os.Handler)3 ViewGroup (android.view.ViewGroup)3 CircularProgressView (com.github.rahatarmanahmed.cpv.CircularProgressView)3 ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)3 PagerAdapter (android.support.v4.view.PagerAdapter)2 OnClickListener (android.view.View.OnClickListener)2 ArtistInfoListener (com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener)2 Album (com.naman14.timber.models.Album)2 List (java.util.List)2 Context (android.content.Context)1