Jun 10 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jun 10 | 9:30 AM |
CalvinS | has entered the room |
Justin M. | has entered the room |
Mark M. |
howdy, CalvinS and Justin M!
|
Justin M. |
Hey there Mark :-)
|
Mark M. |
I leave my desk for two minutes, and a crowd rolls in!
|
Justin M. |
Quiet day today?
|
Mark M. |
up until now
|
Justin M. |
I
totally forgot earlier to come on in, I have some stuff to ask you
about database persistence, but I'll wait until CalvinS is done, I
think he got here before I did
|
Mark M. |
yeah, I think he beat you by a few seconds
|
Mark M. |
so, Calvin, do you have a question?
|
CalvinS |
Hi there....Go ahead Justin I'm just being a fly on the wall until I have questions
|
Justin M. |
OK cool, here goes...
|
Justin M. |
So
we're looking at database persistence right now for our app, and I was
thinking I'd be able to do what we're doing in our iPhone app, have
model classes that are the middlemen between the UI and the database...
|
Justin M. |
But
as I've been digging into database persistence on Android, like with
SQLiteOpenHelper, it's seeming like I can't have that kind of
separation since it needs to know about the Context from the Activity...
|
Mark M. |
yeah, Android isn't big on having smart model classes
|
Jun 10 | 9:35 AM |
Mark M. |
though the Context issue isn't particularly a large issue
|
Mark M. |
avoiding tons of data copying on query results (out of a Cursor, into models) is a bigger problem
|
Justin M. |
I've
looked at the Notepad example from developer.android.com and it is
really basic, but it looks like the DbAdapter class basically is the
goto man for all database access. With one table that wouldn't be too
bad, but we're going to have several, it just seems like a bulky
solution
|
Justin M. |
We
also have parent-child relationships in the database that would be nice
to hide in model classes. What do you think is the best way to tackle
this? Hope I gave enough information here
|
Mark M. |
well, there's nothing limiting you to one such class
|
Mark M. |
on Android, particularly until 2.2 and JIT become widespread, I am hesitant to recommend smart model objects
|
Mark M. |
been there, done that, hit myself repeatedly with a ballpeen hammer in the process
|
Mark M. |
I would put your smarts more in the controllers
|
Mark M. |
(thinking of MVC)
|
Mark M. |
(though MVP and presenters might be a better pattern -- always blur those in my mind)
|
Justin M. |
So having DbAdapters for each table perhaps? Am I understanding you correctly?
|
Mark M. |
something along that line
|
Mark M. |
they can help somewhat with 1:N relations and all
|
Jun 10 | 9:40 AM |
Mark M. |
yet allow you to keep your data in ordinary Cursors
|
Justin M. |
OK,
and then after retrieve the cursors, then in the Activity where I'm
going to display the data, manage linking up the two tables together by
managing two cursors for the two tables?
|
Justin M. |
I'm a little hazy this morning, hope I'm making sense :-P
|
Mark M. |
I was about to ask for clarification of that last one
|
Mark M. |
I seem to be lacking a sentence subject :-)
|
Mark M. |
my hope is that an individual activity will tend to be simpler
|
Mark M. |
for example, take the 1:N relation between recipe and ingredient
|
Mark M. |
a recipe view activity would certainly need to list the ingredients
|
Mark M. |
however, it really should only do that for one recipe, not a whole cookbook
|
Mark M. |
so
you may have two Cursors, but one will be a single-row Cursor (the
recipe) and the other will be detail info (the ingredients)
|
Justin M. |
OK,
I think that makes sense. Do you know of any examples/projects where
there is some more complex database interaction and 1:N relationships
that are implemented that I might be able to take a look at, that might
be a good place to look too, and then I can come back with some better,
more specific questions for next time?
|
Mark M. |
none that I've looked at the source code for
|
Mark M. |
so, for example, some OpenIntents apps should have more complex database models than Notepad
|
Jun 10 | 9:45 AM |
Mark M. |
however, I haven't looked at their code to see how they do it
|
Mark M. |
the code that I've done for this was under contract and is not publicly viewable
|
Justin M. |
Yeah, I wish Google had better examples on this subject. I would think that lots of people would need to know about that.
|
Mark M. |
I suspect the fabled Twitter app will make for interesting reading
|
Mark M. |
once they release it
|
Mark M. |
sometime before Ft. Lauderdale freezes over
|
Justin M. |
LOL that happens about once every 15 years or so (I know, I used to live there ;-) )
|
Mark M. |
only been there once
|
Mark M. |
all I remember are flying cockroaches the size of small cars
|
Mark M. |
:-)
|
Justin M. |
LOL, yeah, you can thank the Everglades for that :-P
|
Justin M. |
Well,
at least you helped me decide to stop going down the path of the smart
model objects, I'll dig around some more and hopefully have some better
questions next week. You'll get to see all of the fruits of my labor in
a month ;-)
|
Jun 10 | 9:50 AM |
Justin M. |
So I'm good for now, thanks!
|
Mark M. |
you're welcome!
|
Justin M. |
Oh real quick, the OpenIntents you talked about, is that http://www.openintents.org?
|
Mark M. |
yes
|
Justin M. |
OK, I'll look at that then, thanks :-)
|
Mark M. |
ShoppingList, NewsReader, etc. should all have more complex database models
|
Justin M. |
Cool beans
|
Jun 10 | 9:55 AM |
CalvinS |
I have a question now
|
Mark M. |
go right ahead!
|
CalvinS |
how do you use the icons in the android resources directory you told me about Tuesday...they are all XML files
|
CalvinS |
the ones here for example F:\android-sdk-windows\platforms\android-8\data\res
|
Mark M. |
well, not all of them are XML files
|
Mark M. |
the ones in res/drawable/ are mostly XML files -- StateListDrawable, LevelListDrawable, etc.
|
Mark M. |
the ones in res/drawable-hdpi/ and res/drawable-mdpi/ are PNGs, mostly
|
Mark M. |
for the PNGs, just copy them
|
Mark M. |
if
you do need, say, a StateListDrawable, you will need to copy the XML
and the PNGs it refers to, then possibly modify your copy of the XML to
point to your copy of the PNGs
|
Mark M. |
once
they are in your project's res/ tree, though, you refer to them no
different than any other resource (e.g., R.drawable.foo, @drawable/foo)
|
Mark M. | |
Jun 10 | 10:00 AM |
CalvinS |
k thanks!
|
Mark M. |
aaaaaaaaaaaaaaaaaaaand, that's a wrap for today's chat
|
Mark M. |
two next week, both in the evening, as I am teaching a class during East Coast business hours
|
CalvinS |
Have a good one guys!
|
Mark M. |
a bit outside of Decidedlywarmlanta
|
Justin M. |
OK, take care!
|
Justin M. |
HOTlanta :-)
|
CalvinS | has left the room |
Justin M. | has left the room |
Mark M. | turned off guest access |