Oct 15 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 15 | 3:55 PM |
Sean D. | has entered the room |
Mark M. |
hello, Sean!
|
Mark M. |
how can I help you today?
|
Sean D. |
hi
|
Sean D. |
I had a couple (hopefully quick) questions...
|
Mark M. |
go right aheae
|
Mark M. |
er, ahead
|
Sean D. |
In my app, I'm syncing objects in the DB to Google Drive on startup. This process could take a while, so I use a service with broadcasts to an activity.
|
Sean D. |
View paste
|
Mark M. |
um
|
Sean D. |
Or if there is a better way to get that information in Activity.onStart, when I re-register the BroadcastReceiver?
|
Mark M. |
are you using regular broadcasts, or LocalBroadcastManager?
|
Sean D. |
regular broadcasts
|
Oct 15 | 4:00 PM |
Mark M. |
I would suggest switching to an event bus: LocalBroadcastManager, Otto, greenrobot's EventBus, etc.
|
EGHDK | has entered the room |
Mark M. |
I added a chapter on that in today's Version 5.2 of the book
|
Sean D. |
Oh okay, cool, I'll check it out, thanks
|
Mark M. |
they should not be subject to the "can't receive when the screen is off" limitation
|
Sean D. |
I also just discovered sync adapters in the docs... would that be a better route than my own service?
|
Mark M. |
also, Otto and greenrobot's EventBus will give you options for being able to basically "pull" the last broadcast
|
Mark M. |
which you can use if the user got rid of your activity, then starts it up again
|
Sean D. |
Ah, perfect.
|
Mark M. |
with respect to sync adapters, there's a fair amount of baggage that comes along with those
|
Mark M. |
such as the whole Accounts system
|
Mark M. |
that's one of the reasons I haven't gotten into it in the book yet
|
Mark M. |
some people love sync adapters, others detest them
|
Mark M. |
hence, I cannot say if it's a good choice for you right now
|
Mark M. |
let me take a question from EGHDK, and I'll be back with you shortly
|
Sean D. |
Okay, I think I'll stick with my own service for now. I'll give the event bus thing a try.
|
Mark M. |
EGHDK: do you have a question?
|
EGHDK |
Yeah, it's about something that I've been now working on for about a week and a half, but I just can't figure out how to do it.
|
EGHDK |
I want to create chat bubbles for my application I'm doing. Very similar to whatsapp: http://imgur.com/2i4Bw96
|
EGHDK |
The thing is... I realize that I can do this with 9patch, BUT one of my requirements is to let the user change the color of the bubbles. Which means I would have to accomplish this programmatically (not using images).
|
Oct 15 | 4:05 PM |
Mark M. |
use a nine-patch for the edges, and layer on top of that a colored fill as a ShapeDrawable
|
Mark M. |
combine the two via a LayerListDrawable
|
EGHDK |
But I'm just stuck at drawing these things now. I don't know whether I should try to create a BubbleView extends View or what.
|
Mark M. |
(actually, ColorDrawable is even better for a solid fill than ShapeDrawable)
|
EGHDK |
Okay... So... create a 9 patch for the edges... and ShapeDrawable as a fill?
|
EGHDK |
Hmm... okay I think I will try that. The reason I am getting frusterated is because I am working with an iOS developer and he is creating these bubbles with a "bezier path" and he insists I should be able to do that in android.
|
Mark M. |
that would basically require you to roll your own View and use low-level Canvas drawing primitives
|
Mark M. |
that would work, but does not strike me as being particularly easy
|
EGHDK |
It's annoying because it is basically just a rounded rectangle...
|
Mark M. |
you could also see how others solved it, such as http://www.androidviews.net/2012/11/mapview-bal...
|
Mark M. |
let me take another question from Sean, and I'll be back with you shortly
|
Mark M. |
Sean: do you have another question?
|
Oct 15 | 4:10 PM |
Sean D. |
Yeah, one more... going back to syncing, I want the user to still be able to interact with the app.
|
Sean D. |
For example, the can open a detail activity from the main activity's list view, etc.
|
Sean D. |
View paste
|
Sean D. |
Oops, that pasted weird. I admit I had these questions prepared :P
|
Mark M. |
the sync is doing writing, I take it?
|
Sean D. |
Yes
|
Sean D. |
It has to at the very least update a record's last modified date so it doesn't get updated again on next sync
|
Mark M. |
you could try yieldIfContendedSafely() on SQLiteDatabase, though I have not tried it personally
|
Alex | has entered the room |
Sean D. |
Hmm, okay, thanks
|
Mark M. |
Alex: do you have a question?
|
Mark M. |
ok... EGHDK: do you have a question?
|
Oct 15 | 4:15 PM |
Alex |
I'm trying to figure out how to implement an overscroll on a listview to reveal some text at the top as the user pulls down. any ideas on the approach to this?
|
Mark M. |
Alex: there are a few pull-to-refresh libraries out there. See http://androidviews.net
|
Mark M. |
ok... Sean: do you have another question?
|
Sean D. |
No, I don't think so... thanks
|
Mark M. |
OK, if anyone has any questions, chime in
|
Gabriele | has entered the room |
EGHDK |
Do you know of any good layer list drawables by any chance?
|
Mark M. |
um, LayerListDrawable is a class
|
EGHDK |
Or rolling my own view by useing low level canvas drawing primitives?
|
EGHDK |
oh...
|
Gabriele |
hi all, I'm just here reading :)
|
Mark M. |
oh, sorry, the class name is LayerDrawable, my mistake
|
Mark M. | |
Mark M. |
(BTW, hello, Gabriele!)
|
Oct 15 | 4:20 PM |
Mark M. |
EGHDK: <layer-list> is the XML element for defining one as a resource, which is where I got mixed up
|
EGHDK |
View paste
|
Mark M. |
um, well, you are a subscriber to a book
|
Mark M. |
the book has a chapter on custom drawables
|
EGHDK |
So do I use the LayerList XML or LayerList Class?
|
Mark M. |
including LayerDrawable and ShapeDrawable there, plus a separate bit of coverage of nine-patch PNGs elsewhere
|
Mark M. |
that depends whether you wish to assemble the layers in Java or in XML
|
EGHDK |
I guess if I want them to be easily customizeable... I would do them in Java?
|
Mark M. |
if you are letting users choose one of millions of colors, perhaps
|
Mark M. |
if you are giving the user a choice of one, say, a dozen colors, perhaps not
|
Mark M. |
with respect to drawing your own custom Views using the Canvas, that is not in my book, though it is in others, plus various blog posts and such
|
Mark M. |
if anyone has any questions, chime in
|
Oct 15 | 4:25 PM |
EGHDK |
Okay I will try LayerDrawable Class.
|
Sean D. |
Oh I had another question... I was trying StrictMode in my app and I've been getting disk read errors coming from the Maps API... for example, inflating a map inside my fragment
|
Sean D. |
Is there anything I can do about those or are they out of my control?
|
Mark M. |
probably they are out of your control
|
Mark M. |
unfortunately, too many things with Maps V2 need to be on the main application thread
|
Sean D. |
Oh, okay
|
Mark M. |
I'd file an issue with the Maps team if you can document a scenario
|
Sean D. |
Thanks
|
Alex |
when an overscroll is performed, is the actual listview being shifted down? or is the space that appears above the listview part of the listview?
|
Mark M. |
Alex: sorry, I do not know how overscroll works
|
Alex |
darn, ok. thanks anyway
|
Oct 15 | 4:30 PM |
Mark M. |
if anyone has any questions, chime in
|
Oct 15 | 4:35 PM |
Gabriele |
is there any specific reason why no pdf reader have tabs, on android?
|
Mark M. |
no clue, sorry
|
Oct 15 | 4:40 PM |
Sean D. | has left the room |
Oct 15 | 4:45 PM |
EGHDK |
Hey Mark, so for one of my apps, I just push the same notification. But I just got a screenshot from one of my users that the notifications icons in his notification tray (not pulled down) are different sizes. Any ideas?
|
Mark M. |
sorry, I do not understand your question
|
EGHDK |
So my application sends notifications to the top bar across the top of the phone.
|
Oct 15 | 4:50 PM |
Mark M. |
OK
|
Oct 15 | 4:50 PM |
EGHDK |
It only has one icon it uses for that top bar of the phone. Yet, on one persons device, my app has two notifications in the top bar, right next to each other. But they are different sizes.
|
EGHDK |
Tiny detail, but wondering if you've encountered that before.
|
Mark M. |
I still do not understand. You seem to be simultaneously saying that you are only showing one Notification and showing two Notifications. Since 1!=2, I am lost
|
Gabriele |
Mark, thank you, see you the next time! Bye all :)
|
Gabriele | has left the room |
Oct 15 | 4:55 PM |
EGHDK |
Eh. Not that important I guess. My application pushed two identical notifications. SO there are two icons in the top bar. One icon is smaller than the other for some reason.
|
Mark M. |
you are using the same drawable resource for both?
|
EGHDK |
Yep.
|
Mark M. |
I can't explain that, outside of a device (or possibly home screen) bug
|
EGHDK |
okay cool
|
EGHDK |
Before todays chat is over... do you have any thoughts on 4.4? =)
|
Mark M. |
I think Android 4.4 is chocolate coated, with crispy wafers inside
|
Mark M. |
I am guessing that it might not come out until after October 22, to come out after Apple's iPad announcements
|
Mark M. |
but that's just a guess
|
EGHDK |
Nice. Haven't been able to find one myself though. Disappointed. Really looking forward to the first time I see a candy bar wrapper with a bugdroid on it.
|
EGHDK |
Yeah, I was hoping for today. And then KitKat posted that song lyric on Google Plus, and everyone thinks the date is now October 18th.
|
Mark M. |
Friday would be an odd launch day
|
Mark M. |
can't rule it out, of course, but firms usually like to do launches earlier in the work week, for better media coverage
|
Oct 15 | 5:00 PM |
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
next one is Thursday at 10am Eastern
|
Alex | has left the room |
EGHDK |
Hmm... that true. Alright, well thanks for pointing me in the right direction for the drawables. I'll be back tomorrow morning if I can't figure it out.
|
Mark M. |
this chat transcript will be archived at http://commonsware.com/office-hours/ shortly
|
Mark M. |
have a pleasant day!
|
EGHDK | has left the room |
Mark M. | turned off guest access |