android-architecture-components

Refactoring google's NetworkBoundResource class to use RxJava instead of LiveData

孤者浪人 提交于 2020-03-17 07:33:47
问题 Google's android architecture components tutorial here has a part that explains how to abstract the logic of getting data over the network. In it, they create an abstract class called NetworkBoundResource using LiveData to create a reactive stream as the basis for all reactive network requests. public abstract class NetworkBoundResource<ResultType, RequestType> { private final AppExecutors appExecutors; private final MediatorLiveData<Resource<ResultType>> result = new MediatorLiveData<>();

how to use Architecture Components ViewModel inside RecyclerView Adapter?

南笙酒味 提交于 2020-03-17 06:44:57
问题 I have multiple ViewHolders that work as separated views inside vertical RecyclerView. I'm practicing with the new Architecture Components ViewModel. inside my ViewModel I have a couple of MutableLiveData lists that i want to observe. but how can i call the ViewModelProviders.of((AppCompatActivity)getActivity()).get(FilterViewModel.class) and mFilterViewModel.getCountries().observe(this, new Observer<ArrayList<TagModel>>() { @Override public void onChanged(@Nullable ArrayList<TagModel>

how to use Architecture Components ViewModel inside RecyclerView Adapter?

可紊 提交于 2020-03-17 06:43:00
问题 I have multiple ViewHolders that work as separated views inside vertical RecyclerView. I'm practicing with the new Architecture Components ViewModel. inside my ViewModel I have a couple of MutableLiveData lists that i want to observe. but how can i call the ViewModelProviders.of((AppCompatActivity)getActivity()).get(FilterViewModel.class) and mFilterViewModel.getCountries().observe(this, new Observer<ArrayList<TagModel>>() { @Override public void onChanged(@Nullable ArrayList<TagModel>

Set toolbar title dynamically using navigation-component

只愿长相守 提交于 2020-03-16 05:41:30
问题 I'm trying to set the toolbar title dynamically, I don't know if it's possible or not. Assume I have list of items every item I clicked it's open new fragment, thus I trying to change toolbar title for each item dynamically. I tried : it.findNavController().navigate(direction) it.findNavController().currentDestination!!.label = someTitle But it doesn't work. There are some related topics i.e: How to set title in app bar with Navigation Architecture Component But it doesn't solve my problem

NavController no current navigation node after device rotation

只谈情不闲聊 提交于 2020-02-28 06:59:47
问题 I am making app, which supports different device orientations. Navigation is carried out by Android Jetpack's Navigation. App main screen for landscape orientation is present below. It is list wrapper fragment (it is NavHostFragment , it is added to activity's layout in fragment tag), wrapper includes list fragment ( fragment ) and details fragment ( FrameLayout ). Portrait orientation is similar (wrapper and list in it, details is accessible throw navigation). My problem is after I change

Unclude fragment from Backstack using Navigation component

我的未来我决定 提交于 2020-02-25 07:00:47
问题 I have Fragments X, A, B, and i'm using Navigation architecture component to navigate between them. Fragments A, B specific, but Fragment X can be any(C,D,...); Fragments A and B from Bottom Navigation and their "navigations icons" always on the screen, it means user can go to A or B anytime from any Fragment(include A and B): X -> A -> B X -> B -> A A -> B -> X A -> B -> A //another ways My problem about this case: X -> A -> B -> A -> B -> ? If user started from X , reached ? and begin to go

Communication between view and ViewModel in MVVM with LiveData

送分小仙女□ 提交于 2020-02-23 15:58:25
问题 What is a proper way to communicate between the ViewModel and the View , Google architecture components give use LiveData in which the view subscribes to the changes and update itself accordingly, but this communication not suitable for single events, for example show message, show progress, hide progress etc. There are some hacks like SingleLiveEvent in Googles example but it work only for 1 observer. Some developers using EventBus but i think it can quickly get out of control when the

What is the difference between 3 APKs generated from flutter?

ε祈祈猫儿з 提交于 2020-02-07 02:36:21
问题 I need to understand the Android device architecture and, Why there is three different types of APKs are generated when I use: flutter build apk --split-per-abi . And when I use flutter build apk I get a large APK file called fat APK contains the 3 versions of the app. 回答1: flutter build apk gives you large apk because, flutter build apk results in a fat APK that contains your code compiled for all the target ABIs. Such APKs are larger in size than their split counterparts, causing the user

BottomAppBar with BottomNavigationDrawer connected to NavigationController

≡放荡痞女 提交于 2020-01-31 18:31:28
问题 Hi I'm trying to use new arch components in my project. Short description what I want to achive: When user is on MainFragment I want to display navigation icon (Hamburger) on BottomAppBar. User is able to click navigation icon and display BottomNavigationDrawer When user select some menu item, or click something on MainFragment he is moved to another fragment, let say DebtDetailsFragment . Then Hamburger should be replaced with 'Back arrow' by NavigationController Below I pasted my

is observeForever lifecycle aware?

最后都变了- 提交于 2020-01-25 10:21:27
问题 I'm working with MVVM, and I have made different implementations of it, but one thing that is still making me doubt is how do I get data from a Repository (Firebase) from my ViewModel without attaching any lifecycle to the ViewModel. I have implemented observeForever() from the ViewModel, but I don't think that is a good idea because I think I should communicate from my repository to my ViewModel either with a callback or a Transformation. I leave here an example where I fetch a device from