Office Hours — Today, July 21

Thursday, July 14

Jul 21
9:50 AM
Mark M.
has entered the room
9:55 AM
Mark M.
turned on guest access
10:05 AM
Mike
has entered the room
Mike
Hi Mark!
Mark M.
howdy, Mike!
how can I help you today?
10:10 AM
Mike
In one of my applications I am following one of your suggestions to store the current state of an activity in a static state object.
Mark M.
that was a suggestion of mine?
data model caching should be in static data members
Mike
...to survive config changes etc.
Mark M.
activity state should be in the onSaveInstanceState() Bundle or via onRetainNonConfigurationInstance()
if you stumble upon wherever I made that suggestion, let me know, so I can nuke that page from orbit :-)
Mike
Well I think i remember to know it from an ASyncTask example?!
Mark M.
um, well, AsyncTasks should be a static inner class
but that's not a "static state object", by my interpretation of that phrase
Mike
Yeah, sorry... U'r right.
Mark M.
OK, whew
now, back to your problem
Mike
Well in that "state object" I also want to save a list of object which is used as the source for an adapter for a ListView.
Troy w.
has entered the room
Mark M.
is that truly state data for the activity, or is that really a data model?
(btw, howdy, Troy!)
Mike
No it's for the activity.
Mark M.
Mike: OK
Troy w.
Hi guys whats going on?
10:15 AM
Troy w.
Hey mark your books are GREATE. subcribing to this was the best thing i have done for my development career
GREAT*
Mark M.
Troy: just answering questions -- I'll get to one of yours after wrapping up Mike's, and thanks for the kind words
Mike: go ahead
Mike
I recognized that when trying to update the ListView (by notifying the corresponding adapter) I doesn't have any effect as long as the object remains the the (inner static) state object.
Mark M.
that does not make any sense
Mike
As soon as I have the object list (serving as the source of my adapter) as a class member of the activity (but not of the state object), it works great.
Mark M.
that does not make any sense, either
objects are objects are objects
it's not like ListView somehow "knows" that your object list is in a state object
something must be wrong in how you are reconnecting the state object to the new activity after the configuration change
10:20 AM
Mike
Well it doesn't even work without a config change.
Mark M.
then you have more fundamental problems
again, objects are objects are objects
it is virtually impossible for me to give you guidance, other than "you need to debug your problem"
Mike
O.K. - I'll try it once again.
I have my custom adapter for the list view, holding the objects which I want to display wihtin the listview.
Mark M.
is this an ArrayAdapter on an ArrayList?
Mike
ArrayAdapter
Mark M.
OK, and your state object holds the ArrayList?
Mike
Yeah.
Mark M.
and you are modifying the contents via add(), insert(), and remove() on the ArrayAdapter?
Mike
Yep.
Mark M.
that should work just fine
ArrayAdapter neither knows nor cares that the ArrayList is held in a state object vs. some other data member
Mike
Hmm.... So it should't make any differences where I "hold" that ArrayList?!
Mark M.
within one activity? no
10:25 AM
Mike
Yes within the same activity.
Mark M.
it matters when you deal with configuration changes, which is why you have it in a state object
Mike
Yes - That is exactly why I have the state object.
Mark M.
but within one activity, you don't even need to "hold" the ArrayList anywhere else other than within the ArrayAdapter
the fact that you happen to have a reference to that ArrayList from a state object should not impact the ArrayAdapter at all
Mike
O.K. - That's what I had expected.
Mark M.
let me take a question from Troy, and I'll swing back to you in a bit
Troy: do you have a question?
Mike
So the problem must be somewhere else.
I think that's more or less all wanted to ask you,...
Will try to fix it.
Thanks!
Troy w.
okay so i have a gallery that loads images from a url into the view.
Ive already masted the code for that segment.
the only problem is every time the view is swiped. the images are fetched over again
which makes it sluggish.
Mark M.
you need to cache the downloaded images
10:30 AM
Troy w.
Hmmm..Okay how would i go about doing this? Thats the same thing another person suggested
Mark M.
plenty of implementations of that floating around
Troy w.
okay cool! ill have a look at that and try it out. one more thing...How did you become a master at this? i know its a little off subject but reading your books ive been wanting to know
Mark M.
I've been working in Android since early 2008
so, time and effort is how I got to where I am
Troy w.
Cool! But how do you use this imageloader jar?
How does it work?
Mark M.
personally, I've never used that one
I wrote some myself, but they're not very good
I'll be rewriting them later this year
I think GreenDroid has their own image caching
Troy w.
Do you know of any other good ones your familiar with
Mark M.
not really
Troy w.
okay hmm ill check it out and hit stackoverflow if i need more help with some.
10:35 AM
Mark M.
I mean, there's gotta be 10-20 of the things floating around
do a Google search: android image caching
if anyone has another question, chime in
Mike
Already done Troy?
Well I do have another one:
With regard to tabs.
Troy w.
Yeah im doing some research now in google
Mike
I know that you like the approach to use Views "instead" of Activities in Tabs.
Me too btw.
Mark M.
particularly since the alternative is deprecated
Mike
Really?! Didn't know that.
10:40 AM
Mark M.
ActivityGroup was deprecated in the new 3.2 release
Mike
Ah - O.K.
Mark M.
which means TabActivity is deprecated by extension
Mike
Well back to my question...
Mark M.
anyway, regardless, go ahead
Mike
I studied your books because I was creating my own TabActivity with its own Widgets.
I saw that you mentioned to use a ViewFlipper for such a functionality....
...so to create your "custom tabs".
I was wondering why not only changing the views being used as the "tab headers"?!
Mark M.
well, you can use setIndicator(View v), and you might be able to change more by theming
but, in the end, you are limited by how the people who wrote TabWidget wanted to do things
Mike
Yes that's what I did. Anything wrong with that approach.
Mark M.
no
that's perfectly fine
Mike
Limited in which way?
Mark M.
TabWidget is a Java class
10:45 AM
Mark M.
it has certain code in it
that code does certain thihngs
er, things
not all of that behavior is necessarily changeable
and it doesn't necessarily take into account every possible tab metaphor
for example, if you want to do a Firefox-style "bunch of tabs, then a drop-down on the right for the overflow", I doubt that you can wrestle TabWidget to do that
maybe you can, but I wouldn't count on it
Mike
But as long as I only want to have different layouts of the tabwidgets (but the same functionality) I can simple inflate the layout, right?!
Mark M.
if you want tabs that are structurally akin to TabWidget, and setIndicator() and themes get you the look you want, great!
presumably, yes
Mike
Well, thank you very much Mark for your answers...
...cu.
Mark M.
Troy: do you have another question?
Mike
has left the room
10:50 AM
Troy w.
I found a answer on stack about caching the url
alot of people voted it up and said it works so im going to try it out now
Mark M.
sounds good
I'll be covering this subject in greater detail later this year in _Tuning Android Applications_
Troy w.
So mark, do you have any applications on the market? and Cool i have all your books on my tablet. Beginning android 3 now also.
Mark M.
_Beginning Android 3_ is basically _The Busy Coder's Guide to Android Development_, so there's nothing new there
I have apps on the Market, but not under my name -- done under contract
Troy w.
LOL im glad you told me that because reading it i seen that.
Mark M.
I plan on doing more engineering work late this year into next, with an eye towards getting apps of my own in the Market
Troy w.
but i want to be supportive of your cause.
and i thought you already had a ton of apps out there
you can probably build just about anything.lol
Mark M.
oh, heck no
there are many, many things in Android that I am unskilled for, mostly games
Troy w.
why not?
10:55 AM
Mark M.
I haven't done game development since the late 1980's
not high on my list of things to get back into
Troy w.
Me too, Have you ever tried to release a killer app on the market?
Mark M.
again, the only apps I have done for the Market were done on a consulting basis
Troy w.
Games are difficult i tried to get into it with books, i was lost. i would need a instructor for that.
Mark M.
I would say that none of them were destined to be "killer apps"
Troy w.
Thats amazing man! Im really amazed at that.
I wasnt even born in the 1980's
Mark M.
yup, I'm old
Troy w.
You look like your in your 30's from your pictures. Thats what i thought.
So do you think its smart to start your own android dev company?
Mark M.
well, I was missing my hair in my 30's too :-)
if you have a business plan, getting into mobile now is an exciting area
Troy w.
LOL for real. dont feel bad man, almost 65% of men are bald or have some thinning
YESS!! it is man!
11:00 AM
Troy w.
Everyday i wake up im excited about it. I love this stuff, i definitely think ive found my "niche"lol but not alot of colleges offer courses for it
Mark M.
yes, a few colleges teach mobile development, but not many
anyway, that's a wrap for today's chat
Troy w.
I bet you still get LOT's of women though. lol =D
Mark M.
another one tomorrow, 4pm Eastern
have a pleasant day!
Troy w.
okay cool, ill be here thanks again mark!
Troy w.
has left the room
Mark M.
turned off guest access

Thursday, July 14

 

Office Hours

People in this transcript

  • Mark Murphy
  • Mike
  • Troy walker