jakubkinst / android-viewmodelbinding Goto Github PK
View Code? Open in Web Editor NEWA lightweight library aiming to speed up Android app development by leveraging the new Android Data Binding together with the Model-View-ViewModel design pattern.
A lightweight library aiming to speed up Android app development by leveraging the new Android Data Binding together with the Model-View-ViewModel design pattern.
I believe this functionality should be resolved outside of this library. There is a lot of options for starting activity with/without result, on Activity, on Fragment, with Bundle, without Bundle etc. We should either implement all of these options or none. I vote for removing this and leaving users to handle this on their own. What do you think @stepansanda?
I like to use these VM, but there is some use cases where it is hard to use IT.
For example:
Activity -> Fragment -> VM -> ViewPager
If i want to have Fragments in ViewPager i have to use childFragmentManager(), it is accessible from Fragment, but not from VM. Also if i have VM i could get parent activity, but not parent Fragment. When i got tablet application, i would use fragments. Of course i want to use arguments for fragments. But i cannot obtain them from VM directly, especialy in onViewAttached, where I should. How to deal with this problems? Will it be fixed?
Another Enhancement question:
Why is BaseActivity extends AppCompatActivity, but BaseViewModel getActivity() returns Activity?
I am not fully familiar with pull request, so that is the reason why i write here, instead of code.
Thanks
Hi Jakub!
After some research of your lib, i realized that navigation between screens is not very handy when it done from viewModel (especially when navigation step contains transitions/animations, better to leave this stuff inside activity/fragment). It would be nice to have ability to navigate via ViewInterface. Something like ViewInterface.navigate(params)
. And then implement navigate method in the Activity/Fragment/Dialog etc.
Please take a look on this proof of concept
mykola-dev@79e66df
Is it worth of pull request?
I suggest to remove getRootView() from ViewModel.java. This method is UI-related so it should belong to View and not ViewModel. I think that ViewModel shouldn't contain any android.view, android.widget imports and rather stay POJO-like object. This ViewModel base class tends to mix business logic with UI logic which breaks MVVM architecture.
When i trying to inject some fields into viewModel with Dagger2, it fails, because apt compiler cannot find ActivityMainBinding (generated binding class). Same issue when injecting into Activity, because it extends class with generic type that has no exist yet at APT compile stage.
PS: i use Kotlin 1.0, but this issue also should be reproduceable in plain Java
example, that failed to compile
mykola-dev@e9417c5
Steps to reproduce:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
at cz.kinst.jakub.viewmodelbinding.ViewModelBindingHelper.getViewModelIdFieldName(ViewModelBindingHelper.java:215)
at cz.kinst.jakub.viewmodelbinding.ViewModelBindingHelper.onCreate(ViewModelBindingHelper.java:72)
at cz.kinst.jakub.viewmodelbinding.ViewModelActivity.onCreate(ViewModelActivity.java:70)
Hey developers, How can I use data binding in my application because I am new to data binding concept ?
I have an application module and one android lib. Module which has all the entites those are used in app module l..
So how can I use data binding in my app with lib. Module..
Which also include dynamic inflation of view based on parameter in some of the entities in library module
Please add ViewModelFragment from RxFragment and ViewModelActivity from RxAppCompactActivity (RxActivity). Thanks for your support. You can use RxLifecycle library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.