Search in sources :

Example 11 with Comment

use of net.dean.jraw.models.Comment 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

Comment (net.dean.jraw.models.Comment)11 View (android.view.View)9 RecyclerView (android.support.v7.widget.RecyclerView)7 TextView (android.widget.TextView)7 ImageView (android.widget.ImageView)6 OpenRedditLink (me.ccrama.redditslide.OpenRedditLink)6 SpannableStringBuilder (android.text.SpannableStringBuilder)5 AlertDialogWrapper (com.afollestad.materialdialogs.AlertDialogWrapper)5 Activity (android.app.Activity)4 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 LayoutInflater (android.view.LayoutInflater)4 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)4 ApiException (net.dean.jraw.ApiException)4 TypedArray (android.content.res.TypedArray)3 Typeface (android.graphics.Typeface)3 ForegroundColorSpan (android.text.style.ForegroundColorSpan)3 LinearLayout (android.widget.LinearLayout)3 BottomSheet (com.cocosw.bottomsheet.BottomSheet)3 SlidingUpPanelLayout (com.sothree.slidinguppanel.SlidingUpPanelLayout)3