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

Colorize a greyscale texture in OpenGL ES on Android
How to stop loading data again while using intent to navigate activity?
How to notifi when new activity is started?
Android: How to read the entire stacktrace from LogCat (including the ..X more errors)?
Best way to write database layer(mysql) in restful webservice?
Handle the data from SQLite/Android
Around me application in android [closed]
Android Opengles CameraPreview (Draw text on camera feed)
Click to scroll in Horizontal Scroll View
Android Intent action/reciever help please
HttpHostConnection Exception
voice recognition in android for send email
Google IO Rest design pattern, Finished ContentProvider and stuck now
The recommended way to register a new user for my android application
Android Background: Image placement with a color
Publish custom application on android market

Categories

HOME
phpword
fuelux
wakanda
pascal
alarm
cq5
limit
android-json
spin
okhttp
arangodb
g++
openstreetmap
resultset
mautic
php-5.6
event-sourcing
package.json
fileserver
red5
oledb
replication
undertow
dpdk
imageresizer
jquery-callback
nstimer
subclass
custom-controls
zend-debugger
paragraph
playstation-portable
login-script
dynamic-jasper
html-encode
browser-extension
mnist
servicestack-text
google-knowledge-graph
watchman
odroid
verifiable-c
cin
kill
comparison-operators
skylink
softmax
preloader
http-request
ovf
reportservice2010
dtsearch
tinymce-3
podscms
git-flow
jqchart
dt
otp
rmongo
chromium-os
cubism.js
reporting-services-2012
vulcanize
dup
php-socket
upx
oracle-spatial
canvg
phpldapadmin
cross-join
primitive-types
device-tree
angular-carousel
tinyxml
jquery-slider
terminate
sbcl
multitasking
breakout
script#
poker
abstract-data-type
insert-id
pdfviewer
josql
apache-whirr
predicatebuilder
luabind
filemerge
mysql-error-1205
lr
entitydatasource
cdonts
appledoc
dot-emacs
blender-2.49
request-headers
data-mapping
scrubyt
perl5.12
soappy
appliance
great-circle

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