Search in sources :

Example 1 with ImageErrorLoadingListener

use of org.schabi.newpipe.ImageErrorLoadingListener 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 2 with ImageErrorLoadingListener

use of org.schabi.newpipe.ImageErrorLoadingListener in project NewPipe by TeamNewPipe.

the class InfoItemBuilder method buildStreamInfoItem.

private void buildStreamInfoItem(StreamInfoItemHolder holder, final StreamInfoItem info) {
    if (info.infoType() != InfoItem.InfoType.STREAM) {
        Log.e("InfoItemBuilder", "Info type not yet supported");
    }
    // fill holder with information
    holder.itemVideoTitleView.setText(info.title);
    if (info.uploader != null && !info.uploader.isEmpty()) {
        holder.itemUploaderView.setText(info.uploader);
    } else {
        holder.itemUploaderView.setVisibility(View.INVISIBLE);
    }
    if (info.duration > 0) {
        holder.itemDurationView.setText(getDurationString(info.duration));
    } else {
        if (info.stream_type == AbstractStreamInfo.StreamType.LIVE_STREAM) {
            holder.itemDurationView.setText(R.string.duration_live);
        } else {
            holder.itemDurationView.setVisibility(View.GONE);
        }
    }
    if (info.view_count >= 0) {
        holder.itemViewCountView.setText(shortViewCount(info.view_count));
    } else {
        holder.itemViewCountView.setVisibility(View.GONE);
    }
    if (info.upload_date != null && !info.upload_date.isEmpty()) {
        holder.itemUploadDateView.setText(info.upload_date + " • ");
    }
    holder.itemThumbnailView.setImageResource(R.drawable.dummy_thumbnail);
    if (info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
        imageLoader.displayImage(info.thumbnail_url, holder.itemThumbnailView, displayImageOptions, new ImageErrorLoadingListener(activity, rootView, info.service_id));
    }
    holder.itemButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            onStreamInfoItemSelectedListener.selected(info.webpage_url, info.service_id);
        }
    });
}
Also used : ImageErrorLoadingListener(org.schabi.newpipe.ImageErrorLoadingListener) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 3 with ImageErrorLoadingListener

use of org.schabi.newpipe.ImageErrorLoadingListener in project NewPipe by TeamNewPipe.

the class InfoItemBuilder method buildChannelInfoItem.

private void buildChannelInfoItem(ChannelInfoItemHolder holder, final ChannelInfoItem info) {
    holder.itemChannelTitleView.setText(info.getTitle());
    holder.itemSubscriberCountView.setText(shortSubscriber(info.subscriberCount) + " • ");
    holder.itemVideoCountView.setText(info.videoAmount + " " + videosS);
    holder.itemChannelDescriptionView.setText(info.description);
    holder.itemThumbnailView.setImageResource(R.drawable.buddy_channel_item);
    if (info.thumbnailUrl != null && !info.thumbnailUrl.isEmpty()) {
        imageLoader.displayImage(info.thumbnailUrl, holder.itemThumbnailView, displayImageOptions, new ImageErrorLoadingListener(activity, rootView, info.serviceId));
    }
    holder.itemButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            onChannelInfoItemSelectedListener.selected(info.getLink(), info.serviceId);
        }
    });
}
Also used : ImageErrorLoadingListener(org.schabi.newpipe.ImageErrorLoadingListener) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

View (android.view.View)3 ImageErrorLoadingListener (org.schabi.newpipe.ImageErrorLoadingListener)3 AdapterView (android.widget.AdapterView)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)1 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)1