android-architecture-components

BottomNavView remains hidden onNavigation between Fragments

痞子三分冷 提交于 2020-05-17 07:11:39
问题 Prior to this question, i implemented the HideBottomViewOnScrollBehaviour to the BottomNavVew , and onDestinationChangedListener in each fragment to control the visiblity of the BottomNavView Bug : when i scroll-down and the BottomNavView collapse/hide in FragmentA and i try navigating to the FragmentB , the BottomNavView remains hidden, but if i scroll-up justt for the BNV to re-appear and try switching to the same fragment, the BNV becomes visible, can anyone help with an explanation...?

Cannot resolve ViewModelProvider construction in a fragment?

蹲街弑〆低调 提交于 2020-05-13 06:09:27
问题 I have been spending a lot of time trying to figure out why in the code below (towards the end), I get an error on ViewModelProvider(this). I also tried getActivity() instead of 'this', same issue. The error I get is "Cannot resolve constructor ..." import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; public class ItemSetupFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

Cannot resolve ViewModelProvider construction in a fragment?

浪尽此生 提交于 2020-05-13 06:08:07
问题 I have been spending a lot of time trying to figure out why in the code below (towards the end), I get an error on ViewModelProvider(this). I also tried getActivity() instead of 'this', same issue. The error I get is "Cannot resolve constructor ..." import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; public class ItemSetupFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

Map LiveData<PagedList<X>> to LiveData<PagedList<Y>>

久未见 提交于 2020-05-10 07:12:35
问题 I need to map domain objects to UI objects and display using a live paged list. I have tried to map LiveData<PagedList<X>> to LiveData<PagedList<Y>> , and map PositionalDataSource<X> to PositionalDataSource<Y> , but due to package private and private restrictions these both appear to be impossible without placing my code in android.arch.paging package and using reflection, or using a modified version of the paging lib. Does anyone know of a way to do this without resorting to such undesirable

How to remove an item from PagedListAdapter in Android Paging Component

情到浓时终转凉″ 提交于 2020-05-10 04:06:24
问题 I used Paging with Retrofit to loading list of Notifications data from REST API. When I press delete button of a notification item then I call delete API to remove it. What is the proper way to remove it from PagedListAdapter after delete API response success? PagedList or PagedListAdapter does not support remove the item by index or object. I tried to call DataSource.validate() but it reloads from begin, not from the current page. 回答1: According to the official doc: If you have more granular

How to remove an item from PagedListAdapter in Android Paging Component

半世苍凉 提交于 2020-05-10 04:06:20
问题 I used Paging with Retrofit to loading list of Notifications data from REST API. When I press delete button of a notification item then I call delete API to remove it. What is the proper way to remove it from PagedListAdapter after delete API response success? PagedList or PagedListAdapter does not support remove the item by index or object. I tried to call DataSource.validate() but it reloads from begin, not from the current page. 回答1: According to the official doc: If you have more granular

can I send nullable data type as argument using safeargs ? if not what should I do?

南楼画角 提交于 2020-04-30 06:26:25
问题 say I have 2 fragments. Login and Home. I set Home fragment as a global destination that has userData as arguments if the user is not logged in yet, then it will start from login fragment. after login and get userData from server then it will navigate to Home and pass userData using this code val home = AuthenticationFragmentDirections.actionGlobalHomeFragment(userData) Navigation.findNavController(view).navigate(home, navOptions) but the problem is when the user already login and open the

can I send nullable data type as argument using safeargs ? if not what should I do?

 ̄綄美尐妖づ 提交于 2020-04-30 06:25:27
问题 say I have 2 fragments. Login and Home. I set Home fragment as a global destination that has userData as arguments if the user is not logged in yet, then it will start from login fragment. after login and get userData from server then it will navigate to Home and pass userData using this code val home = AuthenticationFragmentDirections.actionGlobalHomeFragment(userData) Navigation.findNavController(view).navigate(home, navOptions) but the problem is when the user already login and open the

ViewModel SavedStateHandler.get for LiveData can't set default value as per the document?

萝らか妹 提交于 2020-04-30 04:31:05
问题 In referring to https://developer.android.com/reference/androidx/lifecycle/SavedStateHandle#getLiveData(java.lang.String,%20T) The sample codes in Java as below. String defaultValue = ...; // nullable LiveData<String> liveData; if (defaultValue != null) { liveData = savedStateHandle.get(KEY, defaultValue); } else { liveData = savedStateHandle.get(KEY); } However, I notice that when tried to compile the code, the statement below is not compilable. savedStateHandle.get(KEY, defaultValue); It

setupWithNavController method for toolbar no longer available?

二次信任 提交于 2020-04-18 05:44:29
问题 so previously I had crash with error: You must call setGraph() before calling getGraph() then after reading the solution frem here. it is said that I have to use these lines on my gradle implementation "androidx.navigation:navigation-fragment:2.3.0-alpha02" implementation "androidx.navigation:navigation-ui:2.3.0-alpha02" and the error is dissapear. but now I no longer can find setupWithNavController method. usually I use this line toolbar.setupWithNavController(navController