android-architecture-components

Deep linking from Notification - how to pass data back up through the backstack?

北战南征 提交于 2020-07-09 03:09:19
问题 In my app, the user can select a category, then select an item within that category to finally view the item details. The standard/forward flow is: SelectCategoryFragment -> SelectItemFragment -> ViewItemDetailsFragment On selecting a category, the selectedCatId is passed via a Bundle from SelectCategoryFragment to SelectItemFragment : NavController navController = Navigation.findNavController(v); Bundle args = new Bundle(); args.putLong(SelectItemFragment.ARG_CATEGORY_ID, selectedCatId);

how to get the first or (any) element from a LiveData List in Android MVVM architecture?

北慕城南 提交于 2020-07-05 12:27:09
问题 I used MVVM architecture to build an Android application with a Repository as a mediation between the ViewModel and Room database. In one of the functions, I retrieve a list of objects from a table in the repository class so that I can call it from the ViewModel class. how to retrieve the first element in the list from the repository class instead of observing the LiveData in any one of the activities? here is my repository class: public class StudentRepository { private StudentDAO

how to get the first or (any) element from a LiveData List in Android MVVM architecture?

淺唱寂寞╮ 提交于 2020-07-05 12:27:07
问题 I used MVVM architecture to build an Android application with a Repository as a mediation between the ViewModel and Room database. In one of the functions, I retrieve a list of objects from a table in the repository class so that I can call it from the ViewModel class. how to retrieve the first element in the list from the repository class instead of observing the LiveData in any one of the activities? here is my repository class: public class StudentRepository { private StudentDAO

Paging library - Boundary callback for network + db with API taking page and size

感情迁移 提交于 2020-07-04 07:23:01
问题 Short question : What is the correct way to handle database + network on the Paging library from Architecture components, using an API that uses page + size to load a new page and the BoundaryCallback class? Research and explanation Currently the class BoundaryCallback used in the paging library for architecture components, receives as parameter the instance of an element in the list without actual context of where this element is at. It happens in onItemAtFrontLoaded and onItemAtEndLoaded .

Paging library - Boundary callback for network + db with API taking page and size

心不动则不痛 提交于 2020-07-04 07:21:33
问题 Short question : What is the correct way to handle database + network on the Paging library from Architecture components, using an API that uses page + size to load a new page and the BoundaryCallback class? Research and explanation Currently the class BoundaryCallback used in the paging library for architecture components, receives as parameter the instance of an element in the list without actual context of where this element is at. It happens in onItemAtFrontLoaded and onItemAtEndLoaded .

Is it a good practice to observeForever in Repository class? db+network paged list

泪湿孤枕 提交于 2020-06-26 03:23:31
问题 Im building an app following architecture guidelines.Implemented room db caching + network.Need to get latest page number from separate entity. My model: @Entity(tableName = "top_rated_movie_page") public class Top_Rated_Movies_Page { @PrimaryKey(autoGenerate = true) private int db_id; private Integer page; private Integer total_results; private Integer total_pages; @Ignore private List<Result> results; ... Result class contains data which i display in my paged list which observes changes

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

Architecture Components Retrofit and RxJava 2 error handling

断了今生、忘了曾经 提交于 2020-06-24 14:09:09
问题 I am currently trying to implement the new ViewModels in the architecture components with an API request from retrofit and Okhttp, everything is working but I can't figure out how to pass an error response from retrofit to LiveDataReactiveStreams.fromPublisher and then upstream to the observer in the fragment. This is what I have so far: public class ShowListViewModel extends AndroidViewModel { private final ClientAdapter clientAdapter; private LiveData<List<Show>> shows; public

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState caused by launchFragmentInContainer

六月ゝ 毕业季﹏ 提交于 2020-06-12 05:39:26
问题 I am trying to test the app workflow. The navigation component has been used to define the app workflow. Have used FragmentScenario for testing the navigation from one fragment to another based on this reference(https://developer.android.com/guide/navigation/navigation-testing). Have added the following dependency in build.gradle debugImplementation("androidx.fragment:fragment-testing:1.1.0-beta01") { exclude group: 'androidx.test', module: 'core' } for accessing the api

ViewModel in Kotlin: Unresolved Reference

故事扮演 提交于 2020-05-23 07:46:10
问题 I am trying to implement ViewModel in a 100% Kotlin app. Every piece of documentation I can find says I want to use this to get the ViewModel instance: ViewModelProviders.of(this).get(CustomViewModel::class.java) According to the docs, I should be able to import this with: import android.arch.lifecycle.ViewModelProviders This import is unresolved though. I am using the following in my build file: def androidArchVersion = '1.1.1' implementation "android.arch.lifecycle:viewmodel: