Search in sources :

Example 1 with ImageLoadingListener

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

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

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

the class QuickControlsFragment method updateNowplayingCard.

public void updateNowplayingCard() {
    mTitle.setText(MusicPlayer.getTrackName());
    mArtist.setText(MusicPlayer.getArtistName());
    mTitleExpanded.setText(MusicPlayer.getTrackName());
    mArtistExpanded.setText(MusicPlayer.getArtistName());
    if (!duetoplaypause) {
        ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(MusicPlayer.getCurrentAlbumId()).toString(), mAlbumArt, 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) {
                Bitmap failedBitmap = ImageLoader.getInstance().loadImageSync("drawable://" + R.drawable.ic_empty_music2);
                if (getActivity() != null)
                    new setBlurredAlbumArt().execute(failedBitmap);
            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                if (getActivity() != null)
                    new setBlurredAlbumArt().execute(loadedImage);
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {
            }
        });
    }
    duetoplaypause = false;
    mProgress.setMax((int) MusicPlayer.duration());
    mSeekBar.setMax((int) MusicPlayer.duration());
    mProgress.postDelayed(mUpdateProgress, 10);
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 4 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.assist.ImageLoadingListener in project howabout-android by recomio.

the class ShowImageListAdapter method getView.

@Override
public View getView(int position, View convertView, final ViewGroup parent) {
    final View showImageListItemView;
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        showImageListItemView = inflater.inflate(R.layout.show_image_item, parent, false);
    } else {
        showImageListItemView = convertView;
    }
    final ImageView imageView = (ImageView) showImageListItemView.findViewById(R.id.image);
    final ProgressBar progressBar = (ProgressBar) showImageListItemView.findViewById(R.id.load);
    String imageUrl = imageList.get(position).getBasicUrl();
    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) {
            // 스크린 width에 꽉 차게 view 리사이징.
            float ratio = (float) parent.getWidth() / (float) loadedImage.getWidth();
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(parent.getWidth(), (int) ((float) loadedImage.getHeight() * ratio));
            imageView.setLayoutParams(lp);
            // margin.
            lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            lp.setMargins(1, 1, 1, 1);
            imageView.setLayoutParams(lp);
            imageView.setVisibility(View.VISIBLE);
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
            progressBar.setVisibility(View.GONE);
        }
    });
    return showImageListItemView;
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) LayoutInflater(android.view.LayoutInflater) RelativeLayout(android.widget.RelativeLayout) ImageView(android.widget.ImageView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) ProgressBar(android.widget.ProgressBar)

Example 5 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.assist.ImageLoadingListener in project howabout-android by recomio.

the class MusicPlaylistActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    imageLoader = ImageLoader.getInstance();
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    setAdsContainer(R.id.adView);
    HowaboutApplication application = (HowaboutApplication) getApplication();
    playlistAdapter = application.getPlaylistAdapter();
    if (MusicPlayerService.isLoading()) {
        loadingProgressBar.setVisibility(View.VISIBLE);
        playPauseToggleButton.setVisibility(View.GONE);
    } else {
        if (MusicPlayerService.isPlaying()) {
            playPauseToggleButton.setImageDrawable(pauseIcon);
        } else {
            playPauseToggleButton.setImageDrawable(playIcon);
        }
        loadingProgressBar.setVisibility(View.GONE);
        playPauseToggleButton.setVisibility(View.VISIBLE);
    }
    listView.setAdapter(playlistAdapter);
    playlistAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            try {
                Track track = playlistAdapter.getCurrentItem();
                actionBar.setTitle(track.getTrackTitle());
                actionBar.setSubtitle(track.getArtistName());
                if (MusicPlayerService.isLoading()) {
                    loadingProgressBar.setVisibility(View.VISIBLE);
                    playPauseToggleButton.setVisibility(View.GONE);
                } else {
                    if (MusicPlayerService.isPlaying()) {
                        playPauseToggleButton.setImageDrawable(pauseIcon);
                    } else {
                        playPauseToggleButton.setImageDrawable(playIcon);
                    }
                    loadingProgressBar.setVisibility(View.GONE);
                    playPauseToggleButton.setVisibility(View.VISIBLE);
                }
                imageLoader.displayImage(track.getThumbnailUrl(), songImageView, 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) {
                    }

                    @Override
                    public void onLoadingCancelled(String imageUri, View view) {
                    }
                });
                String lyrics = playlistAdapter.getCurrentLyrics();
                if (lyrics == null) {
                    lyricsScrollView.setVisibility(View.GONE);
                    lyricsTextView.setText("");
                } else {
                    lyricsScrollView.setVisibility(View.VISIBLE);
                    lyricsTextView.setText(lyrics);
                }
                listView.invalidate();
            } catch (Exception e) {
            }
        }

        @Override
        public void onInvalidated() {
        }
    });
    playlistAdapter.notifyDataSetChanged();
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            playlistAdapter.play(position);
            playlistAdapter.notifyDataSetChanged();
        }
    });
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            playlistAdapter.remove(position);
            return true;
        }
    });
    playPauseToggleButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playPauseToggle();
            if (MusicPlayerService.isPlaying()) {
                playPauseToggleButton.setImageDrawable(pauseIcon);
            } else {
                playPauseToggleButton.setImageDrawable(playIcon);
            }
        }
    });
    prevButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playPrev();
        }
    });
    nextButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playNext();
        }
    });
    UpdateCurrentPositionTask updateCurrentPositionTask = new UpdateCurrentPositionTask();
    updateCurrentPositionTimer.scheduleAtFixedRate(updateCurrentPositionTask, 0, 1000);
}
Also used : ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) HowaboutApplication(io.recom.howabout.HowaboutApplication) DataSetObserver(android.database.DataSetObserver) ContentView(roboguice.inject.ContentView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) ActionBar(com.actionbarsherlock.app.ActionBar) Track(io.recom.howabout.category.music.model.Track)

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