Пример #1
0
  @Override
  public void onLoadFinished(
      final Loader<AugmentedQuoteContainer> loader, final AugmentedQuoteContainer data) {
    if (data == null) {
      // TODO - we need to tailor this to lack of connection/other network issue
      addDataToAdapter(null);
      return;
    }

    if (mInfiniteScrollListener != null
        && !mInfiniteScrollListener.isLoading()
        && !mRefreshLayout.isRefreshing()) {
      // This may happen when we are coming back from posts fragment to threads. For some
      // reason loadFinished gets called. However, we may have new data about the thread -
      // don't disturb this data.
      UIUtils.updateEmptyViewState(getView(), mRecyclerView, false);
      mRecyclerView.setOnScrollListener(mInfiniteScrollListener);
      return;
    } else if (data.getCurrentPage() == 1 || mInfiniteScrollListener == null) {
      mAdapter.clear();

      mTotalPages = data.getTotalPages();
      mInfiniteScrollListener =
          new InfiniteRecyclerLoadHelper(
              mRecyclerView, new InfiniteLoadCallback(), mTotalPages, null);
    }
    mInfiniteScrollListener.onLoadFinished();

    addDataToAdapter(data.getQuotes());
    if (!mInfiniteScrollListener.hasMoreData()) {
      mAdapter.removeFooter();
    }
  }
Пример #2
0
  private void addDataToAdapter(final List<AugmentedQuote> data) {
    UIUtils.updateEmptyViewState(getView(), mRecyclerView, data == null ? 0 : data.size());

    // Let's actually add the items now
    mAdapter.addAll(data);
    mRefreshLayout.setRefreshing(false);
  }
Пример #3
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public void onViewCreated(final View view, final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ActionBar actionBar = UIUtils.getSupportActionBar(getActivity());
    actionBar.setTitle(R.string.private_messages);

    mViewPager = (ViewPager) view.findViewById(R.id.message_view_pager);
    mViewPager.setAdapter(mAdapter);

    final TabLayout tabLayout = (TabLayout) view.findViewById(R.id.pager_tab_strip);
    tabLayout.setSelectedIndicatorColors(getResources().getColor(android.R.color.white));
    tabLayout.setViewPager(mViewPager);

    final FloatingActionButton button =
        (FloatingActionButton) view.findViewById(R.id.message_fragment_action_create);

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(final View v) {
            final DialogFragment fragment = CreateMessageFragment.createInstance();
            fragment.setTargetFragment(MessagePagerFragment.this, CREATE_MESSAGE_REQUEST_CODE);
            fragment.show(getFragmentManager(), "createMessage");
          }
        });

    if (CompatUtils.hasLollipop()) {
      CompatUtils.setBackground(button, getResources().getDrawable(R.drawable.fab_background));
    } else {
      button.setBackgroundColor(getResources().getColor(R.color.fab_color));
    }
  }
  @Override
  public void onViewCreated(final View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ViewPager viewPager = (ViewPager) view.findViewById(R.id.forum_view_pager);
    viewPager.setAdapter(mAdapter);
    viewPager.setOffscreenPageLimit(10);

    final TabLayout slidingTabLayout =
        (TabLayout) view.findViewById(R.id.fragment_sliding_tab_layout);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(android.R.color.white));
    slidingTabLayout.setViewPager(viewPager);

    final ActionBar bar = UIUtils.getSupportActionBar(getActivity());
    bar.show();
    bar.setTitle(R.string.quote_mentions);
    bar.setSubtitle(null);
  }