Search in sources :

Example 21 with SimpleImageLoadingListener

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");
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) TextView(android.widget.TextView) View(android.view.View) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 22 with SimpleImageLoadingListener

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);
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) TextView(android.widget.TextView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) TextView(android.widget.TextView) View(android.view.View) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 23 with SimpleImageLoadingListener

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);
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) 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) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)

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