How to refresh selected item In paging library - android

I am using the android paging library to show a list of posts in the recycler view, my data source loads data from inMemory list which I add and remove from it then invalidate the data source to refresh the PagedListAdapter, everything is working well, but the problem is that when I scroll through pages, for example, page #5, and delete some item and call invalidate(), the data source will be re-initialized and will invoke the callbacks again, which re-loads the items in the recycler view, and jump to the first page.
The question is: How to refresh the items without jumping to the first page, and stick in the selected position?
Thanks.

Related

Compose Android - Update a Item from list without page refresh

I have a LazyColumn list which holds user Items and I have populated the list Item view no issue on that, in here say I need to update a view from the Item like updating the user profile picture without updating the whole list but just making the item that needs to be changed and not as whole page refresh.

How to remove item from Firestore Paging Adapter?

I am using Firestore Paging Adapter for loading a list of data and displaying it in RecyclerView. I set onClickListener on each item loaded and I would like to remove item from RecyclerView if it is pressed. How can I do that.
I get pressed item with
val pressedUserRealtion = getItem(adapterPosition)?.toObject(UserRelation::class.java)
and I would like to delete this item from my RecyclerView. I searched and couldn't find any method that would do that, I can't get the reference to list that contains loaded items. The only thing I can think of is setting the view visibility to GONE when user selects the item.
for realtime update, you can use FirestoreRecyclerAdapter
FirestoreRecyclerAdapter — binds a Query to a RecyclerView and
responds to all real-time events included items being added, removed,
moved, or changed. Best used with small result sets since all results
are loaded at once
Documentation

Load Infinite View in Recycler View

I am using The Movie Database Api to load Tv Shows in my recyclerview. I am able to load the views in my recycler view. The url i am using is https://api.themoviedb.org/3/tv/airing_today?api_key=MY_API_KEY&page=1
It loads all the views from page 1 in my recyclerview. What i want is as soon as user reaches end of recyclerview it should load the next page and so on i.e at the end of recycler view i want to load https://api.themoviedb.org/3/tv/airing_today?api_key=MY_API_KEY&page=2
I know i can do it by adding next and previous button below my recyclerview,but i don't want to do that approach. How to automatically load next page as soon as user reaches end of recycler view. FYI,I am using Retrofit. Please help.

RecyclerView deleting item doesn't call OnScrollListener

There seems to be a lot of post on how one can scroll up for more posts and I have posted a question on this before: Adding items to Endless Scroll RecyclerView with ProgressBar at bottom
However, I have a question on deleting items in a list on recyclerview.
You have an android app which fetches 5 items from the database server in a page.
As soon as it fetches it, you start deleting items one by one.
The list recyclerview scrolls up but the OnScrollListener is not called as you haven't really "scrolled".
How do I address this problem when I want to add on more items to my list as my delete start eliminating items from the top?
when deleting each item call
recyclerView.smoothScrollToPosition(0);
it works perfectly

Unable to update the listView in Android

I have a ListView which displays 5 listitems. When the user selects the last item (5th item), a hit goes to server and the next set of 5 items is displayed.
I have implemented the code for displaying the first 5 items. I am also able to fetch the next set of items from the server, but the items are not updated in the ListView.
If required I can share the sample code.
Kindly provide hints/sample source code.
Did you try clearing the list items first and then update the list elements?
In order to commit the updates you should call notifyDataSetChanged() ..

Categories

Resources