Office Hours — Today, July 1

Tuesday, June 29

Jul 1
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:00 PM
Brian C.
has entered the room
Mark M.
howdy, Brian!
Brian C.
Hi, Mark. How's Lisbon?
Mark M.
OK
Jere_Jones
has entered the room
Mark M.
Howdy, Jere_Jones!
Jere_Jones
Hi Mark!
Brian C.
I have a question about mu1titouch
Mark M.
Brian: you're first up -- got a question?
oy
Brian C.
Is there a way to handle multitouch in 1.6?
Mark M.
go ahead, but I have limited knowledge of that area
not that I am aware of
APIs for it were not added until 2.0, IIRC
Brian C.
OK. I guess zoom box controls are my best bet, then.
Thanks
Jere_Jones
Ooo... ooo.... my turn?
Mark M.
Jere_Jones: go right ahead!
Jere_Jones
:)
I just wondered if we could discuss organization of projects. Particularly the best way to handle database access.
4:05 PM
Jere_Jones
I have my Application subclass that holds my DatabaseHelper. But it got REALLY cluttered REALLY fast.
I've moved my col names/create strings into the entity classes that they persist.
Any opinions?
Mark M.
well, my thought is going to be on the radical side, I suspect
nuke the entity classes
Jere_Jones
Okay.... there must be a punch line. What is the alternative?
Mark M.
right now, my thinking is that the model in Android MVC is a Cursor, supported by the DatabaseHelper for accessors
I just revamped the LunchList application in Android Programming Tutorials to fit this approach
entity classes wind up with too much code and too much data copying, IMHO
Jere_Jones
I get worried about using a CursorAdapter because they access the db on the ui thread. Which I am trying to avoid at all costs.
Mark M.
that should not be a problem
Dave G.
has entered the room
Dave G.
Hey all
Mark M.
touch the Cursor in an AsyncTask before handing it to the adapter
Jere_Jones
I come from a C++ background but my understanding is that just about everything (except primatives) in Java are references.
Mark M.
(by touch, I mean like moveToFirst() or something, enough to get it to run the query)
howdy, Dave G.
Jere_Jones
refreshQuery()?
Mark M.
Jere_Jones: yes, everything is an object other than int, float, boolean, short, long, double, byte
4:10 PM
Mark M.
not sure where refreshQuery() is
but you probably do not want to do requery(), as that may just re-set the Cursor to lazy-load state
Jere_Jones
I need to put the createPlaylist, createSource, etc functions somewhere. That is how my dbhelper got crazy.
Mark M.
what do the createX methods do?
Dave G.
Mark: I was a bit confused on the extended the ListAdapter why you'd do it
the part of the book is kinda confusing for me.
Jere_Jones
I'm gonna think on this Mark, please carry on to your other fans. :)
Mark M.
Dave G: hang on, let me get Jere_Jones' issue tackled first
Dave G.
ok
Mark M.
oh, OK
Dave G: you extend ArrayAdapter or CursorAdapter or whatever to customize the rows
Dave G.
Yup. I understand that I've extended ArrayAdapter before however im confused about the ListAdapter
example
with the RatingBar.
Mark M.
not everything can be handled through the simple rules you teach the adapters via their constructor parameters
what about it?
4:15 PM
Dave G.
I dunno. I find it hard to follow, is this creating its own ListView?
Mark M.
no
like any other adapter
it is creating rows
each row contains text and a RatingBar, instead of text and an ImageView like the preceding examples
jason g.
has entered the room
Mark M.
the catch is that since a RatingBar is mutable by the user, you need to track their changes as part of your state
otherwise, row recycling will lose what the user entered
Robert C.
has entered the room
Mark M.
(btw, howdy, jason g!)
and, howdy, Robert C!
Mark J.
has entered the room
jason g.
hello
Mark M.
and, howdy, Mark J!
Robert C.
hi
Dave G.
I guess i'll have to try rereading it. Um. The other thing that is confusing for me is the layout inflater
Mark J.
Heya Mark, wouldn't miss it.
Mark M.
Dave G: what is confusing about the LayoutInflater?
(jason g, Mark J, Robert C -- we'll get to your questions shortly)
Dave G.
not exactly sure what it does.. Is it when your creating new fields in the activity?
without the xml?
Mark M.
no, it is when you turn layout XML files into actual View objects
Dave G.
or initiating the fields?
Mark M.
such as creating rows in a ListAdapter
4:20 PM
Dave G.
ok i think i understand it more now.
I'll have to re-read it a bit more.. I've done some self looking on the web on how to do things. And i'm getting some interesting things out of your book as well.
Mark M.
glad to hear it!
Dave G.
Your book is pretty descriptive :) I like how you go into detail with the fields I learned about a few things that i coudlnt find on the web :)
Mark M.
jason g: got a question?
jason g.
not now. i just signed up and was just curious to see how this goes. books seem good so far. i think the overall business model is a winner for me. just lurking now.
Mark M.
OK, thanks!
Mark J: got a question?
Dave G.
I agree. Subscription base is cool and using the Sony PR505 :)
Mark J.
Oh, hey. Uhh, yeah quick one
Must an Array be present for AsyncTask to work?
Mark M.
no
Mark J.
Alrighty. I am still having issues with it, so I am just trying to make it work.
Mark M.
the only thing related to arrays with AsyncTask are the varargs passed to doInBackground() and onProgressUpdate()
4:25 PM
Mark J.
Alrighty :) You can move on. I may ask more later
Mark M.
OK
Robert C: got a question?
Robert C.
Yes
Got a problem with WiFi turning off when screen goes into a locked state.
Mark M.
that's normal behavior
you need a WifiLock to keep it on
Robert C.
How do you disable that?
I have a lock and it still turns off.
Mark M.
a WifiLock, or a WakeLock?
WakeLock holds the CPU on, but that does not impact the WiFi
Robert C.
When I unlock the phone, things start up where they left off. The code then checks to see if it has a lock and it already does so it skips asking for another one.
Mark M.
a WifiLock, or a WakeLock?
Robert C.
Wifi. The program should continue streaming from the Internet while the phone is locked.
Mark M.
:: shrug ::
do you also hold a WakeLock?
Robert C.
I don't remember seeing a WakeLock. What would that buy me?
Mark M.
keeps the CPU on
4:30 PM
Mark M.
I would assume you would need both a WakeLock and a WifiLock
Robert C.
The logs show WiFi turning off. Could it be that it wants to shut down the CPU and thus that in turn is shutting down the WiFi?
Mark M.
beats me
Robert C.
I don't see a wakelock but I could attempt that and see if it helps.
Mark M.
it's certainly worth a shot
I cover WakeLocks in the Advanced Android book, if it helps
Robert C.
Goal is to keep music playing while the phone is locked. I even tried telling the WiFi to never shut down but it ignores that.
I'll go look there. I should be able to put it in the same place I have the Wifi locks.
I'll shoot at anything if it gets me past this problem. :)
Mark M.
yes
Robert C.
Thanks, I'll give that a try.
Mark M.
:-)
I wound easily
please don't shoot at me
Robert C.
Are there other locks I should probably think about?
Mark M.
OK, back to the front of the line we go...
Brian C: got a question?
Khye
has entered the room
Brian C.
What is the advantage of using a static inner class for the Holder pattern?
Mark M.
Robert C: those are the only two I can think of
Robert C.
thsx
Mark M.
Brian C: I'm trying to clean up my inner class usage, only using non-static inner classes where needed
static inner classes eliminate the implicit reference to the outer class instance
you can get into some interesting GC problems if you're not careful
(btw, howdy, Khye!)
I had been largely ignoring this, but I've come to see the error of my ways
4:35 PM
Khye
Hello
Brian C.
ok, I saw Brad F do it in his zippy talk at I/O. was wondering
Mark M.
right, that was my first clue
some feedback on the cw-android group shoved me further in this direction
Brian C.
ok, i'll go back to check the group for that discussion
thanks, Mark.
Mark M.
OK...let's give Khye a shot, since everyone else has had a turn
Khye: do you have a question?
OK
Dave G: got a question?
Dave G.
Nah. Just looking and learning :)
I'm trying to figure out what will my next applciation be :)
Mark M.
OK, no problem
jason g: got a question?
Dave G.
May have more questions later.. im only at page 100 on your book :)
jason g.
am i correct that there isn't just an html version of the books?
4:40 PM
Mark M.
correct -- PDF, EPUB, and Kindle only
Dave G.
I'm interested in learning services and threads. Does your book go into that?
Khye
Yes - I read in your book that you cannot promote a free application to paid, and we see a lot of 'lite' versions in the market. I have an app that will eventually be paid, but I'd like to get feedback early in its development, but can't leverage the marketplace because of this restriction. How do you feel about 'lite' free versions, is it hard to manage the code base between lite and paid, etc.
Mark M.
Dave G: oh, yes, lots
jason g.
i wish there was an html version i could sync locally and just use a browser to view. maybe stored in mercurial or something.
Mark M.
Khye: with the new Android library projects, it is reportedly not as bad as it used to be
Khye: Lite vs. paid is a very common pattern
jason g: use a browser-based EPUB viewer
Robert C.
Have you tried reading your books with the newly released Kindle for Android?
Dave G.
ya
i wanna try that :)
Mark M.
Robert C: no WiFi at the hotel (wired only) here in Portugal
Robert C.
I haven't tried but was going to. I'm hoping it works so I can learn to code Android on the Android. :)
jason g.
i'm specifically looking for something on a desktop.
works fine with aldiko on android
Robert C.
Kindle runs on the desktop.
Mark M.
PDF viewers run on the desktop
and PDF is always going to be the nicest format, because that's where my print editions come from
4:45 PM
jason g.
it doesn't seem like it should require new software since epub is largely html. pdf viewer works fine which is what i'm using now. i also wanted something less manual for making sure i have the latest book versions.
Mark M.
um, manual is pretty important for my business model
I don't have a problem with people making personal copies (home PC, office PC, phone, etc.)
but I'm not going to be ditching the subscriber model any time soon
Jere_Jones
Just a random thought: A so and so is typing indicator would be really useful in here. :)
Mark M.
Jere_Jones: I usually try to do one person at a time, things broke down here
jason g.
i'm done if you want to move on now.
Mark M.
sorry
Mark J.
:) atleast we are still having a good time :)
Jere_Jones
The time sure does fly. I'm ready for my turn, at your leisure.
4:50 PM
Mark M.
Jere_Jones: go right ahead
Jere_Jones
Imagine something like Google Listen but with multiple playlists.
It has playlists which have sources which have items.
Showing a list of the playlists includes information derived from information about the items and sources.
The list of playlists also includes expanders to show the sources.
That information would change in off ui threads from service, broadcast receivers, user activities, etc.
The act of changing the various entities would notify any adapters. How can I do something similar with a CursorAdapter?
I can't just come up with some wicked query because their is a hierarchy to what (may) need to be shown in the list.
- Done
I type fast. :)
Mark M.
um
Jere_Jones
We were discussing entity classes earlier.
Mark M.
right
what are you gaining by using SQLite in this case?
Jere_Jones
As opposed to what? I understood that SQLite is the defacto db standard for Android.
Mark M.
as opposed to whatever format you are getting the data in -- XML, JSON, etc.
I'm assuming you're not downloading SQLite databaess
er, databases
this feels like a cache
Jere_Jones
Have you tried parsing an RSS feed? It takes a while (seconds).
Mark M.
and you think your "wicked query" will be faster?
Jere_Jones
No. :)
Mark M.
right
Jere_Jones
I think my entity classes will be faster.
Mark M.
could be
Jere_Jones
I'm also not talking about a full blown frame work. These are custom rolled classes.
Mark M.
but your original problem was entity classes backed by a database, and the problems that was giving you
4:55 PM
Mark M.
my advice there -- nuke the entity classes -- assumed the database was the fixed point
the alternative is to consider whether the database is necessarily the right answer
Jere_Jones
The code isn't so much the problem as is how to organize it. What goes in the entity class, what goes in the dbhelper, who is responsible for upgrades, etc.
Mark M.
yeah, there's enough patterns there to fill (somebody else's) book
you're just running into the classic hierarchical data/relational DB impedance mismatch
Jere_Jones
Seems natural to take a 100k rss feed, take the 2k that I need and stuff it somewhere easily accessable.
Mark M.
its why NoSQL is all the rage
agreed...but that might not necessarily be SQLite
Jere_Jones
I'd give my left arm for LINQ in Java.
Mark M.
if your real model is a tree structure of objects, consider persisting to a JSON file or something
one-handed typing is no fun
:-)
Jere_Jones
Ok. What does that gain me?
Mark M.
gets rid of most of your persistence code, I'd think
Jere_Jones
You think? I would figure it would multiply it a lot. Loading/parsing/saving/etc.
Mark M.
dunno
just brainstorming
Jere_Jones
Or does java have a SerializeObjectToJsonFile?
5:00 PM
Mark M.
no (there's Serializeable, give or take an 'e', but that serializes to a binary format IIRC)
Jere_Jones
I appreciate the idea. I have worked with SQL so long it seems natural to put data there. I will give it some serious thought.
Mark M.
there are just too many details that would impact the decision on what to do -- it's tough for me to provide advice
anyway, that's all for this evening, folks
Jere_Jones
So you do the next best thing: provide options. :)
Robert C.
Just providing feedback. Adding WakeLock didn't work.
Jere_Jones
Thanks Mark.
Robert C.
Thanks Mark. Have a good holiday weekend.
Mark M.
Robert C: this sounds like a hackbod sort of problem -- try [android-developers] and hope she responds
Robert C.
hackbod?
Mark M.
have a good weekend, everyone!
Robert C: Dianne Hackborn (a.k.a., hackbod), a Googler on the Android team
Robert C.
I thought you were meaning Dianne. Thx.
Brian C.
has left the room
Jere_Jones
has left the room
Dave G.
has left the room
jason g.
has left the room
Robert C.
has left the room
Mark J.
has left the room
Khye
has left the room
Mark M.
turned off guest access

Tuesday, June 29

 

Office Hours

People in this transcript

  • Brian Cooley
  • Dave Germiquet
  • jason gilbert
  • Jere_Jones
  • Khye
  • Mark Johnston
  • Mark Murphy
  • Robert Casto