Mark M. | has entered the room |
Mark M. | turned on guest access |
Jan 30 | 9:55 AM |
EGHDK | has entered the room |
Jan 30 | 10:00 AM |
EGHDK |
Morning Mark, so I have two more questions since Tuesday.
|
Mark M. |
howdy, EGHDK!
|
Mark M. |
(sure wish this chat would "ding" when somebody entered the room...)
|
Mark M. |
go ahead with your first question
|
EGHDK |
First one, is that I am using dates/calendar a lot. So I have a Calendar.MONTH which gives me an int, but now I want to display it to the user as a string (March, April, May...) whats the best way to do that?
|
Mark M. |
off the cuff, probably SimpleDateFormat
|
EGHDK |
I feel like I can hard code it and have a whole bunch of if statements but I feel like there could be an easier way
|
Mark M. |
yeah, even Google's former alternative has been deprecated in favor of SimpleDateFormat
|
Mark M. | |
Mark M. |
the fourth one, using "MMMM" as the format, is probably what you want
|
Mark M. |
bonus: it's already locale-aware, and hence will return proper names based on the device language
|
EGHDK |
What was google former alternative?
|
Mark M. |
the DateUtils class has a getMonthString() method
|
Mark M. |
deprecated in API Level 17
|
Mark M. |
and, frankly, not that much simpler than SimpleDateFormat
|
EGHDK |
Hmm... interesting. Alright cool.
|
EGHDK |
So wait, I'm originally starting with a unix timestamp, is there any way to convert that to "March 21, 2013" lets say?
|
Jan 30 | 10:05 AM |
Mark M. |
again, SimpleDateFormat
|
Mark M. |
standard Java stuff
|
EGHDK |
Still got to pick me up a java book.
|
EGHDK |
well actually I picked up head first.
|
EGHDK |
Just haven't read it through yet.
|
EGHDK |
Alrighty, second question. I looked at your tutorial for Reverse chronometer. Works great actually.
|
EGHDK |
Let me tell you how I'm implementing it, so let me know if I'm doing something wrong.
|
Jan 30 | 10:10 AM |
Emmanuel | has entered the room |
EGHDK |
I have a listview, and every list item has this chronometer
|
Mark M. |
(hello, Emmanuel -- I will be with you shortly!)
|
EGHDK |
In getView that when I do the setting of the time. and then chorno.run()
|
EGHDK |
So that works fine.
|
Emmanuel |
ok thanks
|
EGHDK |
But in your book, your example says to pause or stop in onPause or onStop I think.
|
EGHDK |
Do I have to do that at all?
|
Mark M. |
you pause when you want the countdown to pause
|
Mark M. |
you stop when you want the countdown to stop
|
Mark M. |
the business rules for that are up to you
|
EGHDK |
Okay, I never want them to pause or stop
|
EGHDK |
But I thought the timer might keep running if I exit the activity or something.
|
EGHDK |
and get a memory problem somewhere.
|
Mark M. |
there is no timer
|
Mark M. |
the implementation should use postDelayed(), if I am not mistaken
|
Mark M. |
and that *will* keep running until the activity is destroyed
|
EGHDK |
Okay, so I shouldl be good to go then.
|
Mark M. |
that's part of the reason for the pause and stop recommendations
|
EGHDK |
Great.
|
Jan 30 | 10:15 AM |
Mark M. |
once the activity is no longer in the foreground, it can go *poof* at any point
|
Mark M. |
if you need to maintain timing information when you are not in the foreground, you will need to do so persisetntly
|
EGHDK |
I maintain it persistenly.
|
Mark M. |
OK
|
EGHDK |
And I grab that persistent time when I set the time to the chrono
|
Mark M. |
Emmanuel: your turn! do you have a question?
|
EGHDK |
But I thought maybe I have to stop the chorno when it gets off of the listView. But it seems I do not.
|
Mark M. |
EGHDK: the row will be recycled, and you will have to address that
|
Emmanuel |
yes I do
|
EGHDK |
I do. But, again. I don't have to call stop on the chronometer correct?
|
Mark M. |
Emmanuel: go right ahead
|
Emmanuel |
I was playing around with Fragments
|
Emmanuel |
I created a custom row
|
Emmanuel |
so I can use with a ListView
|
Emmanuel |
this row contained and ImageButton and some TextView
|
Emmanuel |
s*
|
Emmanuel |
the problem is that it seems that the ImageButton "steals" the focus of the row
|
Emmanuel |
and it makes it non clicable
|
Emmanuel |
clickable*
|
Jan 30 | 10:20 AM |
Mark M. |
there is some recipe for dealing with this, though I forget the details
|
Emmanuel |
I tried every way possible to make the ImageButton non focusable
|
Emmanuel |
I ended up removing the ImageButton and using an ImageView
|
Emmanuel |
and it worked perfectly
|
Emmanuel |
I even tried to switch to ListFragment
|
Mark M. |
this has nothing to do with fragments
|
Mark M. | |
Mark M. | |
Emmanuel |
tried both of them...
|
Mark M. |
then I cannot help you further, sorry
|
Mark M. |
personally, I avoid this scenario
|
Emmanuel |
my question was if this is considered a bug?
|
Mark M. |
(other than the one RatingBar book sample, and there I do not care about clicks on rows)
|
Mark M. |
I cannot answer that
|
Mark M. |
again, I disagree with the approach
|
Emmanuel |
oh
|
Emmanuel |
ImageButtons or ImageViews in rows are a nono?
|
Mark M. |
it's more that widgets inside of an AdapterView should not themselves be focusable/clickable
|
Mark M. |
independently of the row itself
|
Jan 30 | 10:25 AM |
Emmanuel |
ohhh
|
Mark M. |
now, not everyone agrees with me, including Google, who uses their little "..." stuff in their cards in places like the Play Store app
|
Emmanuel |
right
|
Mark M. |
but I do not know the technique for getting that to work
|
Emmanuel |
but what you are saying makes sense
|
Mark M. |
and I cannot quite fathom how I'd get accessibility working in the Play Store scenario
|
Mark M. |
for "sub-actions" in a ListView row, I would use a contextual action bar
|
Emmanuel |
I will have to look into that
|
Mark M. |
long-press to bring up the contextual action bar (a.k.a., action mode), where the user can perform operations on selected items
|
Mark M. |
but, that may not be appropriate in all scenarios either
|
Emmanuel |
lol
|
Mark M. |
my overall point is: I don't know the answer to your question, sorry
|
Emmanuel |
no problem, thanks
|
Mark M. |
EGHDK: do you have another question?
|
Jan 30 | 10:30 AM |
Mark M. |
OK, if anyone has a question, go ahead
|
Emmanuel |
have you played with BLE?
|
Mark M. |
if you mean Bluetooth Low-Energy, no
|
Emmanuel |
yeah
|
Emmanuel |
ohh ok
|
Jan 30 | 10:35 AM |
Emmanuel |
this might be off-topic, but have you ever considered stopping by the Android chat room in SO?
|
Emmanuel |
(not for tech support, just to hang out)
|
Emmanuel |
you probably have no time...
|
Mark M. |
went there a bit after they opened it up
|
Emmanuel |
oh
|
Mark M. |
I elected to draw the line at keeping chats something just for subscribers
|
Emmanuel |
I see
|
Mark M. |
so I do not do SO chats, whether per-answer or the topic-specific rooms
|
Emmanuel |
we get the privilege, lol
|
Emmanuel |
fair enough
|
Emmanuel |
have you played with Arduino/Android stuff for home automation?
|
EGHDK |
When I have an outside class that does something, but it needs a context, and I call that method from an activity, I usually just pass in "this" as an arguement. Should I not pass in this since it's an activity and thats pretty big? Should I just take the activities context and do that instead since context is a "smaller" object than "activity"?
|
Jan 30 | 10:40 AM |
Emmanuel |
(by stuff I mean gadgets that involve both platforms)
|
codeMagic | has entered the room |
Mark M. |
Emmanuel: no, I have not done much of anything dealing with connecting Android devices to accessories, outside of a couple of wearables
|
Mark M. |
(hello, codeMagic, be with you shortly!)
|
Mark M. |
EGHDK: there is no "activities context"
|
EGHDK |
What happens when I pass in `this`
|
Mark M. |
Activity inherits from Context
|
codeMagic |
Hello, all! Ok, Mark M.
|
Mark M. |
hence, Activity is a Context
|
Mark M. |
an Activity instance is not smaller than itself
|
Mark M. |
just as 1 is not smaller than 1
|
Mark M. |
this is a reference to an object, an instance of some class
|
EGHDK |
Should I be using this (activity) to pass into a method?
|
Mark M. |
typically that is fine
|
Mark M. |
I believe I pointed you to http://www.doubleencore.com/2013/06/context/ last time
|
EGHDK |
Okay, I just feel like I'm passing this huge monolithic activity sometimes, and that it may be causing a memory issue.
|
Mark M. |
there are certain circumstances when you need to choose certain Context implementations
|
Emmanuel |
That link is amazing, everyone should read it!
|
Mark M. |
Java is pass-by-reference for objects, not pass-by-value
|
EGHDK |
Yeah, like getAppContext for DB if I want to be thread safe.
|
Mark M. |
you are not copying the Activity instance
|
EGHDK |
Mark M, I think Java is "pass by value, which is pass by copy"?
|
Mark M. |
codeMagic: do you have a question?
|
Mark M. |
(EGHDK: absolutely incorrect)
|
EGHDK |
Damn Head First Java has me confused.
|
codeMagic |
I mostly wanted to check it out as I just signed up for your subscription
|
Jan 30 | 10:45 AM |
Mark M. |
ah, OK
|
Mark M. |
mostly, it's live Q&A
|
Mark M. |
you are certainly welcome to just hang out
|
codeMagic |
Actually, do you have any printing experience with the new framework?
|
Mark M. |
but that's not really the role
|
codeMagic |
Ok, is it alright to stop by and see what people are asking?
|
Mark M. |
not yet, though that's comparatively high on my todo list
|
codeMagic |
Ah, ok
|
Mark M. |
the downside of joining the chat just to lurk is that, AFAIK, you are not seeing the transcript of what went on before you arrived
|
Mark M. |
I post all transcripts to http://commonsware.com/office-hours/ as well
|
codeMagic |
I need to implement printing and been having hard time with with USB and the Brother SDK though got WIFi to work fine
|
EGHDK |
View paste
|
Mark M. |
so, you do not need to join the chat just to see what people are asking
|
codeMagic |
Nope, don't see what was before just since I joined
|
Mark M. |
EGHDK: only for primitives (int, float, double, boolean, etc.)
|
codeMagic |
Thanks for the transcript link
|
Mark M. |
EGHDK: Java is pass-by-reference for objects
|
EGHDK |
Okay, maybe I should read further into the book... HAH
|
Mark M. |
codeMagic: yeah, that's one of the limitations of Campfire
|
EGHDK |
Maybe theres a twist like you say...
|
Mark M. |
EGHDK: well...
|
Mark M. |
it depends a bit on what you consider "value" to be
|
Mark M. |
most people would consider pass-by-value for an object to mean "make a copy of the object"
|
Jan 30 | 10:50 AM |
Mark M. |
a pedantic definition would be more like "well, we are making a copy of the pointer to the memory location, so it is pass-by-value"
|
Mark M. |
and so you wind up with stuff like http://stackoverflow.com/a/73021/115145
|
Mark M. |
and that may be what the book is saying
|
Mark M. |
if anyone has a question, chime in
|
Jan 30 | 10:55 AM |
codeMagic |
When you get to the printing framework, where should I look for your info on that, your blog?
|
codeMagic |
I plan to dig into it soon as I need a printing solution and it looks interesting
|
Mark M. |
I doubt I'll be blogging about it
|
Mark M. |
it will turn up in a book update eventually
|
codeMagic |
But I imagine you might get further faster than me
|
codeMagic |
Ah, ok
|
Mark M. |
well, since I am not working on printing right now, you have a significant head start
|
codeMagic |
Unfortunately, there isn't much about it yet with it being so new. But I'm sure I will figure something out when I get time to dig in
|
Mark M. |
printing is one of those things I need to get to, but it's a long list :-)
|
codeMagic |
Undersanable, I know how that is
|
Mark M. |
also, since it's mostly KitKat-only, it's not a super-high priority until there are more KitKat devices
|
Mark M. |
(and, no, the candy bars don't count)
|
codeMagic |
:)
|
Mark M. |
(unless they have a working "Print" button... :-)
|
Emmanuel |
Are you planing in adding an OpenGL ES 2.0 chapter to the book?
|
Mark M. |
Emmanuel: no, as there are whole books on that subject
|
Mark M. |
I couldn't do it justice
|
Emmanuel |
ohh ok. I started reading one that is specific to Android, but wondered if you were going to add something later. Ok.
|
Mark M. |
the big challenge for me this year is yet another book overhaul, to deal with Android Studio/Gradle and a pivot to API Level 14 as a foundation (e.g., de-emphasize ActionBarSherlock)
|
Mark M. |
and, since I have no idea when Android Studio is going to sufficiently stabilize, I have some difficulty planning my year
|
Jan 30 | 11:00 AM |
Emmanuel |
are you always going to support Eclipse?
|
Emmanuel |
or eventually you are going to move completely to AS?
|
Mark M. |
I'll support it as long as Google is
|
Emmanuel |
ok
|
Mark M. |
Ant support will fade out, as that will be replaced totally by Gradle
|
Emmanuel |
right
|
Mark M. |
and I expect Google to punt on Eclipse support eventually
|
Emmanuel |
I believe so, but some people think they will support Eclipse for ever...
|
Mark M. |
most of the book, outside of the tutorials, is fairly IDE-agnostic
|
Emmanuel |
yeah
|
Mark M. |
those are the same people that thought Google would support Google Reader forever... :-)
|
Emmanuel |
LOL
|
Mark M. |
anyway, that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Emmanuel |
see you later. Thanks.
|
codeMagic |
Thanks for letting me stop in and hang out. I look forward to your memory talk at AnDevCon
|
Mark M. |
the next chat is Tuesday at 4pm US Eastern Time
|
Mark M. |
codeMagic: you and me both! :-)
|
Mark M. |
have a pleasant day!
|
Emmanuel |
you too
|
codeMagic |
You also. Thanks
|
EGHDK | has left the room |
Emmanuel | has left the room |
codeMagic | has left the room |
Mark M. | turned off guest access |