Jul 21 | 9:50 AM |
Mark M. | has entered the room |
Jul 21 | 9:55 AM |
Mark M. | turned on guest access |
Jul 21 | 10:05 AM |
Mike | has entered the room |
Mike |
Hi Mark!
|
Mark M. |
howdy, Mike!
|
Mark M. |
how can I help you today?
|
Jul 21 | 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?
|
Mark M. |
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()
|
Mark M. |
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
|
Mark M. |
but that's not a "static state object", by my interpretation of that phrase
|
Mike |
Yeah, sorry... U'r right.
|
Mark M. |
OK, whew
|
Mark M. |
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?
|
Mark M. |
(btw, howdy, Troy!)
|
Mike |
No it's for the activity.
|
Mark M. |
Mike: OK
|
Troy w. |
Hi guys whats going on?
|
Jul 21 | 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
|
Troy w. |
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
|
Mark M. |
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
|
Mark M. |
objects are objects are objects
|
Mark M. |
it's not like ListView somehow "knows" that your object list is in a state object
|
Mark M. |
something must be wrong in how you are reconnecting the state object to the new activity after the configuration change
|
Jul 21 | 10:20 AM |
Mike |
Well it doesn't even work without a config change.
|
Mark M. |
then you have more fundamental problems
|
Mark M. |
again, objects are objects are objects
|
Mark M. |
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.
|
Mike |
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
|
Mark M. |
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
|
Jul 21 | 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
|
Mark M. |
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
|
Mark M. |
Troy: do you have a question?
|
Mike |
So the problem must be somewhere else.
|
Mike |
I think that's more or less all wanted to ask you,...
|
Mike |
Will try to fix it.
|
Mike |
Thanks!
|
Troy w. |
okay so i have a gallery that loads images from a url into the view.
|
Troy w. |
Ive already masted the code for that segment.
|
Troy w. |
the only problem is every time the view is swiped. the images are fetched over again
|
Troy w. |
which makes it sluggish.
|
Mark M. |
you need to cache the downloaded images
|
Jul 21 | 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
|
Mark M. | |
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
|
Mark M. |
so, time and effort is how I got to where I am
|
Troy w. |
Cool! But how do you use this imageloader jar?
|
Troy w. |
How does it work?
|
Mark M. |
personally, I've never used that one
|
Mark M. |
I wrote some myself, but they're not very good
|
Mark M. |
I'll be rewriting them later this year
|
Mark M. |
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
|
Mark M. | |
Troy w. |
okay hmm ill check it out and hit stackoverflow if i need more help with some.
|
Jul 21 | 10:35 AM |
Mark M. | |
Mark M. |
I mean, there's gotta be 10-20 of the things floating around
|
Mark M. |
do a Google search: android image caching
|
Mark M. |
if anyone has another question, chime in
|
Mike |
Already done Troy?
|
Mike |
Well I do have another one:
|
Mike |
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.
|
Mike |
Me too btw.
|
Mark M. |
particularly since the alternative is deprecated
|
Mike |
Really?! Didn't know that.
|
Jul 21 | 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.
|
Mike |
I saw that you mentioned to use a ViewFlipper for such a functionality....
|
Mike |
...so to create your "custom tabs".
|
Mike |
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
|
Mark M. |
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
|
Mark M. |
that's perfectly fine
|
Mike |
Limited in which way?
|
Mark M. |
TabWidget is a Java class
|
Jul 21 | 10:45 AM |
Mark M. |
it has certain code in it
|
Mark M. |
that code does certain thihngs
|
Mark M. |
er, things
|
Mark M. |
not all of that behavior is necessarily changeable
|
Mark M. |
and it doesn't necessarily take into account every possible tab metaphor
|
Mark M. |
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
|
Mark M. |
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!
|
Mark M. |
presumably, yes
|
Mike |
Well, thank you very much Mark for your answers...
|
Mike |
...cu.
|
Mark M. |
Troy: do you have another question?
|
Mike | has left the room |
Jul 21 | 10:50 AM |
Troy w. |
I found a answer on stack about caching the url
|
Troy w. |
alot of people voted it up and said it works so im going to try it out now
|
Mark M. |
sounds good
|
Mark M. |
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
|
Mark M. |
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.
|
Troy w. |
and i thought you already had a ton of apps out there
|
Troy w. |
you can probably build just about anything.lol
|
Mark M. |
oh, heck no
|
Mark M. |
there are many, many things in Android that I am unskilled for, mostly games
|
Troy w. |
why not?
|
Jul 21 | 10:55 AM |
Mark M. |
I haven't done game development since the late 1980's
|
Mark M. |
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.
|
Troy w. |
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.
|
Troy w. |
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 :-)
|
Mark M. |
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
|
Troy w. |
YESS!! it is man!
|
Jul 21 | 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
|
Mark M. |
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
|
Mark M. |
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 |