alter-ego / androidbound Goto Github PK
View Code? Open in Web Editor NEWTwo-way binding library for Android
License: Apache License 2.0
Two-way binding library for Android
License: Apache License 2.0
It would enable us to use lists with different types of objects, each of which would inflate a different layout.
Should it be called from the activity onCreate() or onPostCreate(), when the activity is already initialized (similar to fragment lifecycle)?
@hamen opinions?
Binder doesn't get called at all in newer support libraries.
by calling viewmodel.dispose(), it will then remove the ViewModel's internal activity reference.
When binding using ValueConverter
- like binding="{Text @= LocalizedFullName(Profile)}"
, the binder still checks types when binding and complains that object Profile
cannot be cast to String
required by the method Text
:
Error occurred while binding Profile to target Text: org.sharethemeal.app.user.models.Friend$FriendProfile cannot be cast to java.lang.String
there's some stuff still missing - for example, Button doesn't have bindable TextColor or Color.
it should be pulled from ViewBinder instance into the interface.
needed examples:
Activities
UI
Binding commands
Custom stuff
That way it will be more in line with RxJava names
currently ValueConverter only interprets parameters inside ''
, which means that
binding="{Text @= LocalizedFullName(Profile.Firstname, 'Profile.Lastname')}"
sees the parameter, but
binding="{Text @= LocalizedFullName(Profile.Firstname, Profile.Lastname)}"
doesn't, which doesn't allow us to bind to objects as parameters.
Evaluate if this could actually be done... and do it.
presumably on all versions 11 < x < 21, it's a bug regarding the support libraries. There's a code in the android.support.v4.view.LayoutInflaterCompatHC that helps.
If the call happens too late - as it does with Android, you can actually have two activities open at the same time - then it will also delete binding of other activities. It should just delete the calling activity's parent view bindings.
should we? can we?
when parsing binding strings likebinding="{SourceUri @= OptimizedImageUrl(Achievement.ImageUrl, '70, 1.0, png, 80, fill')}}"
, that extraneous }
at the end will confuse the parser and he will try to parse the spec which is null
.
here's the (incomplete) stacktrace:
09-06 11:59:37.731: E/AndroidRuntime(17922): FATAL EXCEPTION: main
09-06 11:59:37.731: E/AndroidRuntime(17922): Process: org.sharethemeal.app.android, PID: 17922
09-06 11:59:37.731: E/AndroidRuntime(17922): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
09-06 11:59:37.731: E/AndroidRuntime(17922): at solutions.alterego.androidbound.factories.SourceBindingFactory.create(SourceBindingFactory.java:23)
09-06 11:59:37.731: E/AndroidRuntime(17922): at solutions.alterego.androidbound.binding.BindingAssociationEngine.createTargetBinding(BindingAssociationEngine.java:106)
09-06 11:59:37.731: E/AndroidRuntime(17922): at solutions.alterego.androidbound.binding.BindingAssociationEngine.<init>(BindingAssociationEngine.java:47)
09-06 11:59:37.731: E/AndroidRuntime(17922): at solutions.alterego.androidbound.binding.TextSpecificationBinder.bind(TextSpecificationBinder.java:49)
09-06 11:59:37.731: E/AndroidRuntime(17922): at solutions.alterego.androidbound.ViewBinder.bindViewToSource(ViewBinder.java:197)
09-06 11:59:37.731: E/AndroidRuntime(17922): at solutions.alterego.androidbound.ViewBinder.checkAndBindView(ViewBinder.java:187)
09-06 11:59:37.731: E/AndroidRuntime(17922): at
05-22 15:51:47.779: E/AndroidRuntime(9493): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void rx.subjects.PublishSubject.onCompleted()' on a null object reference
05-22 15:51:47.779: E/AndroidRuntime(9493): at solutions.alterego.androidbound.ViewModel.dispose(ViewModel.java:42)
05-22 15:51:47.779: E/AndroidRuntime(9493): at solutions.alterego.androidbound.android.BindingAppCompatActivity.onDestroy(BindingAppCompatActivity.java:40)
05-22 15:51:47.779: E/AndroidRuntime(9493): at org.sharethemeal.app.core.BaseBindingActivity.onDestroy(BaseBindingActivity.java:137)
some small tasks that should be done:
implements INotifyPropertyChanged
usage - is it necessary?If you try to bind to one of the inherited methods/properties of the object, it won't work. It seems that it doesn't work even if you add the corresponding property getter method to the object.
example:
public class Original {
public DateTime date;
}
public class OriginalChild extends Original {
public DateTime getDate();
}
binding to date
won't work!
needed for TextView.setTextColor(int)
@hamen ?
As it is, it's not useful at all.
we need the following:
If the binding finishes with double }}
the BindingSpecificationParser will call parseMode with null string, and it will then crash:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at solutions.alterego.androidbound.parsers.BindingSpecificationParser.parseMode(BindingSpecificationParser.java:122)
at solutions.alterego.androidbound.parsers.BindingSpecificationParser.parse(BindingSpecificationParser.java:107)
at solutions.alterego.androidbound.parsers.BindingSpecificationParser.parse(BindingSpecificationParser.java:16)
at solutions.alterego.androidbound.parsers.BindingSpecificationListParser.parse(BindingSpecificationListParser.java:52)
at solutions.alterego.androidbound.parsers.BindingSpecificationListParser.parse(BindingSpecificationListParser.java:11)
at solutions.alterego.androidbound.binders.TextSpecificationBinder.bind(TextSpecificationBinder.java:41)
at solutions.alterego.androidbound.android.BindableLayoutInflaterFactory$InflaterFactoryBase.bindView(BindableLayoutInflaterFactory.java:107)
at solutions.alterego.androidbound.android.BindableLayoutInflaterFactory$2.onCreateView(BindableLayoutInflaterFactory.java:64)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:171)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at solutions.alterego.androidbound.ViewBinder.inflate(ViewBinder.java:193)
at solutions.alterego.androidbound.example.MainActivity.onCreate(MainActivity.java:27)
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.