Oct 7 | 9:50 AM |
Mark M. | has entered the room |
Oct 7 | 9:55 AM |
Mark M. | turned on guest access |
Oct 7 | 10:00 AM |
icecreamman | has entered the room |
Mark M. |
howdy, icecreamman!
|
icecreamman |
hello. i just received my subscription this morning via email from you in fact
|
Mark M. |
I think I commented on one of your SO questions this morning as well, though I forget which one
|
Mark M. |
regardless, how can I help you?
|
icecreamman |
ah, yep. thats why i am here. i didn't see that
anyone had responded yet. it is just been very frustrating trying to
learn these things without guidance.
|
icecreamman |
i will run through your example in the link and see if it works out better
|
icecreamman |
now i also have all of these great pdf resources to hopefully help my understanding
|
Mark M. |
ah, yes, that question
|
Mark M. |
it's sure not obvious where your code as listed is going wrong
|
Mark M. |
(for the purposes of the transcript, the question is http://stackoverflow.com/questions/3879159…)
|
Oct 7 | 10:05 AM |
Mark M. |
are you trying this in the emulator or a device?
|
icecreamman |
this is all emulator
|
icecreamman |
build 2.2 i believe
|
Mark M. |
well, the Maps/NooYawk sample definitely works there
|
Mark M. |
anything unusual about your icon?
|
icecreamman |
nope, its the one straight from the tutorial. the
only thing that i thought was weird is i have no explicity 'drawable'
folder - there exist drawable-hdpi, drawable-mdpi, etc... but the icon
does show up under my generated resources file, and it does appear if i
don't pass a context to the itemizedoverlay constructer
|
icecreamman |
its just very weird
|
Mark M. |
make a res/drawable/ directory and put it in there
|
icecreamman |
ha, funny thing is, i already tried that to no avail :(
|
Mark M. |
I don't understand the "it does appear if i don't pass a context to the itemizedoverlay constructer" part
|
Mark M. |
you aren't using that parameter anywhere, at least in the code you have in the SO question
|
Mark M. |
well, except in the Dialog constructor, which won't be triggered until after the icon is displayed
|
Oct 7 | 10:10 AM |
icecreamman |
gotcha. so midway through the MapActivity i have the following line:
|
icecreamman | |
icecreamman |
and i believe 'this' is the context of the application?
|
Mark M. |
'this' is the Activity
|
Mark M. |
in Java, it refers to the current object
|
Mark M. |
akin to self in Ruby
|
Mark M. |
or self in Smalltalk
|
icecreamman |
ahh. duh. so i *believe* that the ItemizedOverlay
requires a reference to the entire context (this is like a process id
if we are talking about threads, no?).
|
icecreamman |
so by passing it the activity, i am doing something incorrect...?
|
Mark M. |
ItemizedOverlay itself does not
|
Mark M. |
Context is a superclass of Activity
|
Mark M. |
and it has nothing much to do with process IDs
|
Mark M. |
in your HelloItemizedOverlay implementation, you are:
|
Mark M. |
1. accepting the Context as a parameter in the constructor
|
Mark M. |
2. storing that in a data member of your HelloItemizedOverlay
|
Mark M. |
3. using it in the constructor of your AlertDialog.Builder
|
Mark M. |
all of that is fine, but I can't quite see how that would impact whether the icon is visible
|
Oct 7 | 10:15 AM |
Mark M. |
I'm going to take a guess that you're new to Java as well as Android?
|
icecreamman |
yes, sadly.
|
Mark M. |
that's OK
|
Mark M. |
however, you may want to spend a bit of time playing with Java outside of Android first
|
Mark M. |
Android is plenty weird on its own :-)
|
icecreamman |
agreed
|
dhaupert | has entered the room |
Mark M. |
here is a blog post with a list of the topics of importance in Java for Android developers: http://commonsware.com/blog/2010/08/02/jav…
|
Mark M. |
welcome, dhaupert!
|
dhaupert |
Hi Mark, thanks for having this and for the great helpful book!
|
Mark M. |
icecreamman: regardless, try the Maps/NooYawk sample app, see if it runs for you
|
icecreamman |
ah thank you. well i am going to spend the next
while scouring all of resources. the sample app seems to be more
extensive, so that should be a good starting point. have a great day
|
icecreamman | has left the room |
Mark M. |
dhaupert: how can I help you today?
|
dhaupert |
I have been struggling with the android:launchMode
options, which aren't really covered in the book and the description
Google provides sent me in the wrong direction.
|
Mark M. |
yeah, someday I'll add an chapter on manifest tricks to the Advanced Android book
|
Mark M. |
soooooooooo much needs to be written...
|
dhaupert |
My app has a hierarchy of activities such that if Android decides to kill one of them, the rest are pretty much of no use
|
Oct 7 | 10:20 AM |
dhaupert |
I was hoping for a mode where I could say 'if you
have to kill any activity, kill the whole task'. But I don't see that
being possible.
|
Mark M. |
no, Android is designed around lots of independent activities
|
Mark M. |
key here being "independent"
|
Mark M. |
if they are so tightly coupled that they should live and die as a whole, make them a single activity
|
Mark M. |
think of it as a "UI transaction", if you will
|
Mark M. |
or, come up with a model to make them be more independent
|
dhaupert |
so have a single activity but change the content view around
|
dhaupert |
?
|
Mark M. |
yes, or use a ViewFlipper, whichever fits better
|
dhaupert |
I will check into ViewFlippers- never heard of that.
|
Mark M. |
think of it as being like TabHost, minus the tabs
|
Mark M. |
or like a CardLayout in Swing
|
Mark M. |
several children, only one of which is visible at a time
|
Mark M. |
also supports animations on transitioning between children
|
Mark M. |
and a few other fun features to boot
|
dhaupert |
That sounds like exactly what I needed.
|
Oct 7 | 10:25 AM |
dhaupert |
(trying to remember what my other question was!)..
|
Mark M. |
take your time -- nobody else here at the moment
|
dhaupert |
Just looking at viewflipper and it doesn't seem
like you can control which view to show- more like a load and forget
type of animation.
|
Mark M. |
methods on the superclass
|
Mark M. |
setDisplayedChild()
|
dhaupert |
ah
|
Mark M. |
showNext()
|
Mark M. |
showPrevious()
|
Mark M. |
it's possible you could just use a ViewAnimator -- I had been thinking that was abstract, but it looks like it's not
|
dhaupert |
Of course at this point I have the app just about done so it would involve converting a lot of screens from being activities.
|
dhaupert |
How does the concept of View translate over from what was already an activity?
|
Mark M. |
well
|
Mark M. |
in your case, the simplest thing to do is probably:
|
Mark M. |
Step #1: create a new activity that will represent the combined UI
|
Mark M. |
Step #2: give it a layout file that is just a full-screen ViewFlipper
|
Mark M. |
Step #3: In onCreate(), call
addView(getLayoutInflater().inflate(R.layout.something)) on the
ViewFlipper, for each of the layouts from your independent activities
|
Oct 7 | 10:30 AM |
Mark M. |
Step #3a: you may need to change some of the widget IDs in those layouts, if you used the same names
|
dhaupert |
(I try not to)
|
Mark M. |
Step #4: Copy over the guts of the other activities into the new one
|
Mark M. |
e.g. event handlers, other lifecycle methods
|
Mark M. |
Step #5: update your manifest to have the new activity be the LAUNCHER one
|
Mark M. |
Step #6: test, test, test
|
Mark M. |
Step #7: nuke the old activities
|
Mark M. |
you could combine all the layouts into one
|
Mark M. |
or you could use <include> in the new activity's layout to avoid the addView() calls
|
dhaupert |
so I couldn't keep each of the former activities
as some sort of separate class? It would get kind of messy having them
all in the same class
|
Ciaran H. | has entered the room |
Mark M. |
if the code is that tightly coupled, I'd argue the implementation should be in one spot
|
Mark M. |
(btw, howdy, Ciaran H!)
|
Frank S. | has entered the room |
Mark M. |
however, you could try some sort of lifecycle method dispatch mechanism
|
Mark M. |
know which child is alive and route onStop() and etc. to the right one, or to all children, as appropriate
|
Mark M. |
(btw, howdy, Frank S!)
|
Frank S. |
hi mark
|
Mark M. |
dhaupert: so, there is definitely a cost to combining them
|
Ciaran H. |
Howdy Mark!
|
Mark M. |
let me take some questions from the newcomers, and I'll swing back to you if you have a follow-up question in a bit
|
Mark M. |
Ciaran: do you have a question?
|
dhaupert |
yeah, thinking of a class variable that points to
the active view. Seems like there are tradeoffs to doing it, but
definitely worth the investment of some experimentation. I don't have
the option of a re-design as there are project requirements to match the
flow of an iPhone app which is very hierarchy based.
|
Oct 7 | 10:35 AM |
Ciaran H. |
I am designing a custom graphing widget. my
question is would it be best to have a view for the graph itself and a
surface view on top of that to do the graphing?
|
Mark M. |
what do you mean by "the graph itself"?
|
Mark M. |
I don't know the difference between that and "do the graphing"
|
Ciaran H. |
I want it to graph accelerometer data
|
Ciaran H. |
i already have an activity that does it i just
want make a widget so i can have multiple instances of it and use it for
various applications
|
Ciaran H. |
like a button
|
Mark M. |
that's all fine
|
Mark M. |
but I don't understand the difference between "the graph itself" and "do the graphing", and why those would be separate things
|
Ciaran H. |
oh ok
|
Mark M. |
in your activity, how do you "do the graphing" today?
|
Ciaran H. |
i mean i know the x and y of the graph are static so i dont need to redraw them everytime
|
Ciaran H. |
so that would be a view and the surface view will do the plotting
|
Ciaran H. |
i have a seperate thread that does the on draw
|
Ciaran H. |
i guess the standard way to draw with a surface view
|
Oct 7 | 10:40 AM |
Mark M. |
yeah, I don't think games, for example, are sticking fixed pixels on one layer and relying on alpha compositing to combine them
|
Mark M. |
I suspect that is slower than just drawing it yourself
|
Mark M. |
so, I'd just make your reusable widget either a subclass of SurfaceView or something that holds a SurfaceView
|
Ciaran H. |
ok thats what i have so far
|
Ciaran H. |
i have it extending surface view
|
Mark M. |
(not even sure if you need it to be a SurfaceView
-- I thought you could just draw on a Canvas supplied to onDraw() of a
regular View, but, again, 2D graphics is not my area of expertise)
|
Ciaran H. |
yeah i tried just a canvas but it wipes clean after every draw
|
Ciaran H. |
the surface view saves state
|
Mark M. |
:: shrug ::
|
Mark M. |
OK
|
Mark M. |
like I said, not my area of expertise
|
Ciaran H. |
ok thank you anyway
|
Mark M. |
Frank: got a question?
|
Frank S. |
kinda
|
Frank S. |
if I'm collecting real time data
|
Frank S. |
"real time"
|
Frank S. |
would you say write it to a file and flush the file to a database
|
Frank S. |
or the database is fast enough todo an insert for every new data point
|
Mark M. |
transactions on the database will be your bottleneck
|
Mark M. |
as will doing the flush to the file
|
Mark M. |
I'd batch them up in RAM and write a bunch of entries at once, if you can
|
Oct 7 | 10:45 AM |
Mark M. |
if you have to do it one at a time, writing to the
file and flushing the file to disk, then converting it into the
database after the collection period is over, is probably fastest
|
Frank S. |
OK Cool. We are able to buffer those values in RAM
|
Frank S. |
and then flush RAM to file
|
Frank S. |
and then when the time is right, insert the file into the db
|
Frank S. |
thanks for the advice
|
Mark M. |
if you can buffer, it may be you can go straight to the DB -- you're effectively amortizing the transaction overhead
|
Mark M. |
but, there is less overhead for a simple file write
|
Ciaran H. |
yeah there is a buffered writer
|
Mark M. |
since there's no transaction log, rollback capability, etc.
|
Frank S. |
yeah. It's a cloud database so I'm not totally worried about the integrity of the data
|
Mark M. |
flat file is probably the simplest and fastest, then
|
Mark M. |
swinging back around...
|
Mark M. |
dhaupert: got another question?
|
Frank S. |
Will do. I'll start with that piece first. Thanks mark
|
Oct 7 | 10:50 AM |
dhaupert |
Thanks Mark, still trying to think through the logistics of the viewflipper stuff. Feel free to go back to the others for now..
|
Mark M. |
OK
|
Mark M. |
Ciaran: got another question?
|
Ciaran H. |
I believe I am good till Tuesday.. Tahnks again
|
Ciaran H. |
Thanks*
|
Mark M. |
Frank: got another question?
|
Frank S. |
How much notice do you need to get the waresubscriptions for the students taking the mobile programming course at FSU?
|
Mark M. |
not much
|
Frank S. |
We are 100% teaching it in the spring and applied to get an actual course listing
|
Mark M. |
once the course listing is in your catalog, shoot it my way for verification
|
Mark M. |
then, once enrollment is closed (or close to closed) for the semester, give me a headcount, and I can generate the coupons
|
Frank S. |
ok. I believe we are capping the class at 30. I will look it up in the registery now
|
Mark M. |
I'd like a couple of days at least before class begins, just in case I am traveling and have infrequent Internet access
|
Frank S. |
will do
|
Oct 7 | 10:55 AM |
dhaupert |
Thinking through this ViewFlipper stuff- thinking
of using an arraylist as kind of a pseudo view stack, where I would keep
the class references in the array and can push and pop by adding to or
removing from the array. Then for each activity lifecycle function, I'd
just pass that onto the top item in the array. Then I can keep all of
my code separate. Does that seem sound to you?
|
Mark M. |
even simpler: use setTag() and getTag() for the children of ViewFlipper
|
Mark M. |
setTag() to associate your quasi-activity with the child
|
Mark M. |
getTag() to get it back later
|
Mark M. |
you can then use getDisplayedChild().getTag() to get at the object
|
dhaupert |
a Tag can ben pretty much anything, right? Even a pointer to a class
|
Mark M. |
any Object
|
Mark M. |
that way, you don't have to worry about your array getting out of sync
|
dhaupert |
good idea!
|
dhaupert |
Appreciate your help Mark. Thanks again.
|
Mark M. |
any last questions from anyone?
|
Oct 7 | 11:00 AM |
Ciaran H. |
no sir talk to you Tuesday
|
Mark M. |
yes, two more chats scheduled for next week
|
Ciaran H. | has left the room |
Mark M. |
have a pleasant weekend, all!
|
dhaupert | has left the room |
Frank S. | has left the room |
Mark M. | turned off guest access |