Search in sources :

Example 11 with OpenRedditLink

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

the class MediaFragmentComment 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");
    }
    final SlidingUpPanelLayout slideLayout = ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout));
    PopulateShadowboxInfo.doActionbar(s.comment, rootView, getActivity(), true);
    (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE);
    ContentType.Type type = ContentType.getContentType(contentUrl);
    if (!ContentType.fullImage(type)) {
        addClickFunctions((rootView.findViewById(R.id.submission_image)), slideLayout, rootView, type, getActivity(), s);
    } else {
        (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE);
        addClickFunctions((rootView.findViewById(R.id.submission_image)), slideLayout, rootView, type, getActivity(), s);
    }
    doLoad(contentUrl);
    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() {
            ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).setPanelHeight(title.getMeasuredHeight());
            title.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });
    ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).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) {
                final Comment c = s.comment.getComment();
                rootView.findViewById(R.id.base).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        String url = "https://reddit.com" + "/r/" + c.getSubredditName() + "/comments/" + c.getDataNode().get("link_id").asText().substring(3, c.getDataNode().get("link_id").asText().length()) + "/nothing/" + c.getId() + "?context=3";
                        new OpenRedditLink(getActivity(), url);
                    }
                });
            } else {
                rootView.findViewById(R.id.base).setOnClickListener(openClick);
            }
        }
    });
    return rootView;
}
Also used : Comment(net.dean.jraw.models.Comment) SlidingUpPanelLayout(com.sothree.slidinguppanel.SlidingUpPanelLayout) ContentType(me.ccrama.redditslide.ContentType) 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) ViewTreeObserver(android.view.ViewTreeObserver) OpenRedditLink(me.ccrama.redditslide.OpenRedditLink)

Aggregations

OpenRedditLink (me.ccrama.redditslide.OpenRedditLink)11 View (android.view.View)8 Intent (android.content.Intent)6 TextView (android.widget.TextView)6 Comment (net.dean.jraw.models.Comment)6 RecyclerView (android.support.v7.widget.RecyclerView)5 DialogInterface (android.content.DialogInterface)4 TypedArray (android.content.res.TypedArray)4 SpannableStringBuilder (android.text.SpannableStringBuilder)4 ImageView (android.widget.ImageView)4 LinearLayout (android.widget.LinearLayout)4 ClipData (android.content.ClipData)3 ClipboardManager (android.content.ClipboardManager)3 Typeface (android.graphics.Typeface)3 ForegroundColorSpan (android.text.style.ForegroundColorSpan)3 StyleSpan (android.text.style.StyleSpan)3 AlertDialogWrapper (com.afollestad.materialdialogs.AlertDialogWrapper)3 BottomSheet (com.cocosw.bottomsheet.BottomSheet)3 PopulateSubmissionViewHolder (me.ccrama.redditslide.SubmissionViews.PopulateSubmissionViewHolder)3 FontPreferences (me.ccrama.redditslide.Visuals.FontPreferences)3