Search in sources :

Example 1 with FailReason

use of com.nostra13.universalimageloader.core.assist.FailReason in project SimplifyReader by chentao0707.

the class CaptureActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK) {
        return;
    }
    if (requestCode == IMAGE_PICKER_REQUEST_CODE) {
        String imagePath = data.getStringExtra(CommonImagePickerDetailActivity.KEY_BUNDLE_RESULT_IMAGE_PATH);
        if (!CommonUtils.isEmpty(imagePath)) {
            ImageLoader.getInstance().loadImage("file://" + imagePath, 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) {
                    String resultZxing = new DecodeUtils(DecodeUtils.DECODE_DATA_MODE_ALL).decodeWithZxing(loadedImage);
                    String resultZbar = new DecodeUtils(DecodeUtils.DECODE_DATA_MODE_ALL).decodeWithZbar(loadedImage);
                    if (!CommonUtils.isEmpty(resultZbar)) {
                        Bundle extras = new Bundle();
                        extras.putInt(DecodeThread.DECODE_MODE, DecodeUtils.DECODE_MODE_ZBAR);
                        handleDecode(resultZbar, extras);
                    } else if (!CommonUtils.isEmpty(resultZxing)) {
                        Bundle extras = new Bundle();
                        extras.putInt(DecodeThread.DECODE_MODE, DecodeUtils.DECODE_MODE_ZXING);
                        handleDecode(resultZxing, extras);
                    } else {
                        showToast(getResources().getString(R.string.tips_decode_null));
                    }
                }

                @Override
                public void onLoadingCancelled(String imageUri, View view) {
                }
            });
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) Bundle(android.os.Bundle) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) DecodeUtils(com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View)

Example 2 with FailReason

use of com.nostra13.universalimageloader.core.assist.FailReason in project NewPipe by TeamNewPipe.

the class VideoItemDetailFragment method initThumbnailViews.

private void initThumbnailViews(final StreamInfo info) {
    ImageView videoThumbnailView = (ImageView) activity.findViewById(R.id.detail_thumbnail_view);
    ImageView uploaderThumb = (ImageView) activity.findViewById(R.id.detail_uploader_thumbnail_view);
    if (info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
        imageLoader.displayImage(info.thumbnail_url, videoThumbnailView, displayImageOptions, new ImageLoadingListener() {

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

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                ErrorActivity.reportError(getActivity(), failReason.getCause(), null, rootView, ErrorActivity.ErrorInfo.make(ErrorActivity.LOAD_IMAGE, NewPipe.getNameOfService(info.service_id), imageUri, R.string.could_not_load_thumbnails));
            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                streamThumbnail = loadedImage;
                if (streamThumbnail != null) {
                    // TODO: Change the thumbnail implementation
                    // When the thumbnail is not loaded yet, it not passes to the service in time
                    // so, I can notify the service through a broadcast, but the problem is
                    // when I click in another video, another thumbnail will be load, and will
                    // notify again, so I send the videoUrl and compare with the service's url
                    ActivityCommunicator.getCommunicator().backgroundPlayerThumbnail = streamThumbnail;
                    Intent intent = new Intent(PopupVideoPlayer.InternalListener.ACTION_UPDATE_THUMB);
                    intent.putExtra(PopupVideoPlayer.VIDEO_URL, info.webpage_url);
                    getContext().sendBroadcast(intent);
                }
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {
            }
        });
    } else {
        videoThumbnailView.setImageResource(R.drawable.dummy_thumbnail_dark);
    }
    if (info.uploader_thumbnail_url != null && !info.uploader_thumbnail_url.isEmpty()) {
        imageLoader.displayImage(info.uploader_thumbnail_url, uploaderThumb, displayImageOptions, new ImageErrorLoadingListener(activity, rootView, info.service_id));
    }
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ImageErrorLoadingListener(org.schabi.newpipe.ImageErrorLoadingListener) Intent(android.content.Intent) ImageView(android.widget.ImageView) 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)

Example 3 with FailReason

use of com.nostra13.universalimageloader.core.assist.FailReason in project Timber by naman14.

the class BaseNowplayingFragment method updateSongDetails.

public void updateSongDetails() {
    //do not reload image if it was a play/pause change
    if (!duetoplaypause) {
        if (albumart != null) {
            ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(MusicPlayer.getCurrentAlbumId()).toString(), albumart, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).build(), new SimpleImageLoadingListener() {

                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    doAlbumArtStuff(loadedImage);
                }

                @Override
                public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                    Bitmap failedBitmap = ImageLoader.getInstance().loadImageSync("drawable://" + R.drawable.ic_empty_music2);
                    doAlbumArtStuff(failedBitmap);
                }
            });
        }
    }
    duetoplaypause = false;
    if (mPlayPause != null)
        updatePlayPauseButton();
    if (playPauseFloating != null)
        updatePlayPauseFloatingButton();
    if (songtitle != null)
        songtitle.setText(MusicPlayer.getTrackName());
    if (songalbum != null)
        songalbum.setText(MusicPlayer.getAlbumName());
    if (songartist != null)
        songartist.setText(MusicPlayer.getArtistName());
    if (songduration != null && getActivity() != null)
        songduration.setText(TimberUtils.makeShortTimeString(getActivity(), MusicPlayer.duration() / 1000));
    if (mProgress != null) {
        mProgress.setMax((int) MusicPlayer.duration());
        if (mUpdateProgress != null) {
            mProgress.removeCallbacks(mUpdateProgress);
        }
        mProgress.postDelayed(mUpdateProgress, 10);
    }
    if (mCircularProgress != null) {
        mCircularProgress.setMax((int) MusicPlayer.duration());
        if (mUpdateCircularProgress != null) {
            mCircularProgress.removeCallbacks(mUpdateCircularProgress);
        }
        mCircularProgress.postDelayed(mUpdateCircularProgress, 10);
    }
    if (timelyView11 != null) {
        mElapsedTimeHandler = new Handler();
        mElapsedTimeHandler.postDelayed(mUpdateElapsedTime, 600);
    }
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) Handler(android.os.Handler) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) TimelyView(com.naman14.timber.timely.TimelyView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView)

Example 4 with FailReason

use of com.nostra13.universalimageloader.core.assist.FailReason in project Timber by naman14.

the class AlbumAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
    Album localItem = arraylist.get(i);
    itemHolder.title.setText(localItem.title);
    itemHolder.artist.setText(localItem.artistName);
    ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(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) {
                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);
                }
            }
        }
    });
    if (TimberUtils.isLollipop())
        itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
Also used : Palette(android.support.v7.graphics.Palette) Album(com.naman14.timber.models.Album) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)

Example 5 with FailReason

use of com.nostra13.universalimageloader.core.assist.FailReason 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));
    if (TimberUtils.isLollipop())
        itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
Also used : Palette(android.support.v7.graphics.Palette) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.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)

Aggregations

FailReason (com.nostra13.universalimageloader.core.assist.FailReason)19 Bitmap (android.graphics.Bitmap)18 View (android.view.View)17 ImageView (android.widget.ImageView)17 TextView (android.widget.TextView)12 ImageLoadingListener (com.nostra13.universalimageloader.core.assist.ImageLoadingListener)7 RecyclerView (android.support.v7.widget.RecyclerView)6 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)6 Palette (android.support.v7.graphics.Palette)4 LayoutInflater (android.view.LayoutInflater)4 SimpleImageLoadingListener (com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener)4 Track (io.recom.howabout.category.music.model.Track)4 ProgressBar (android.widget.ProgressBar)3 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)3 HowaboutApplication (io.recom.howabout.HowaboutApplication)3 OnClickListener (android.view.View.OnClickListener)2 InjectView (butterknife.InjectView)2 ActionBar (com.actionbarsherlock.app.ActionBar)2 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)2 MaterialDrawableBuilder (net.steamcrafted.materialiconlib.MaterialDrawableBuilder)2