question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically fetch first result on load more, scrolls the RecyclerView

See original GitHub issue

Hi,

There’s a method to fetch first result on load more automatically, I tested it and I found it scrolls the RecyclerView but it shouldn’t.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
davideascommented, Nov 18, 2017

I moved the adding after the removal of the progressItem, this preserves also the feature to delay the removal to display a message in the progressItem.

I release this fix in the new SNAPSHOT in few moments…

1reaction
NamingExceptioncommented, Nov 16, 2017

Hi @davideas ,

You can reproduce this in the sample app in the FragmentInstagramHeaders class.

Just replace initializeRecyclerView code with

private void initializeRecyclerView() {
        // Initialize Adapter and RecyclerView
        // true = it makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
        FlexibleAdapter.useTag("InstagramHeadersAdapter");
        mAdapter = new FlexibleAdapter<>(new ArrayList<>(), getActivity(), true);
        mAdapter.addListener(getActivity())
                .setAnimationOnScrolling(true)
                .setAnimationOnReverseScrolling(true);
        mRecyclerView = getView().findViewById(R.id.recycler_view);
        mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
        mRecyclerView.setAdapter(mAdapter);
        mRecyclerView.setHasFixedSize(true); //Size of RV will not change
        // NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
        // a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        // Custom divider item decorator with 24dpi as empty space between sections
        mRecyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity()).withDefaultDivider());

        mAdapter.setDisplayHeadersAtStartUp(true) //Show Headers at startUp!
                .setStickyHeaders(true) //Make headers sticky
                // Endless scroll with 1 item threshold
                .setEndlessScrollListener(this, new ProgressItem())
				.setLoadingMoreAtStartUp(true)
                .setEndlessScrollThreshold(1); //Default=1

        SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout);
        swipeRefreshLayout.setEnabled(true);
        mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE);
    }

You init the recycler with 0 items, and setLoadingMoreAtStartUp to true. After the items are loaded the recycler is scrolled a bit down and is not at the first item.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android RecyclerView Load More, Endless Scrolling
In this tutorial, we'll be discussing and implementing Endless Scrolling or Infinite Scroll on RecyclerView in our Android Application.
Read more >
Refreshing data in RecyclerView and keeping its scroll position
The top answer by @DawnYu works, but the recyclerview will first scroll to the top, then go back to the intended scroll position...
Read more >
Android RecyclerView Load More on Scroll with Example
Navigate to the app > res > layout > activity_main. xml and add the below code to that file. Below is the code...
Read more >
Endless Scrolling with AdapterViews and RecyclerView
A common application feature is to load automatically more items as the user scrolls through the items (aka infinite scroll). This is done...
Read more >
Recycleview scroll back to first item when calling recyclerView ...
final RecycleviewAdapter mRecycleviewAdapter = new RecycleviewAdapter(chData, chName, this); recyclerView.setAdapter(mRecycleviewAdapter); recyclerView.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found