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;
}
Aggregations