Search in sources :

Example 1 with Reddit

use of me.ccrama.redditslide.Reddit 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 2 with Reddit

use of me.ccrama.redditslide.Reddit 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 3 with Reddit

use of me.ccrama.redditslide.Reddit in project Slide by ccrama.

the class MediaFragmentComment method displayImage.

public void displayImage(final String url) {
    if (!imageShown) {
        actuallyLoaded = url;
        final SubsamplingScaleImageView i = (SubsamplingScaleImageView) rootView.findViewById(R.id.submission_image);
        i.setMinimumDpi(70);
        i.setMinimumTileDpi(240);
        final ProgressBar bar = (ProgressBar) rootView.findViewById(R.id.progress);
        bar.setIndeterminate(false);
        bar.setProgress(0);
        final Handler handler = new Handler();
        final Runnable progressBarDelayRunner = new Runnable() {

            public void run() {
                bar.setVisibility(View.VISIBLE);
            }
        };
        handler.postDelayed(progressBarDelayRunner, 500);
        ImageView fakeImage = new ImageView(getActivity());
        fakeImage.setLayoutParams(new LinearLayout.LayoutParams(i.getWidth(), i.getHeight()));
        fakeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
        File f = ((Reddit) getActivity().getApplicationContext()).getImageLoader().getDiscCache().get(url);
        if (f != null && f.exists()) {
            imageShown = true;
            try {
                i.setImage(ImageSource.uri(f.getAbsolutePath()));
            } catch (Exception e) {
            // todo  i.setImage(ImageSource.bitmap(loadedImage));
            }
            (rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
            handler.removeCallbacks(progressBarDelayRunner);
            previous = i.scale;
            final float base = i.scale;
            i.setOnZoomChangedListener(new SubsamplingScaleImageView.OnZoomChangedListener() {

                @Override
                public void onZoomLevelChanged(float zoom) {
                    if (zoom > previous && !hidden && zoom > base) {
                        hidden = true;
                        final View base = rootView.findViewById(R.id.base);
                        ValueAnimator va = ValueAnimator.ofFloat(1.0f, 0.2f);
                        // in millis
                        int mDuration = 250;
                        va.setDuration(mDuration);
                        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                            public void onAnimationUpdate(ValueAnimator animation) {
                                Float value = (Float) animation.getAnimatedValue();
                                base.setAlpha(value);
                            }
                        });
                        va.start();
                    // hide
                    } else if (zoom <= previous && hidden) {
                        hidden = false;
                        final View base = rootView.findViewById(R.id.base);
                        ValueAnimator va = ValueAnimator.ofFloat(0.2f, 1.0f);
                        // in millis
                        int mDuration = 250;
                        va.setDuration(mDuration);
                        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                            public void onAnimationUpdate(ValueAnimator animation) {
                                Float value = (Float) animation.getAnimatedValue();
                                base.setAlpha(value);
                            }
                        });
                        va.start();
                    // unhide
                    }
                    previous = zoom;
                }
            });
        } else {
            ((Reddit) getActivity().getApplicationContext()).getImageLoader().displayImage(url, new ImageViewAware(fakeImage), new DisplayImageOptions.Builder().resetViewBeforeLoading(true).cacheOnDisk(true).imageScaleType(ImageScaleType.NONE).cacheInMemory(false).build(), new ImageLoadingListener() {

                private View mView;

                @Override
                public void onLoadingStarted(String imageUri, View view) {
                    imageShown = true;
                    mView = view;
                }

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

                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    imageShown = true;
                    File f = null;
                    if (getActivity() != null) {
                        f = ((Reddit) getActivity().getApplicationContext()).getImageLoader().getDiscCache().get(url);
                    }
                    if (f != null && f.exists()) {
                        i.setImage(ImageSource.uri(f.getAbsolutePath()));
                    } else {
                        i.setImage(ImageSource.bitmap(loadedImage));
                    }
                    (rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
                    handler.removeCallbacks(progressBarDelayRunner);
                    previous = i.scale;
                    final float base = i.scale;
                    i.setOnZoomChangedListener(new SubsamplingScaleImageView.OnZoomChangedListener() {

                        @Override
                        public void onZoomLevelChanged(float zoom) {
                            if (zoom > previous && !hidden && zoom > base) {
                                hidden = true;
                                final View base = rootView.findViewById(R.id.base);
                                ValueAnimator va = ValueAnimator.ofFloat(1.0f, 0.2f);
                                // in millis
                                int mDuration = 250;
                                va.setDuration(mDuration);
                                va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                                    public void onAnimationUpdate(ValueAnimator animation) {
                                        Float value = (Float) animation.getAnimatedValue();
                                        base.setAlpha(value);
                                    }
                                });
                                va.start();
                            // hide
                            } else if (zoom <= previous && hidden) {
                                hidden = false;
                                final View base = rootView.findViewById(R.id.base);
                                ValueAnimator va = ValueAnimator.ofFloat(0.2f, 1.0f);
                                // in millis
                                int mDuration = 250;
                                va.setDuration(mDuration);
                                va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                                    public void onAnimationUpdate(ValueAnimator animation) {
                                        Float value = (Float) animation.getAnimatedValue();
                                        base.setAlpha(value);
                                    }
                                });
                                va.start();
                            // unhide
                            }
                            previous = zoom;
                        }
                    });
                }

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

                @Override
                public void onProgressUpdate(String imageUri, View view, int current, int total) {
                    ((ProgressBar) rootView.findViewById(R.id.progress)).setProgress(Math.round(100.0f * current / total));
                }
            });
        }
    }
}
Also used : ImageLoadingProgressListener(com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ValueAnimator(android.animation.ValueAnimator) Bitmap(android.graphics.Bitmap) Reddit(me.ccrama.redditslide.Reddit) ImageView(android.widget.ImageView) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) ProgressBar(android.widget.ProgressBar) ImageViewAware(com.nostra13.universalimageloader.core.imageaware.ImageViewAware) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) Handler(android.os.Handler) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) MediaView(me.ccrama.redditslide.Activities.MediaView) ImageView(android.widget.ImageView) View(android.view.View) MediaVideoView(me.ccrama.redditslide.Views.MediaVideoView) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) IOException(java.io.IOException) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Example 4 with Reddit

use of me.ccrama.redditslide.Reddit 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 Reddit

use of me.ccrama.redditslide.Reddit in project Slide by ccrama.

the class PeekMediaView method displayImage.

public void displayImage(final String urlB) {
    LogUtil.v("Displaying " + urlB);
    final String url = StringEscapeUtils.unescapeHtml4(urlB);
    if (!imageShown) {
        actuallyLoaded = url;
        final SubsamplingScaleImageView i = (SubsamplingScaleImageView) findViewById(R.id.submission_image);
        i.setMinimumDpi(70);
        i.setMinimumTileDpi(240);
        progress.setIndeterminate(false);
        progress.setProgress(0);
        final Handler handler = new Handler();
        final Runnable progressBarDelayRunner = new Runnable() {

            public void run() {
                progress.setVisibility(View.VISIBLE);
            }
        };
        handler.postDelayed(progressBarDelayRunner, 500);
        ImageView fakeImage = new ImageView(getContext());
        fakeImage.setLayoutParams(new LinearLayout.LayoutParams(i.getWidth(), i.getHeight()));
        fakeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
        File f = ((Reddit) getContext().getApplicationContext()).getImageLoader().getDiscCache().get(url);
        if (f != null && f.exists()) {
            imageShown = true;
            i.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() {

                @Override
                public void onReady() {
                }

                @Override
                public void onImageLoaded() {
                }

                @Override
                public void onPreviewLoadError(Exception e) {
                }

                @Override
                public void onImageLoadError(Exception e) {
                    imageShown = false;
                    LogUtil.v("No image displayed");
                }

                @Override
                public void onTileLoadError(Exception e) {
                }
            });
            try {
                i.setImage(ImageSource.uri(f.getAbsolutePath()));
                i.setZoomEnabled(false);
            } catch (Exception e) {
                imageShown = false;
            // todo  i.setImage(ImageSource.bitmap(loadedImage));
            }
            (progress).setVisibility(View.GONE);
            handler.removeCallbacks(progressBarDelayRunner);
        } else {
            ((Reddit) getContext().getApplicationContext()).getImageLoader().displayImage(url, new ImageViewAware(fakeImage), new DisplayImageOptions.Builder().resetViewBeforeLoading(true).cacheOnDisk(true).imageScaleType(ImageScaleType.NONE).cacheInMemory(false).build(), new ImageLoadingListener() {

                private View mView;

                @Override
                public void onLoadingStarted(String imageUri, View view) {
                    imageShown = true;
                    mView = view;
                }

                @Override
                public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                    Log.v(LogUtil.getTag(), "LOADING FAILED");
                    imageShown = false;
                }

                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    imageShown = true;
                    File f = ((Reddit) getContext().getApplicationContext()).getImageLoader().getDiscCache().get(url);
                    if (f != null && f.exists()) {
                        i.setImage(ImageSource.uri(f.getAbsolutePath()));
                    } else {
                        i.setImage(ImageSource.bitmap(loadedImage));
                    }
                    (progress).setVisibility(View.GONE);
                    handler.removeCallbacks(progressBarDelayRunner);
                }

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

                @Override
                public void onProgressUpdate(String imageUri, View view, int current, int total) {
                    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) Handler(android.os.Handler) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) IOException(java.io.IOException) Bitmap(android.graphics.Bitmap) Reddit(me.ccrama.redditslide.Reddit) ImageView(android.widget.ImageView) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Aggregations

Reddit (me.ccrama.redditslide.Reddit)11 View (android.view.View)9 Bitmap (android.graphics.Bitmap)8 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)8 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)8 ImageView (android.widget.ImageView)6 Handler (android.os.Handler)5 LinearLayout (android.widget.LinearLayout)5 ImageViewAware (com.nostra13.universalimageloader.core.imageaware.ImageViewAware)5 ImageLoadingProgressListener (com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener)5 File (java.io.File)5 IOException (java.io.IOException)5 Submission (net.dean.jraw.models.Submission)5 ProgressBar (android.widget.ProgressBar)4 ContentType (me.ccrama.redditslide.ContentType)4 MediaVideoView (me.ccrama.redditslide.Views.MediaVideoView)4 ValueAnimator (android.animation.ValueAnimator)3 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)3 SubsamplingScaleImageView (me.ccrama.redditslide.Views.SubsamplingScaleImageView)3 URISyntaxException (java.net.URISyntaxException)2