android


Is there any way can let greenDAO support android data-binding now?


When you use greenDAO library, you need to use greendao-generator to generate relevant POJO and XXXDAO, DAOSession, DAOMaster class. Just like this POJO class here: Note.java
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
/**
* Entity mapped to table "NOTE".
*/
public class Note {
private Long id;
/** Not-null value. */
private String text;
private String comment;
private java.util.Date date;
public Note() {
}
public Note(Long id) {
this.id = id;
}
public Note(Long id, String text, String comment, java.util.Date date) {
this.id = id;
this.text = text;
this.comment = comment;
this.date = date;
}
// Getter and setter...
}
And each time you change your model, this code need to be regenerated.
Android data-binding can be used by giving your data objects the ability to notify when data changes.But before that, you need to modify your POJO class.There are different data change notification mechanisms: Data Objects
1.implementing the Observable interface, assigning a Bindable annotation and call notifyPropertyChanged() method in setter.
private static class User extends BaseObservable {
private String firstName;
private String lastName;
#Bindable
public String getFirstName() {
return this.firstName;
}
#Bindable
public String getLastName() {
return this.lastName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
notifyPropertyChanged(BR.firstName);
}
public void setLastName(String lastName) {
this.lastName = lastName;
notifyPropertyChanged(BR.lastName);
}
}
2.Use ObservableFields or Observable Collections:
private static class User {
public final ObservableField<String> firstName =
new ObservableField<>();
public final ObservableField<String> lastName =
new ObservableField<>();
public final ObservableInt age = new ObservableInt();
}
So, if we want to use greenDAO and Android data-binding together, we need to modify the automatically generated file manually? I believe this is a very large amount of work if your project is large. Or Is there any elegant way can let greenDAO support android data-binding now?
Looking forward to your reply! Thanks!

Related Links

Android PrintServer crashes when pressing print button while rendering preview
Android: Action button icons always appear in overlay
Espresso click on every element with a certain id
setRetainInstance(true) not saving variables on configuration change in API 19
Can't Open Android Device Monitor - Reinstall?
Not able to recieve message after BIND_LISTENER deprecated
Retrofit2 Upload a video and fields
How to display two images side by side in multiple screen size?
Switch within a loop cannot execute twice
Android: Replace fragment while asynctask running fails
some files missed in my android app but how i should put them
Error during uploading image to amazon server
When the outgoing call is forwarded to somewhere else no audio is coming in PJSUA2 android
Digest Authorization in android http request
Sqlite Database onupgrade() not updating database
Ensure that the “Google Maps Android API v2” is enabled. I am getting this error when I try to Implement Google Maps

Categories

HOME
localization
facebook-oauth
turing-machines
jpa
ns-3
pclxl
babeljs
interpolation
enthought
plist
mautic
flatpak
vuejs
production
googlebot
systemtime
expressionengine3
google-cloud-print
maze
delimiter
mat
tizen-tv
constexpr
gitlab-api
mobx
wacom
github3.py
reactjs.net
jwplayer6
sql-delete
latitude-longitude
playframework-2.1
c9.io
comparison-operators
ogc
trigonometry
placeholder
httrack
builder
clarifai
spring-integration-sftp
mongotemplate
appdomain
modelsim
monkey
flyout
cmp
sandcastle
taocp
custom-lists
builtins
envi
jclouds
respondcms
riot
nss
uiactionsheet
cortex-m
nullable
thread-sleep
nio2
qbxml
avisynth
flock
pyobjc
telepat
dot.js
exceldatareader
android-cookiemanager
pseudo-class
structuremap3
rmysql
lnk
ray
ios8-extension
fpdi
dtmf
hidapi
cnf
diem
windows-98
panda3d
correlated-subquery
listactivity
msr
ajax-polling
pos-for-.net
burndowncharts
murmurhash
idatareader

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App