android-paging-library

Dagger2: Using CompositeDisposable with Android Paging Library

。_饼干妹妹 提交于 2021-02-11 14:18:04
问题 I'm using Dagger2. I will be injecting CompositeDisposable in ViewModel through @Inject constructor(private val compositeDisposable: CompositeDisposable) And my screen would also be using Android Pagination library and inside PageKeyedDataSource class I would be adding every network call into compositeDisposable using it's .add(diposable) . I also would be adding CompositeDisposable in PageKeyedDataSource constructor through Dagger graph. Is there any way that CompositeDisposable in ViewModel

onRestoreInstanceState not working for RecyclerView layout manager if using Paging 3 library

纵饮孤独 提交于 2021-01-28 09:11:51
问题 I had a problem in saving RecyclerView state and it solved by saving layout manager state and using it after resume fragment.(thanks to @HarisDautović) class TestFragment : Fragment() { private val testListAdapter: TestListAdapter by lazy { TestListAdapter() } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { return inflater.inflate(R.layout.fragment_test, container, false) } override fun onViewCreated(view: View,

Paging3: “Not sure how to convert a Cursor to this method's return type” when using PagingSource as return type in Room DAO

对着背影说爱祢 提交于 2020-12-05 07:28:29
问题 I was trying to imitate Google's codelab for the new Paging 3 library, and I encountered the following error when I tried to have a Room DAO method return a PagingSource : D:\Programming\Android\something\app\build\tmp\kapt3\stubs\debug\com\someapp\something\data\db\UsersDao.java:38: error: Not sure how to convert a Cursor to this method's return type (androidx.paging.PagingSource<java.lang.Integer,com.someapp.something.data.db.GithubUser>). public abstract androidx.paging.PagingSource<java

Updating a single item in a recylerview. I am using paging library and would like to update a single item/row

馋奶兔 提交于 2020-06-25 06:49:30
问题 I am passing pagedlist values to adapter using submit list. when i update a single item consider i am clicking a like button of a feed in a recyclerview. how to update the single item. i am following this example for paging implementation https://github.com/saquib3705/PagingLibrarySampleApp which just loads data and update the recyclerview. I would like to add like button for the items and update the list when user liked how to achieve it. Also look at this which is what i m exactly looking

LiveData Paged List size is always 0

偶尔善良 提交于 2020-05-27 06:16:05
问题 I implemented Paging using android paging library. The ViewModel returns a LiveData<PagedList<MyObject>> and I observe that in the fragment where I set the adapter and everything is working good, except that when I want to check the size of the list is always 0. viewModel.getSearchResults().observe(this, mList -> { adapter.submitList(mList); Log.e("Count", String.valueOf(mList.size())); }); Where mList is a PagedList<MyObject> 回答1: If you look at Loading Data from PagedList documentation you

LiveData Paged List size is always 0

…衆ロ難τιáo~ 提交于 2020-05-27 06:15:59
问题 I implemented Paging using android paging library. The ViewModel returns a LiveData<PagedList<MyObject>> and I observe that in the fragment where I set the adapter and everything is working good, except that when I want to check the size of the list is always 0. viewModel.getSearchResults().observe(this, mList -> { adapter.submitList(mList); Log.e("Count", String.valueOf(mList.size())); }); Where mList is a PagedList<MyObject> 回答1: If you look at Loading Data from PagedList documentation you

LiveData Paged List size is always 0

梦想的初衷 提交于 2020-05-27 06:15:10
问题 I implemented Paging using android paging library. The ViewModel returns a LiveData<PagedList<MyObject>> and I observe that in the fragment where I set the adapter and everything is working good, except that when I want to check the size of the list is always 0. viewModel.getSearchResults().observe(this, mList -> { adapter.submitList(mList); Log.e("Count", String.valueOf(mList.size())); }); Where mList is a PagedList<MyObject> 回答1: If you look at Loading Data from PagedList documentation you

Invalidating custom PageKeyedDataSource makes recycler view jump

坚强是说给别人听的谎言 提交于 2020-04-18 05:35:30
问题 I am trying to implement an android paging library with custom PageKeyedDataSource, This data source will query the data from Database and insert Ads randomly on that page. I implemented the paging, but whenever I scroll past the second page and invalidate the data source, the recycler view jumps back to the end of the second page. What is the reason for this? DataSource: class ColorsDataSource( private val colorsRepository: ColorsRepository ) : PageKeyedDataSource<Int, ColorEntity>() {

How to clear/remove all items in page list adapter

耗尽温柔 提交于 2019-12-11 03:18:53
问题 I'm using the android paging library to show search result items, is there any way I can clear/remove all the loaded result items, Calling Invalidate on live Paged List refreshing the list not clear/remove items In Activity: fun clearSearchResult() { if (productSearchResultItemAdapter.itemCount > 0) { viewModel.invalidateResultList() } } In ViewModel private fun searchProductByTerm(searchTerm: String): Listing<Item> { sourceFactory = ProductSearchItemDataSourceFactory(productSearchUC,