android-paging

How to maintain same DataSource for List,Filter and Search in Android Paging Library

喜夏-厌秋 提交于 2019-12-08 07:45:03
问题 I am having activity that displays list of items and also having filter and search option. I am displaying the items using android paging library. First time the List of items will be loaded its working fine when I am Scrolling to bottom next set of items getting loaded. But I also want to filter the items and Search the items. On Filtering or Searching item I am invalidating the existing source.if am not invalidate the Data Source the filter and Search api is not firing.I want to load list

Android Paging Library LiveData<PagedList<T>> is triggered before the end of the api call

a 夏天 提交于 2019-12-06 10:21:33
问题 It's been 2 days I'm trying to learn how to use the new Paging Library with the Kotlin Language (first time too) So I've read many guide / tutorial and Github repo (https://github.com/STAR-ZERO/paging-retrofit-sample) for implementing this paging library and basically my trouble is my LiveData<PagedList<Discover>> inside my ViewModel is trigger before my api call is ending and I don't know why and I feel the call callback.onResult(it?.results.orEmpty(), null, 2) doesn't do anything I'm using

Paging Library without Room

人盡茶涼 提交于 2019-12-05 02:53:20
All examples of the new paging library have been with Room library and Room creates a Data Source for us. In my own case, I need to create my custom data source. Here is a method in my view model class that ought to return the live data. My livedata always returns null. LiveData<PagedList<ApiResult>> getData(){ LivePagedListProvider<Integer,ApiResult> p = new LivePagedListProvider<Integer, ApiResult>() { @Override protected DataSource<Integer, ApiResult> createDataSource() { return new DataClass(); } }; listLiveData = p.create(0,new PagedList.Config.Builder() .setPageSize(5) //number of items

Update list items in PagingLibrary w/o using Room (Network only)

妖精的绣舞 提交于 2019-12-05 00:09:50
问题 I'm using Paging Library to load data from network using ItemKeyedDataSource . After fetching items user can edit them, this updates are done inside in Memory cache (no database like Room is used). Now since the PagedList itself cannot be updated (discussed here) I have to recreate PagedList and pass it to the PagedListAdapter . The update itself is no problem but after updating the recyclerView with the new PagedList , the list jumps to the beginning of the list destroying previous scroll

How to add date separators in recycler view using Paging Library?

橙三吉。 提交于 2019-12-03 06:45:36
After a lot of searching, I know its possible with regular adapter, but I have no idea how to do it using Paging Library. I don`t need code just a clue. Example To add separators, you essentially have 2 options: View-based, you explicitly include separators as an 'item' in the list and define a new viewtype for those separators. Allows the list to re-use the separator views but means you need to take the separators into account when defining the data. Data-based, each item actually has a separator view, but it only shows on specific items. Based on some criteria you show or hide it whilst

PageKeyedDataSource loadAfter doesnt get fire

血红的双手。 提交于 2019-12-02 01:30:46
In my fragment, I integrated android jetpack paging library and the data source I using PageKeyedDataSource with retrofit API callback. the code runs as excepted and loads the data to recyclerview but after I scroll to the bottom, it supposed to load more data by firing loadAfter function in data source class but it didn't I also switched to ItemKeyedDataSource still it fails to execute is my code wrong or the plugin have an issue! but in some demo apps which I found in GitHub works perfectly I followed there code. please if anyone had this problem and fixed let me know Edit: Using AndroidX

AdMob Ads in an endless RecyclerView with Paging library

白昼怎懂夜的黑 提交于 2019-12-01 22:18:33
I am using paging library to fetch data from server, I was thinking of showing Ad after every 10 items. So as the user scrolls down and new items are fetched and added to PagedList. I want the new Ad to be loaded and added in RecyclerView as well just like Instagram shows ads in feeds. So if the user scrolls to 200 items, 20 ads will be shown gradually!!. I have read a couple of tutorials but I haven't figured an easy way to do it. Here is my adapter. class RequestsPagedAdapter( private val retryCallback: () -> Unit, private val from: From) : PagedListAdapter<RequestsQuery.Request,

AdMob Ads in an endless RecyclerView with Paging library

戏子无情 提交于 2019-12-01 22:08:04
问题 I am using paging library to fetch data from server, I was thinking of showing Ad after every 10 items. So as the user scrolls down and new items are fetched and added to PagedList. I want the new Ad to be loaded and added in RecyclerView as well just like Instagram shows ads in feeds. So if the user scrolls to 200 items, 20 ads will be shown gradually!!. I have read a couple of tutorials but I haven't figured an easy way to do it. Here is my adapter. class RequestsPagedAdapter( private val

How does Android Paging Library know to load more data?

て烟熏妆下的殇ゞ 提交于 2019-11-30 17:52:55
Iʼm fairly new to developing Android apps and Iʼm trying to do everything “the right way.” So right now, Iʼm implementing the new Android Paging Library into my project, where I need to load a list of articles from a network server. I have an ArticlesRepository class that returns an ArticleList class containing instances of ArticleListItem that I would like to display in a RecyclerView. The list of articles is paginated already on the server, so the repository sends a request for the first page and returns an ArticleList with the page property set to 1 and the articles property containing a

Paging Library Filter/Search

我们两清 提交于 2019-11-30 10:24:24
问题 I am using the Android Paging Library like described here: https://developer.android.com/topic/libraries/architecture/paging.html But i also have an EditText for searching Users by Name. How can i filter the results from the Paging library to display only matching Users? 回答1: EDIT from 2019: hold on, I think you might be able to solve this with a MediatorLiveData. Specifically Transformations.switchMap and some additional magic. Currently I was using public void reloadTasks() { if(liveResults