Search in sources :

Example 26 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project SimplifyReader by chentao0707.

the class MusicsFragment method refreshPageInfo.

@Override
public void refreshPageInfo(MusicsListEntity entity, int totalDuration) {
    toggleShowLoading(false, null);
    mPlayerDiscView.startPlay();
    mPlayerCtrlBtn.setImageResource(R.drawable.btn_pause_selector);
    if (null != entity) {
        mTitle.setText(entity.getTitle());
        StringBuilder sb = new StringBuilder();
        sb.append("--\t");
        sb.append(entity.getArtist());
        sb.append("\t--");
        mSonger.setText(sb.toString().trim());
    }
    if (totalDuration > 0) {
        mPlayerSeekBar.setMax(totalDuration);
    }
    String imageUrl = entity.getPicture();
    if (!CommonUtils.isEmpty(imageUrl)) {
        mPlayerDiscView.loadAlbumCover(imageUrl);
        ImageLoader.getInstance().loadImage(imageUrl, new ImageLoadingListener() {

            @Override
            public void onLoadingStarted(String imageUri, View view) {
            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                Bitmap bitmap = ImageBlurManager.doBlurJniArray(loadedImage, BLUR_RADIUS, false);
                mBackgroundImage.setImageBitmap(bitmap);
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {
            }
        });
    } else {
        Bitmap bitmap = ImageBlurManager.doBlurJniArray(BitmapFactory.decodeResource(getResources(), R.drawable.player_bg), BLUR_RADIUS, false);
        mBackgroundImage.setImageBitmap(bitmap);
    }
    String totalTime = CommonUtils.convertTime(totalDuration);
    if (null != totalTime && !TextUtils.isEmpty(totalTime)) {
        mTotalTime.setText(totalTime);
    }
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) PlayerDiscView(com.github.obsessive.simplifyreader.widgets.PlayerDiscView) InjectView(butterknife.InjectView) View(android.view.View) TextView(android.widget.TextView) MusicsView(com.github.obsessive.simplifyreader.view.MusicsView)

Example 27 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.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 28 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.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 29 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Android-Universal-Image-Loader by nostra13.

the class ImageLoader method loadImage.

/**
 * Adds load image task to execution pool. Image will be returned with
 * {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
 * <br />
 * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method call
 *
 * @param uri              Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
 * @param targetImageSize  Minimal size for {@link Bitmap} which will be returned in
 *                         {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View,
 *                         android.graphics.Bitmap)} callback}. Downloaded image will be decoded
 *                         and scaled to {@link Bitmap} of the size which is <b>equal or larger</b> (usually a bit
 *                         larger) than incoming targetImageSize.
 * @param options          {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
 *                         decoding and displaying. If <b>null</b> - default display image options
 *                         {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
 *                         from configuration} will be used.<br />
 * @param listener         {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
 *                         events on UI thread if this method is called on UI thread.
 * @param progressListener {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
 *                         Listener} for image loading progress. Listener fires events on UI thread if this method
 *                         is called on UI thread. Caching on disk should be enabled in
 *                         {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions options} to make
 *                         this listener work.
 * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
 */
public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
    checkConfiguration();
    if (targetImageSize == null) {
        targetImageSize = configuration.getMaxImageSize();
    }
    if (options == null) {
        options = configuration.defaultDisplayImageOptions;
    }
    NonViewAware imageAware = new NonViewAware(uri, targetImageSize, ViewScaleType.CROP);
    displayImage(uri, imageAware, options, listener, progressListener);
}
Also used : NonViewAware(com.nostra13.universalimageloader.core.imageaware.NonViewAware)

Example 30 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Slide by ccrama.

the class AlbumPager method loadImage.

public static void loadImage(final View rootView, Fragment f, String url, boolean single) {
    final SubsamplingScaleImageView image = rootView.findViewById(R.id.image);
    image.setMinimumDpi(70);
    image.setMinimumTileDpi(240);
    ImageView fakeImage = new ImageView(f.getActivity());
    final TextView size = rootView.findViewById(R.id.size);
    fakeImage.setLayoutParams(new LinearLayout.LayoutParams(image.getWidth(), image.getHeight()));
    fakeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
    ((Reddit) f.getActivity().getApplication()).getImageLoader().displayImage(url, new ImageViewAware(fakeImage), new DisplayImageOptions.Builder().resetViewBeforeLoading(true).cacheOnDisk(true).imageScaleType(single ? ImageScaleType.NONE : ImageScaleType.NONE_SAFE).cacheInMemory(false).build(), new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
            size.setVisibility(View.VISIBLE);
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            Log.v("Slide", "LOADING FAILED");
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            size.setVisibility(View.GONE);
            image.setImage(ImageSource.bitmap(loadedImage));
            (rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
            Log.v("Slide", "LOADING CANCELLED");
        }
    }, new ImageLoadingProgressListener() {

        @Override
        public void onProgressUpdate(String imageUri, View view, int current, int total) {
            size.setText(FileUtil.readableFileSize(total));
            ((ProgressBar) rootView.findViewById(R.id.progress)).setProgress(Math.round(100.0f * current / total));
        }
    });
}
Also used : ImageViewAware(com.nostra13.universalimageloader.core.imageaware.ImageViewAware) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ImageLoadingProgressListener(com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) GridView(android.widget.GridView) ImageView(android.widget.ImageView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) ExoVideoView(me.ccrama.redditslide.Views.ExoVideoView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) Bitmap(android.graphics.Bitmap) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

FailReason (com.nostra13.universalimageloader.core.assist.FailReason)30 Bitmap (android.graphics.Bitmap)29 View (android.view.View)29 ImageView (android.widget.ImageView)23 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)22 TextView (android.widget.TextView)14 ProgressBar (android.widget.ProgressBar)8 File (java.io.File)8 Reddit (me.ccrama.redditslide.Reddit)8 LinearLayout (android.widget.LinearLayout)7 ImageLoadingListener (com.nostra13.universalimageloader.core.assist.ImageLoadingListener)7 ImageViewAware (com.nostra13.universalimageloader.core.imageaware.ImageViewAware)7 ImageLoadingProgressListener (com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener)7 Handler (android.os.Handler)5 OnClickListener (android.view.View.OnClickListener)5 IOException (java.io.IOException)5 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)5 ExoVideoView (me.ccrama.redditslide.Views.ExoVideoView)5 SubsamplingScaleImageView (me.ccrama.redditslide.Views.SubsamplingScaleImageView)5 LayoutInflater (android.view.LayoutInflater)4