Search in sources :

Example 1 with ImageLoadingListener

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

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

the class SubredditPosts method loadPhotos.

public void loadPhotos(List<Submission> submissions) {
    for (Submission submission : submissions) {
        String url;
        ContentType.Type type = ContentType.getContentType(submission);
        if (submission.getThumbnails() != null) {
            if (type == ContentType.Type.IMAGE || type == ContentType.Type.SELF || (submission.getThumbnailType() == Submission.ThumbnailType.URL)) {
                if (type == ContentType.Type.IMAGE) {
                    if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails() != null && submission.getThumbnails().getVariations() != null && submission.getThumbnails().getVariations().length > 0) {
                        int length = submission.getThumbnails().getVariations().length;
                        if (SettingValues.lqLow && length >= 3) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
                        } else if (SettingValues.lqMid && length >= 4) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
                        } else if (length >= 5) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
                        } else {
                            url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                        }
                    } else {
                        if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height")) {
                            // Load the preview image which has probably already been cached in memory instead of the direct link
                            url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
                        } else {
                            url = submission.getUrl();
                        }
                    }
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, 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) {
                        }
                    });
                } else if (submission.getThumbnails() != null) {
                    if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails().getVariations().length != 0) {
                        int length = submission.getThumbnails().getVariations().length;
                        if (SettingValues.lqLow && length >= 3) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
                        } else if (SettingValues.lqMid && length >= 4) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
                        } else if (length >= 5) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
                        } else {
                            url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                        }
                    } else {
                        url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                    }
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, 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) {
                        }
                    });
                } else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) {
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(submission.getUrl(), 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) {
                        }
                    });
                }
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) Submission(net.dean.jraw.models.Submission) ContentType(me.ccrama.redditslide.ContentType) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) Reddit(me.ccrama.redditslide.Reddit) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) View(android.view.View)

Example 3 with ImageLoadingListener

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

the class MultiredditPosts method loadPhotos.

public void loadPhotos(List<Submission> submissions) {
    for (Submission submission : submissions) {
        String url;
        ContentType.Type type = ContentType.getContentType(submission);
        if (submission.getThumbnails() != null) {
            if (type == ContentType.Type.IMAGE || type == ContentType.Type.SELF || (submission.getThumbnailType() == Submission.ThumbnailType.URL)) {
                if (type == ContentType.Type.IMAGE) {
                    if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails() != null && submission.getThumbnails().getVariations() != null && submission.getThumbnails().getVariations().length > 0) {
                        int length = submission.getThumbnails().getVariations().length;
                        if (SettingValues.lqLow && length >= 3) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
                        } else if (SettingValues.lqMid && length >= 4) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
                        } else if (length >= 5) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
                        } else {
                            url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                        }
                    } else {
                        if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height")) {
                            // Load the preview image which has probably already been cached in memory instead of the direct link
                            url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
                        } else {
                            url = submission.getUrl();
                        }
                    }
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, 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) {
                        }
                    });
                } else if (submission.getThumbnails() != null) {
                    if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails().getVariations().length != 0) {
                        int length = submission.getThumbnails().getVariations().length;
                        if (SettingValues.lqLow && length >= 3) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
                        } else if (SettingValues.lqMid && length >= 4) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
                        } else if (length >= 5) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
                        } else {
                            url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                        }
                    } else {
                        url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                    }
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, 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) {
                        }
                    });
                } else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) {
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(submission.getUrl(), 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) {
                        }
                    });
                }
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) Submission(net.dean.jraw.models.Submission) ContentType(me.ccrama.redditslide.ContentType) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) MultiReddit(net.dean.jraw.models.MultiReddit) Reddit(me.ccrama.redditslide.Reddit) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) View(android.view.View)

Example 4 with ImageLoadingListener

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

the class SubredditPostsRealm method loadPhotos.

public void loadPhotos(List<Submission> submissions) {
    for (Submission submission : submissions) {
        String url;
        ContentType.Type type = ContentType.getContentType(submission);
        if (submission.getThumbnails() != null) {
            if (type == ContentType.Type.IMAGE || type == ContentType.Type.SELF || (submission.getThumbnailType() == Submission.ThumbnailType.URL)) {
                if (type == ContentType.Type.IMAGE) {
                    if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails() != null && submission.getThumbnails().getVariations() != null && submission.getThumbnails().getVariations().length > 0) {
                        int length = submission.getThumbnails().getVariations().length;
                        if (SettingValues.lqLow && length >= 3) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
                        } else if (SettingValues.lqMid && length >= 4) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
                        } else if (length >= 5) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
                        } else {
                            url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                        }
                    } else {
                        if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height")) {
                            // Load the preview image which has probably already been cached in memory instead of the direct link
                            url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
                        } else {
                            url = submission.getUrl();
                        }
                    }
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, 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) {
                        }
                    });
                } else if (submission.getThumbnails() != null) {
                    if (((!NetworkUtil.isConnectedWifi(c) && SettingValues.lowResMobile) || SettingValues.lowResAlways) && submission.getThumbnails().getVariations().length != 0) {
                        int length = submission.getThumbnails().getVariations().length;
                        if (SettingValues.lqLow && length >= 3) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[2].getUrl()).toString();
                        } else if (SettingValues.lqMid && length >= 4) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[3].getUrl()).toString();
                        } else if (length >= 5) {
                            url = Html.fromHtml(submission.getThumbnails().getVariations()[length - 1].getUrl()).toString();
                        } else {
                            url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                        }
                    } else {
                        url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()).toString();
                    }
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(url, 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) {
                        }
                    });
                } else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) {
                    ((Reddit) c.getApplicationContext()).getImageLoader().loadImage(submission.getUrl(), 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) {
                        }
                    });
                }
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) Submission(net.dean.jraw.models.Submission) ContentType(me.ccrama.redditslide.ContentType) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) Reddit(me.ccrama.redditslide.Reddit) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) View(android.view.View)

Example 5 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project NewPipe by TeamNewPipe.

the class VideoDetailFragment method initThumbnailViews.

private void initThumbnailViews(@NonNull StreamInfo info) {
    thumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark);
    if (!TextUtils.isEmpty(info.getThumbnailUrl())) {
        final String infoServiceName = NewPipe.getNameOfService(info.getServiceId());
        final ImageLoadingListener onFailListener = new SimpleImageLoadingListener() {

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                showSnackBarError(failReason.getCause(), UserAction.LOAD_IMAGE, infoServiceName, imageUri, R.string.could_not_load_thumbnails);
            }
        };
        imageLoader.displayImage(info.getThumbnailUrl(), thumbnailImageView, ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS, onFailListener);
    }
    if (!TextUtils.isEmpty(info.getUploaderAvatarUrl())) {
        imageLoader.displayImage(info.getUploaderAvatarUrl(), uploaderThumb, ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
    }
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) ParallaxScrollView(com.nirhart.parallaxscroll.views.ParallaxScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) AnimationUtils.animateView(org.schabi.newpipe.util.AnimationUtils.animateView) TextView(android.widget.TextView)

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