Search in sources :

Example 11 with ImageLoadingListener

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;
}
Also used : ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) HowaboutApplication(io.recom.howabout.HowaboutApplication) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Bitmap(android.graphics.Bitmap) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ProgressBar(android.widget.ProgressBar) Track(io.recom.howabout.category.music.model.Track)

Example 12 with ImageLoadingListener

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;
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) ProgressBar(android.widget.ProgressBar)

Example 13 with ImageLoadingListener

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

Example 14 with ImageLoadingListener

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) {
        }
    });
}
Also used : Palette(android.support.v7.graphics.Palette) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) Bitmap(android.graphics.Bitmap) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

Bitmap (android.graphics.Bitmap)13 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)13 View (android.view.View)12 ImageView (android.widget.ImageView)12 TextView (android.widget.TextView)8 ImageLoadingListener (com.nostra13.universalimageloader.core.assist.ImageLoadingListener)7 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)6 LayoutInflater (android.view.LayoutInflater)4 Track (io.recom.howabout.category.music.model.Track)4 ProgressBar (android.widget.ProgressBar)3 HowaboutApplication (io.recom.howabout.HowaboutApplication)3 RecyclerView (android.support.v7.widget.RecyclerView)2 OnClickListener (android.view.View.OnClickListener)2 InjectView (butterknife.InjectView)2 ActionBar (com.actionbarsherlock.app.ActionBar)2 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)2 Intent (android.content.Intent)1 DataSetObserver (android.database.DataSetObserver)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Bundle (android.os.Bundle)1