Giter Site home page Giter Site logo

jakubkinst / android-viewmodelbinding Goto Github PK

View Code? Open in Web Editor NEW
295.0 295.0 32.0 569 KB

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.

Java 88.35% FreeMarker 11.65%
android architecture binding mvvm viewmodel

android-viewmodelbinding's People

Contributors

arthufimtcev avatar helmisek avatar jakubkinst avatar ravidsrk avatar stepansanda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-viewmodelbinding's Issues

Remove startActivityForResult() from BaseViewModel

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?

Usage with Fragment? Enhancement tips.

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

Provide API for making navigation via ViewInterface

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?

Remove UI-related methods from ViewModel.java

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.

Compatibility with Dagger2

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

Sample app crash on rotation

Steps to reproduce:

  1. Run the app
  2. Rotate device
 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)

Data binding with library

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 

RxJava2 support Views

Please add ViewModelFragment from RxFragment and ViewModelActivity from RxAppCompactActivity (RxActivity). Thanks for your support. You can use RxLifecycle library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.