Example #1
0
  @Override
  public void onResume() {
    super.onResume();

    // set ordering
    commentsAdapter.setPrioritizeOpComments(settings.prioritizeOpComments());
  }
Example #2
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    this.tabletLayout = view.findViewById(R.id.infoview) != null;

    if (!(getActivity() instanceof ToolbarActivity)) {
      throw new IllegalStateException("Fragment must be child of a ToolbarActivity.");
    }

    ToolbarActivity activity = (ToolbarActivity) getActivity();
    activity.getScrollHideToolbarListener().reset();

    int abHeight = AndroidUtility.getActionBarContentOffset(getActivity());
    if (tabletLayout) {
      View tabletLayout = ButterKnife.findById(view, R.id.tabletlayout);
      tabletLayout.setPadding(0, abHeight, 0, 0);

      ((FrameLayout.LayoutParams) voteAnimationIndicator.getLayoutParams()).gravity =
          Gravity.CENTER;

      scrollHandler = new NoopOnScrollListener();
    } else {
      // use height of the toolbar to configure swipe refresh layout.
      swipeRefreshLayout.setProgressViewOffset(false, 0, (int) (1.5 * abHeight));

      scrollHandler = new ScrollHandler(activity);
    }

    content.addOnScrollListener(scrollHandler);

    swipeRefreshLayout.setColorSchemeResources(R.color.primary);
    swipeRefreshLayout.setOnRefreshListener(
        () -> {
          if (!isVideoFullScreen()) {
            rewindOnLoad = true;
            loadPostDetails();
          }
        });

    swipeRefreshLayout.setKeepScreenOn(settings.keepScreenOn());

    adapter = new MergeRecyclerAdapter();
    content.setItemAnimator(null);
    content.setLayoutManager(new LinearLayoutManager(getActivity()));
    content.setAdapter(adapter);

    initializeMediaView();
    initializeInfoLine();
    initializeCommentPostLine();

    commentsAdapter = new CommentsAdapter(userService.getName().or(""));
    commentsAdapter.setCommentActionListener(this);
    commentsAdapter.setPrioritizeOpComments(settings.prioritizeOpComments());
    commentsAdapter.setShowFavCommentButton(userService.isAuthorized());
    adapter.addAdapter(commentsAdapter);

    // restore the postInfo, if possible.
    if (tags != null && comments != null) {
      displayTags(tags);
      displayComments(comments);
    }

    loadPostDetails();

    // show the repost badge if this is a repost
    repostHint.setVisibility(isRepost() ? View.VISIBLE : View.GONE);
  }