Oct 14 | 7:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 14 | 7:55 PM |
Octavian D. | has entered the room |
Mark M. |
howdy, Octavian!
|
Octavian D. |
good evening
|
Oct 14 | 8:00 PM |
Mark M. |
how can I help you?
|
Octavian D. |
oh actually not much right now :)
|
Octavian D. |
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
|
Mark M. |
people usually come here if they have specific questions to be answered
|
Mark M. |
though lurking is perfectly acceptable
|
Mark M. |
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
|
Oct 14 | 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
|
Rhett S. |
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
|
Rhett S. |
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
|
Oct 14 | 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
|
Mark M. |
er, you do
|
Mark M. |
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
|
Rhett S. |
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?
|
Oct 14 | 8:15 PM |
Mark M. |
(BTW, howdy, SD!)
|
Mark M. |
well, BaseAdapter is a skeletal adapter
|
Mark M. |
it doesn't know much about any sort of data structure
|
Mark M. |
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
|
Oct 14 | 8:20 PM |
Rhett S. |
i have a question about reproducing a UI feature often seen on the iphone -
|
Oct 14 | 8:20 PM |
Mark M. |
Rhett: hang on
|
Mark M. |
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
|
Mark M. |
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
|
Mark M. |
(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
|
Mark M. |
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
|
Mark M. |
and it releases the WakeLock
|
Mark M. |
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
|
Mark M. |
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
|
Oct 14 | 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.
|
Mark M. |
it's not an easy problem to solve
|
Mark M. |
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
|
Mark M. |
Octavian: do you have a question?
|
Rhett S. |
View paste
|
Octavian D. |
nope
|
Mark M. |
OK, on to Rhett's question...
|
Mark M. |
no, I don't know the effect you're talking about
|
Rhett S. |
hmm, darn - any iphone app shows it.
|
Rhett S. |
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
|
Mark M. |
however, the source is available
|
Oct 14 | 8:30 PM |
Mark M. |
so you could poke around and try to see how they're pulling off the trick
|
Mark M. | |
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
|
Mark M. |
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
|
Mark M. |
yes
|
Rhett S. |
thank you
|
Mark M. |
all 3585 lines of it
|
Mark M. |
I recommend a case of Red Bull
|
Mark M. |
suffice it to say, the technique doesn't appear to be very easy to implement
|
Mark M. |
OK...SD, got another question?
|
SD |
View paste
|
Oct 14 | 8:35 PM |
Mark M. |
well, WiFi proximity isn't built into stock Android, and that would probably be FINE
|
Mark M. |
after all, WiFi signals are only so strong
|
Mark M. |
cell tower triangulation I think gives you accuracy on the order of hundreds of meters, maybe a kilometer
|
Mark M. |
it'll depend on where you are -- probably better in a city (lots of towers), worse in the countryside
|
SD |
ok
|
Mark M. | |
rob b. |
yeah.....
|
rob b. |
lemme give you a qucik background
|
rob b. |
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
|
rob b. |
Trying to port an iphone app that was done by someone else for the same client
|
rob b. | |
rob b. |
obviously they had it a bit easier because there are fewer possible resolutions
|
rob b. |
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
|
rob b. |
ha, yeah.
|
rob b. |
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
|
rob b. |
was trying to make a ButtonMenu class, that contains the buttons as linearlayout or tablelayout
|
Oct 14 | 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
|
Mark M. |
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
|
rob b. |
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
|
Mark M. |
(BTW, howdy, Dan!)
|
Mark M. |
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
|
Mark M. |
in a horizontal RadioGroup
|
Mark M. |
with custom imagery
|
rob b. |
the set of 7 buttons?
|
rob b. |
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)
|
rob b. |
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
|
rob b. |
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
|
Oct 14 | 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
|
Mark M. |
in fact, I'd do the whole thing with a RelativeLayout base
|
Mark M. |
one child being your search bar
|
rob b. |
ok that is what i was trying
|
Mark M. |
one child being the MapView
|
Mark M. |
one child being the bottom 3-button bar
|
Mark M. |
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
|
rob b. |
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
|
Mark M. |
for Z-axis ordering, it's not a question of attributes -- later children float over earlier children
|
Mark M. |
that's why you need the SlidingDrawer to be in the XML after the MapView
|
Mark M. |
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
|
rob b. |
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
|
Mark M. |
Dan: got a question?
|
Oct 14 | 8:50 PM |
Dan |
nope just lurking
|
Mark M. |
OK, SD: what's your question?
|
SD |
View paste
|
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.
|
SD |
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
|
Mark M. |
but that should not impact your ability to get locations in the meantime
|
Mark M. |
I'd hard-wire it to use GPS, then test on an emulator, pushing a position in via DDMS
|
Oct 14 | 8:55 PM |
SD |
GPS because I get better accuracy?
|
Mark M. |
no, GPS because that's what DDMS simulates with the emulator
|
Mark M. |
adding in your getBestProvider() stuff is good once you get the basic logic working
|
Mark M. |
start as simple as humanly possible, then work your way up
|
Mark M. |
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
|
SD |
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
|
Mark M. |
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
|
Mark M. |
by which I mean you cannot force it asleep
|
Mark M. |
there's the "Stay awake" setting (Applications > Development in Settings app)
|
Mark M. |
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
|
SD |
ok
|
Mark M. |
OK, that's a wrap for today's chat
|
Oct 14 | 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 |