Office Hours — Today, October 14

Tuesday, October 12

Oct 14
7:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:55 PM
Octavian D.
has entered the room
Mark M.
howdy, Octavian!
Octavian D.
good evening
8:00 PM
Mark M.
how can I help you?
Octavian D.
oh actually not much right now :)
just curious
Mark M.
sometimes the office hours are crowded, sometimes less o
Octavian D.
are you expecting more people to show up?
Mark M.
er, less so
Octavian D.
ah ok
Mark M.
it's not really a "hang out and chat" kind of chat room
people usually come here if they have specific questions to be answered
though lurking is perfectly acceptable
BTW, the transcripts get published to the [cw-android] Google Group
Octavian D.
ok
Rhett S.
has entered the room
Mark M.
howdy, Rhett!
Rhett S.
hello mark
Octavian D.
hello Rhett
Rhett S.
and Octavian
Mark M.
Rhett: it's your turn -- do you have a question?
Rhett S.
Are you in the midst of a discussion?
Mark M.
nope
8:05 PM
Rhett S.
I have a few general questions about how to get my lists to work right with section headers. I'm still pretty new to this stuff so i may not make perfect sense.
Mark M.
fire away!
Rhett S.
well. first i want to understand when to use mergeadapter vs. another approach i'm wondering about
the strategy i'm thinking about is to make a list of Objects that can include core date and the headers - so i would only need 1 adapter. does that make sense?
Mark M.
where would the list of objects come from?
Rhett S.
i would get the list of say, TravelItems from a backend method - but when it is displayed there need to be date headers inserted
so i was thinking of making objects that can either be headers or travelitems
Mark M.
no, I mean, are the objects being loaded from a database, from a file, from a Web service call, etc.?
Rhett S.
that has been abstracted by the time we get to my level - the data comes from a webservice but wil be locally cached
8:10 PM
Mark M.
um
Rhett S.
so you can say it is from a database - but i'm just getting a list by making a java method call
Mark M.
a general goal in constrained environments is to minimize the amount of copying of data you di
er, you do
this goes double for garbage-collected environments like Android
Rhett S.
example code: ArrayList<TravelItem> travelItems = it.getSortedItems();
Mark M.
so I am really really not a fan of taking a Cursor and copying the data into POJOs
Rhett S.
well this is a complicated UI where passing the pojos around makes things much easier to understand
Mark M.
in a constrained environment, you often have to sacrifice the needs of the developer to cater to the needs of the user
Rhett S.
but if i understand, you are saying that it might be better to stick with cursors and then merge adapters, rather than merging in the object level
Mark M.
right -- if you were being handed a Cursor, I wouldn't go create POJOs just to avoid the MergeAdapter
Rhett S.
this is actually a short list: a user's itinerary for a single trip
i am in fact being handed objects
Mark M.
given that you are being handed POJOs, you could either create a new ArrayList that has a blend of TravelItems and your headers
SD
has entered the room
Mark M.
or create your own adapter straight from BaseAdapter
Rhett S.
can you say more about door #2?
8:15 PM
Mark M.
(BTW, howdy, SD!)
well, BaseAdapter is a skeletal adapter
it doesn't know much about any sort of data structure
you fill that in by implementing some abstract methods
Rhett S.
hello SD - have we by any chance met in person?
Octavian D.
hello SD
Mark M.
Rhett: in your case, probably the ArrayAdapter is the simpler solution -- I just mention rolling a full adapter from BaseAdapter for completeness
Rhett S.
Thanks, Mark. SD: are you my friend stan?
Mark M.
and, on a related note...SD: do you have a question?
SD
yes
Rhett S.
Btw, Mark did you repackage MergerAdapter as you mentioned last week?
Mark M.
Rhett: sorry, haven't had a chance yet
Rhett S.
no worries
8:20 PM
Rhett S.
i have a question about reproducing a UI feature often seen on the iphone -
8:20 PM
Mark M.
Rhett: hang on
SD: do you have a question?
SD
I was trying to do the "requestLocationUpdates" using wakefulIntentService. I am releasing lock after I get updates. The code works fine when phone is attached to computer (debugging). But doesn't work when its not. Ie when it goes to sleep
Mark M.
WakefulIntentService does not work well with listener APIs like requestLocationUpdates()
rob b.
has entered the room
Mark M.
I have a WakefulLocationService partially implemented
which I will eventually wrap up
Octavian D.
hello rob
Mark M.
but probably not until after I slice me some Gingerbread, if the rumors of it being released next week are true
(BTW, howdy, rob!)
SD
any pointers you can give - what I might need to do to fix this issue
rob b.
hi!
Mark M.
you can't really start from WakefulIntentService as a base
start with a regular Service
SD
Isn't intent service same as regular service except it works in seperate thread?
Mark M.
it also shuts down when the work is complete
and it releases the WakeLock
you need the WakeLock to stay on
rob b.
(i wanted to ask a question when you have a minute but i figured a graphic would help.... posting something to my site right now....)
Mark M.
rob: you're next in line, hold on
SD: you could, I suppose, grab your own WakeLock in doWakefulWork() plus call requestLocationUpdates()
SD
but I have alarm which will trigger the new intendservice again.
Mark M.
then, when the fix comes in, you process the location and release your own WakeLock
8:25 PM
Mark M.
but then you have to deal with cases like a second alarm coming in, not getting a fix (e.g., you're asking for GPS but can't get a signal), etc.
it's not an easy problem to solve
which is why it's taking me some time to try to solve it
SD
hum.. ok.. got it. Thanks!
Mark M.
OK...rob: got a question?
Rhett S.
I'm ready anytime...
Mark M.
Rhett: I like to give everyone a shot at a first question before making it back around for the second round
rob b.
go ahead with rhett, i'll be another minute
Mark M.
OK
Octavian: do you have a question?
Rhett S.
View paste
On the iphone platform it is easier than for us to make section headers in lists. These headers do a nice visual effect when user scrolls up: the section headers stop moving when they hit the top of the screen, and sort of push each other out of the way in an animation - do you know the effect i am talking about? 

I had thought this would be impossible on Android - clearly simply adding section headers with MergeAdapter would not animate in that way... However i have noticed that the Contacts app on the Droid does the affect i'm seeking....

How?
Octavian D.
nope
Mark M.
OK, on to Rhett's question...
no, I don't know the effect you're talking about
Rhett S.
hmm, darn - any iphone app shows it.
do you have a Droid handy?
Mark M.
but I see what you mean about Contacts -- Nexus One does it too
Rhett S.
ah. seems like a slick trick!
Mark M.
off the cuff, not sure how they're doing that
however, the source is available
8:30 PM
Mark M.
so you could poke around and try to see how they're pulling off the trick
Rhett S.
i'm not accustomed to looking at the source code - that's a good idea. but this makes me wonder _what_ source... for example, the Droid X has a different Contacts app
Mark M.
I am guessing it is the ContactsListActivity
well, you don't have source for Motorola's proprietary app
Rhett S.
the contacts app on my stock droid x does not animate like that - in fact it does not have alpha section headers
Mark M.
the original DROID has a "standard" Android open source UI
Rhett S.
but the exact code running on the nexus one is at your link?
Mark M.
like the Nexus One
yes
Rhett S.
thank you
Mark M.
all 3585 lines of it
I recommend a case of Red Bull
suffice it to say, the technique doesn't appear to be very easy to implement
OK...SD, got another question?
SD
View paste
Approximatly how much would be the accuracy of ACCURACY_COARSE (Cell tower or wifi - whatever is available)?
8:35 PM
Mark M.
well, WiFi proximity isn't built into stock Android, and that would probably be FINE
after all, WiFi signals are only so strong
cell tower triangulation I think gives you accuracy on the order of hundreds of meters, maybe a kilometer
it'll depend on where you are -- probably better in a city (lots of towers), worse in the countryside
SD
ok
Mark M.
View paste
rob: you ready with your question?
rob b.
yeah.....
lemme give you a qucik background
i am an experienced web/javascript programmer, and fairly comfortable in java. been studying android and read books and played around for a few weeks, but i now have a contract (for my brother-in-law) and worried i'm in over my head
Trying to port an iphone app that was done by someone else for the same client
App
obviously they had it a bit easier because there are fewer possible resolutions
i've been trying to get the layout right and its been a nightmare. nothing works as i'd hope
Mark M.
let me guess
rob b.
any thoughts on how to do that layout? im at the point of doing absolutelayout and just measuring everything
Mark M.
you posted a question a few hours ago on StackOverflow, right?
rob b.
yup
Mark M.
got a few snarky responses?
rob b.
very frustrated if you can't tell
ha, yeah.
i posted one a couple days ago and you replied in a comment....try the heirarchy viewer
Mark M.
which part of "do that layout" are you having problems with?
rob b.
well, the two sections on bottom with the buttons
was trying to make a ButtonMenu class, that contains the buttons as linearlayout or tablelayout
8:40 PM
Mark M.
OK
rob b.
but one, i need to get them to show up under the map, with the map sizing itself to account for them
Dan
has entered the room
Mark M.
I generally recommend platform fidelity
in which case, your bottom buttons turn into an option menu
rob b.
couldn't get that to work....not sure if that shoudl be a relativelayout that contains the map plus the two things
ok
Mark M.
the goal isn't to make the two apps look the same, since damn near nobody will be using both of them
(BTW, howdy, Dan!)
rob: the goal is to make it fit well with the rest of the apps on the platform
rob b.
yes, i talked about that with client. i know they prefer it look as similar as possible
Dan
hi!
Mark M.
OK
rob b.
but i can do a regular tab menu, i suppose
Mark M.
anyway, that bottom is probably a set of RadioButtons
in a horizontal RadioGroup
with custom imagery
rob b.
the set of 7 buttons?
or the bottom....
Mark M.
no, I'm talking the bottom three buttons
rob b.
(yeah the set of sever would be check buttons actually since they are all toggles)
ok
Mark M.
I'm assuming those are mutual-exclusion -- clicking on one totally changes your map (or perhaps the entire UI)
rob b.
yes
the bottom set that is true
Mark M.
the row of seven could be CheckBoxes with custom imagery, or possibly ToggleButtons
rob b.
so can i get those to lay out beneath the map, and have the map size itself to account for them? I couldn't get that to work
Mark M.
put them inside a SlidingDrawer, and use your own graphics for the drawer handle
rob b.
ok
8:45 PM
Mark M.
the SlidingDrawer and the MapView would need to be children of a RelativeLayout, with the drawer as a later child (i.e., lower in the XML), so it floats on top
in fact, I'd do the whole thing with a RelativeLayout base
one child being your search bar
rob b.
ok that is what i was trying
Mark M.
one child being the MapView
one child being the bottom 3-button bar
one child being the SlidingDrawer
rob b.
ok
Mark M.
for me, the trickiest part would be the styling of the buttons, but that's because I'm craptacular at graphics
rob b.
yeah i can do that stuff :)
Mark M.
doing it this way will be tons easier than trying to get the AbsoluteLayout stuff right
rob b.
what xml attribute do i need on the relative layout to get it to work? i could only get the stuff to overlay
not be under, and have the map figure out its own size
Mark M.
there are many for X/Y positioning, relative to the container or relative to other widgets
for Z-axis ordering, it's not a question of attributes -- later children float over earlier children
that's why you need the SlidingDrawer to be in the XML after the MapView
so when they open the drawer, it opens over the map
rob b.
ya, i figured that out. i just couldn't get them all to fall in the right place
Mark M.
and your handle intrudes into the map in the normal case
rob b.
right
SD
I have a question if you have time.
Mark M.
you might want to take a look at the Maps chapter in the Advanced Android book
rob b.
ok i will look at that
thanks so much, i'll see how far i get :)
Mark M.
SD: hold on, let's give Dan a shot, since he hasn't asked a question yet
Dan: got a question?
8:50 PM
Dan
nope just lurking
Mark M.
OK, SD: what's your question?
SD
View paste
I am sorry but I am still not clear about why location updates not working for me - 

Please see code at http://pastie.org/private/557nyvdrutk2cpspnmhdua

I am not releasing lock in finally block of onHandleIntent(intent i) method of WakefulIntentService.

Instead releasing after I receive updates & setup next alarm.

Why should it not work?
Mark M.
off the cuff, I have no idea
SD
ok. anything I should try.... that you can think of?
Mark M.
are you sure isAtleastOneTaskNotExpired is working the way you expect?
SD
yes. it is.
I tried without that .. so thats not the issue
Mark M.
long term, you'll have WakeLock problems -- if the process gets killed, you'll leak the WakeLock
but that should not impact your ability to get locations in the meantime
I'd hard-wire it to use GPS, then test on an emulator, pushing a position in via DDMS
8:55 PM
SD
GPS because I get better accuracy?
Mark M.
no, GPS because that's what DDMS simulates with the emulator
adding in your getBestProvider() stuff is good once you get the basic logic working
start as simple as humanly possible, then work your way up
also, the emulator won't fall asleep, so you won't need to fuss with WakeLocks
SD
ok.. In my case, it was having wifi connection. but I will try with GPS
it works fine with actual device as far as its connected to my computer and I am watching logs
Mark M.
bear in mind that if it's connected to your computer, it might not fall asleep, depending on your settings
SD
once I remove USB connection of device, It stops working.. so my guess is it stops becasue phone goes to sleep...
Mark M.
quite possible
but if anything, your code should keep the device on more than is needed, not less
SD
is there a way to tell phone to sleep even when connected to computer using USB
Mark M.
not that I am aware of
by which I mean you cannot force it asleep
there's the "Stay awake" setting (Applications > Development in Settings app)
that will allow it to fall asleep normally while charging
SD
yeah. but can I tell it to sleep when I am not doing anything with phone (just connected to computer and watching debug msgs) a
ok
Mark M.
OK, that's a wrap for today's chat
9:00 PM
SD
I will be waiting for ur wakefullocationservice.. I hope you will get time to publish it soon
Mark M.
two more scheduled for next week, same time slot as today's
SD
thanks
Dan
gn thx
Dan
has left the room
Mark M.
have a pleasant day!
rob b.
thanks again mark. your books are really good and i like the publication model :)
Octavian D.
thanks Mark, good night.
Mark M.
rob: thanks!
Octavian D.
has left the room
Rhett S.
has left the room
SD
has left the room
rob b.
has left the room
Mark M.
turned off guest access

Tuesday, October 12

 

Office Hours

People in this transcript

  • Dan
  • Mark Murphy
  • Octavian Damiean
  • Rhett Savage
  • rob brown
  • SD