android-paging

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

佐手、 提交于 2020-01-01 02:46:10
问题 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 回答1: 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

Paging Library without Room

旧巷老猫 提交于 2019-12-22 04:00:57
问题 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

Paging library DataSource.Factory for multiple data sources android

我只是一个虾纸丫 提交于 2019-12-21 05:34:05
问题 I have multiple data sources. But there is only one DataSourceFactory. So, all sources is sharing one factory. I need one DataSourceFactory per data source. In my app, I have multiple views with RecyclerViews and hence multiple custom data sources. So, do you end up creating multiple implementations of DataSource.Factory per data source or is there a more generic solution? Edited I found the solution in my case. In my previous version, I used only one Datasource Factory for all datasources.

How does Android Paging Library know to load more data?

走远了吗. 提交于 2019-12-18 20:29:11
问题 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

Android paging library + Firestore crashes with IllegalStateException

折月煮酒 提交于 2019-12-13 04:01:19
问题 I trying to implement the new Android paging library using Firestore as my backend. I have created a class MyDataSource that extends PageKeyedDataSource<Integer, MyObject> , where I'm implementing three functions: loadInitial loadBefore loadAfter For example one of the functions is this: @Override public void loadInitial(@NonNull LoadInitialParams<Integer> params, @NonNull final LoadInitialCallback<Integer, MyObject> callback) { query.addSnapshotListener((snapshots, exception) -> { if

PageKeyedDataSource loadAfter doesnt get fire

醉酒当歌 提交于 2019-12-12 21:49:56
问题 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

How do I create a PagedList of an object for tests?

戏子无情 提交于 2019-12-12 07:47:40
问题 I have been working with the arch libraries from Google, but one thing that has made testing difficult is working with PagedList . For this example, I am using the repository pattern and returning details from either an API or network. So within the ViewModel I make a call to this interface method: override fun getFoos(): Observable<PagedList<Foo>> The Repository will then use RxPagedListBuilder to create the Observable that is of type PagedList: override fun getFoos(): Observable<PagedList

Paging Library and Room with different PagedLists that depends of different requests

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 07:58:32
问题 I am trying to set up all my lists using new Android Architecture Components: Room Persistance Library and Paging Library. But I am facing the following problem. Imagine an app that has a lots of diferents lists of the same model. Each list has his own url request to server. Some elements can be repeated in diferent responses. So I think that I have to insert and update all elements of each response to a table of that model. Furthermore, each request has pages. For example, elements/famous/0

PagedListAdapter does not update list if just the content of an item changes

别等时光非礼了梦想. 提交于 2019-12-11 02:39:14
问题 I'm using the Room and Paging libraries to display categories. My Entity: @Entity(tableName = Database.Table.CATEGORIES) data class Category( @PrimaryKey(autoGenerate = true) @ColumnInfo(name = ID) var id: Long = 0, @ColumnInfo(name = NAME) var name: String = "", @ColumnInfo(name = ICON_ID) var iconId: Int = 0, @ColumnInfo(name = COLOR) @ColorInt var color: Int = DEFAULT_COLOR ) My DAO: @Query("SELECT * FROM $CATEGORIES") fun getPagedCategories(): DataSource.Factory<Int, Category> @Update fun

Failing to load next data with android Paging library

随声附和 提交于 2019-12-10 17:19:33
问题 I am trying to show call log list using Room-Paging-LiveData-ViewModel. Without paging my code works perfectly. And I want to use paging also. In my database I have total 25 call log record. The first 9 call log is showing in the list. By debugging I found that while reading data in view model via Dao , it is returning list of size 25. But only first 9 of these are non null. All other entries in the list is null. I am expecting the null data will refresh soon as this is a paged list. But the