pardom/ActiveAndroid — pull request #9 by zach-klippenstein (2012-12-19 03:53:21+00:00)
Title: Fixed deserialization with TypeSerializers, BLOB/byte[] support, and DataSetObserver

Hi, my name is Zach, and I'm a 4th-year computer science co-op student. This is my first pull request to a public project, so I apologize in advance if I haven't followed the expected etiquette. I think 4 commits might be a bit much for one request, but I hope at least some of this is up to the standards of your project.

65a5ddd is just a format cleanup I noticed while working on the other stuff. The other 3 are more major:

1. fd8a5d4 I was implementing a custom Adapter sourced from a From object, and since CursorAdapters get notified by Cursors when backing data changes, I thought it would be nice to have similar functionality here. This implementation isn't ideal, since changes are only monitored at the table level, but tracking the list of results for each query would require a lot more complexity -- this is fairly simple.

2. 8a747a2 Fixes issue #8. The commit description explains the fix. If existing serializers _were_ working, I'm not sure how. I'm very open to any suggestions on how to fix this in a better way. In particular, I couldn't figure out how to fix it without having TypeSerializers provide the java class of their serialized type, since the class-to-SQLiteType mapping isn't one-to-one (e.g. if SQLiteType is REAL, call getFloat() or getDouble()?). In addition to breaking existing code, another problem with this fix is that there is no compile-time checking that the serialized type is valid. The best alternative I could think of is checking TYPE_MAP.containsValue(typeSerializer.getSerializedType()) when registering TypeSerializers on initialization.

3. 7b2e0c5 Byte arrays are trivially serialized using the SQLite BLOB type, so I added the trivial code for that.

Let me know what you think, I would be happy to implement any suggestions.