Search in sources :

Example 6 with SubsamplingScaleImageView

use of me.ccrama.redditslide.Views.SubsamplingScaleImageView in project Slide by ccrama.

the class MediaFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = (ViewGroup) inflater.inflate(R.layout.submission_mediacard, container, false);
    if (savedInstanceState != null && savedInstanceState.containsKey("position")) {
        stopPosition = savedInstanceState.getLong("position");
    }
    PopulateShadowboxInfo.doActionbar(s, rootView, getActivity(), true);
    (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE);
    ImageView typeImage = (ImageView) rootView.findViewById(R.id.type);
    typeImage.setVisibility(View.VISIBLE);
    SubsamplingScaleImageView img = rootView.findViewById(R.id.submission_image);
    final SlidingUpPanelLayout slideLayout = ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout));
    ContentType.Type type = ContentType.getContentType(s);
    img.setAlpha(1f);
    if (s.getThumbnail() == null || s.getThumbnail().isEmpty() || firstUrl == null || firstUrl.isEmpty() || (s.isNsfw() && SettingValues.getIsNSFWEnabled())) {
        (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.VISIBLE);
        ((ImageView) rootView.findViewById(R.id.thumbimage2)).setImageResource(R.drawable.web);
        addClickFunctions((rootView.findViewById(R.id.thumbimage2)), slideLayout, rootView, type, getActivity(), s);
        (rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
        if ((s.isNsfw() && SettingValues.getIsNSFWEnabled())) {
            ((ImageView) rootView.findViewById(R.id.thumbimage2)).setImageResource(R.drawable.nsfw);
        } else {
            if (firstUrl.isEmpty() && !s.getThumbnail().isEmpty()) {
                ((Reddit) getContext().getApplicationContext()).getImageLoader().displayImage(s.getThumbnail(), ((ImageView) rootView.findViewById(R.id.thumbimage2)));
            }
        }
    } else {
        (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE);
        addClickFunctions(img, slideLayout, rootView, type, getActivity(), s);
    }
    if (!s.isNsfw() || !SettingValues.getIsNSFWEnabled()) {
        if (type == ContentType.Type.EXTERNAL || type == ContentType.Type.LINK || type == ContentType.Type.VIDEO) {
            doLoad(firstUrl, type);
        } else {
            doLoad(contentUrl, type);
        }
    }
    switch(type) {
        case ALBUM:
            typeImage.setImageResource(R.drawable.album);
            break;
        case EXTERNAL:
        case LINK:
        case REDDIT:
            typeImage.setImageResource(R.drawable.world);
            rootView.findViewById(R.id.submission_image).setAlpha(0.5f);
            break;
        case SELF:
            typeImage.setImageResource(R.drawable.fontsizedarker);
            break;
        case EMBEDDED:
        case VIDEO:
            typeImage.setImageResource(R.drawable.play);
            rootView.findViewById(R.id.submission_image).setAlpha(0.5f);
            break;
        default:
            typeImage.setVisibility(View.GONE);
            break;
    }
    rootView.findViewById(R.id.base).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i2 = new Intent(getActivity(), CommentsScreen.class);
            i2.putExtra(CommentsScreen.EXTRA_PAGE, i);
            i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, sub);
            getActivity().startActivity(i2);
        }
    });
    final View.OnClickListener openClick = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
        }
    };
    rootView.findViewById(R.id.base).setOnClickListener(openClick);
    final View title = rootView.findViewById(R.id.title);
    title.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            slideLayout.setPanelHeight(title.getMeasuredHeight());
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                title.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        }
    });
    slideLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {

        @Override
        public void onPanelSlide(View panel, float slideOffset) {
        }

        @Override
        public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
            if (newState == SlidingUpPanelLayout.PanelState.EXPANDED) {
                rootView.findViewById(R.id.base).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent i2 = new Intent(getActivity(), CommentsScreen.class);
                        i2.putExtra(CommentsScreen.EXTRA_PAGE, i);
                        i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, sub);
                        getActivity().startActivity(i2);
                    }
                });
            } else {
                rootView.findViewById(R.id.base).setOnClickListener(openClick);
            }
        }
    });
    return rootView;
}
Also used : CommentsScreen(me.ccrama.redditslide.Activities.CommentsScreen) SlidingUpPanelLayout(com.sothree.slidinguppanel.SlidingUpPanelLayout) ContentType(me.ccrama.redditslide.ContentType) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) Intent(android.content.Intent) 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) ImageView(android.widget.ImageView) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 7 with SubsamplingScaleImageView

use of me.ccrama.redditslide.Views.SubsamplingScaleImageView in project Slide by ccrama.

the class AlbumPager method loadImage.

private static void loadImage(final View rootView, Fragment f, String url, boolean single) {
    final SubsamplingScaleImageView image = (SubsamplingScaleImageView) rootView.findViewById(R.id.image);
    image.setMinimumDpi(70);
    image.setMinimumTileDpi(240);
    ImageView fakeImage = new ImageView(f.getActivity());
    final TextView size = (TextView) rootView.findViewById(R.id.size);
    fakeImage.setLayoutParams(new LinearLayout.LayoutParams(image.getWidth(), image.getHeight()));
    fakeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
    ((Reddit) f.getActivity().getApplication()).getImageLoader().displayImage(url, new ImageViewAware(fakeImage), new DisplayImageOptions.Builder().resetViewBeforeLoading(true).cacheOnDisk(true).imageScaleType(single ? ImageScaleType.NONE : ImageScaleType.NONE_SAFE).cacheInMemory(false).build(), new ImageLoadingListener() {

        private View mView;

        @Override
        public void onLoadingStarted(String imageUri, View view) {
            mView = view;
            size.setVisibility(View.VISIBLE);
        }

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

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            size.setVisibility(View.GONE);
            image.setImage(ImageSource.bitmap(loadedImage));
            (rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
        }

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

        @Override
        public void onProgressUpdate(String imageUri, View view, int current, int total) {
            size.setText(readableFileSize(total));
            ((ProgressBar) rootView.findViewById(R.id.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) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) GridView(android.widget.GridView) ImageView(android.widget.ImageView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) MediaVideoView(me.ccrama.redditslide.Views.MediaVideoView) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) Bitmap(android.graphics.Bitmap) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) SubsamplingScaleImageView(me.ccrama.redditslide.Views.SubsamplingScaleImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

SubsamplingScaleImageView (me.ccrama.redditslide.Views.SubsamplingScaleImageView)7 View (android.view.View)6 ImageView (android.widget.ImageView)6 MediaVideoView (me.ccrama.redditslide.Views.MediaVideoView)6 Bitmap (android.graphics.Bitmap)5 LinearLayout (android.widget.LinearLayout)5 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)5 ImageViewAware (com.nostra13.universalimageloader.core.imageaware.ImageViewAware)5 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)5 ImageLoadingProgressListener (com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener)5 File (java.io.File)4 ValueAnimator (android.animation.ValueAnimator)3 Handler (android.os.Handler)3 ProgressBar (android.widget.ProgressBar)3 TextView (android.widget.TextView)3 IOException (java.io.IOException)3 MediaView (me.ccrama.redditslide.Activities.MediaView)3 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)3 Reddit (me.ccrama.redditslide.Reddit)3 AdapterView (android.widget.AdapterView)2