Office Hours — Today, February 19

Tuesday, February 16

Feb 19
9:50 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:55 AM
Mike Q.
has entered the room
Mark M.
Howdy, Mike!
star
Mike Q.
Hi Mark.
star
10:00 AM
Henrik F.
has entered the room
Henrik F.
Hello
star
Mark M.
Howdy, Henrik!
star
Stephen K.
has entered the room
Mark M.
And, howdy, Stephen!
star
Stephen K.
hi all
star
Henrik F.
We are given the task to implement a horizontally scrollable grid of images that shows 4 rows and 5 colums on the screen (the number of columns can of course be larger than 5, but at most 5 are visible at any time). When an item in this grid is clicked the grid should be zoomed in (animated over 1 second) to a 3x3 grid where the selected image is centered and the surrounding 8 images are partly visible (partly outside the screen). In this 3x3 grid the user should be able to move to any of the surrounding 8 images by clicking on the visible part (again with an animation). When the centered image is clicked it should zoom out to the 4x5 grid again. Could you give some general pointers how to accomplish such a thing? Custom layouts and ViewFlippers, drawing bitmaps directly on a canvas, OpenGL or something else?
star
sorry about the length of that question :)
star
Stephen K.
I have a question about scrolling. I want to get a fast scroll for a ListView like on my Contacts app - this is the HTC Hero so I think it might be a different UI. I've seen a couple of threads, one of which you contributed to (http://stackoverflow.com/questions/1201962…), giving some pointers, but I wondered whether you had any further help?
star
Philip M.
has entered the room
Mark M.
Henrik: general pointer -- several cases of Red Bull are recommended for that one
star
Philip M.
mmmm, Red Bull, I like this discussion already =P
star
Mark M.
Stephen: hold two minutes, and I'll get to your question
star
Henrik F.
I see..
star
Stephen K.
sure
star
Mark M.
Just the "horizontally-scrollable grid" will be a challenge
star
I'd start by looking at GridView's source and HorizontalScrollView's source and see how you can combine them into a HorizontalGridView.
star
Henrik F.
We have done a few tests, the horizontally scrollable grid is implemented with a Gallery where each view is in fact a whole column of 4 images.
star
Mark M.
If that works for you, cool.
star
Henrik F.
LinearLayout (vertical)
star
Mark M.
Gallery has a fairly distinct look, not what I'd consider a "grid"
star
Henrik F.
The zooming on the other hand is a different matter..
star
10:05 AM
Mark M.
That shouldn't be too terribly bad
star
10:05 AM
Henrik F.
There is padding in that Gallery adaption, so it looks more or less like a grid.
star
Svetlin S.
has entered the room
Mark M.
You'll create your 3x3 grid, plop it on top of the existing grid, and use a ScaleAnimation to change your size
star
When the ScaleAnimation is complete, hide the larger "grid"
star
Henrik F.
Ok, with a ViewFlipper? (or any other ViewAnimator)
star
Mark M.
No, directly applying the animation
star
See the Animation chapter in your copy of _The Busy Coder's Guide to Advanced Android Development_
star
Svetlin S.
Hello to everyone
star
Henrik F.
Ok, another problem then, about the 3x3 grid. With the default layouts it seems hard to get something to show partly outside the screen
star
Mark M.
Correct
star
Henrik F.
AbsoluteLayout is not an option
star
Mark M.
Having things show partly outside of the screen may not be an option
star
Henrik F.
in our spec it is :)
star
Mark M.
You have a very complex set of requirements
star
Working within the widget framework, you may not hit them all
star
Your choice is then to change the spec or drop down to 2D/Canvas stuff and spend months and months
star
(hence, the Red Bull, since you won't be given months and months)
star
Stephen: Could you be a bit more specific on your question?
star
Henrik F.
we have tried an OpenGL approach, this works, but we wanted to know if it could be done simpler
star
but now we know. Thanks for your help
star
10:10 AM
Mark M.
Stephen: Could you be a bit more specific on your question?
star
Stephen K.
well, I have several fairly long ListViews, coming from a CursorAdapter, say 300 rows, and I want the user to be able to go directly to, say, entries beginning with A, quickly. I don't mind how this is achieved particularly, but the fast scrolling approach where it comes up with each letter seems sensible
star
Mark M.
I haven't implemented "fast scrolling" before
star
You might take a peek at Romain Guy's Shelves sample app
star
I think he uses "fast scrolling" there
star
Stephen K.
is that on his blog?
star
Mark M.
The curious-creature one, yes
star
Stephen K.
ok, I'll do that thanks - I've looked at the source of the Android Contacts app, but it's a little beyond my level. Thanks for the pointer
star
Mark M.
Yeah, Contacts is kinda big
star
OK, who's got the next question?
star
Nobody has a question?
star
10:15 AM
Philip M.
I do, just typing
star
10:15 AM
Philip M.
got a few
star
So I had some questions about implementing my own ArrayAdapter. I'm attaching it to a Spinner widget and the item list is only 4 items long. it's part of a dynamically generated ScrollView so that as items get selected, more widgets appear. I'm trying to modify the adapter so that after an item has been selected, it can no longer be selected in subsequent clicks on that spinner. How would I achieve this?
star
Mark M.
Off the cuff...
star
Step #1: Have your ArrayAdapter implement areAllItemsEnabled(), returning false
star
Step #2: Have your ArrayAdapter implement isEnabled(), returning false for those that were clicked and true otherwise
star
Step #2a: Use two ArrayLists, one for the actual data, one for the "has it been selected" booleans used in Step #2
star
Step #3: Add a selection listener to update the "has it been selected" boolean ArrayList
star
I have not tried areAllItemsEnabled()/isEnabled() in a Spinner, so I am assuming that part works
star
10:20 AM
Philip M.
And the two ArrayLists will be part of the Adapter or outside of the adapter?
star
Mark M.
Part of the Adapter. One will be the "natural" data that any ArrayAdapter would have.
star
Does anyone else have a question? If not, we can continue with Philip's next one.
star
Henrik F.
Again, thanks for the help and bye
star
Henrik F.
has left the room
Mark M.
OK, back to Philip -- got another question?
star
10:25 AM
Philip M.
K, also, I'm assuming that the spinner dialog that pops up is similar in execution as the ListView in that if that list is big enough to go outside the screen, it'll start reusing view. How could I prevent that if i know that any lists I did generate were for the most part going to be only about a dozen items? This is for a expandable list view where the sublists will have very custom rows.
star
This is *also for an expandable list view, sorry
star
Mark M.
Well, I haven't messed with an ExpandableListView, and I don't know what a "spinner dialog" is.
star
Philip M.
the spinner "dialog" is the list that pops up when the spinner is clicked
star
Mark M.
Ah, OK.
star
You are welcome to override getView() in your adapter and choose to ignore the passed-in View for recycling
star
Just be sure you know what you're doing -- recycling is suggested for a reason.
star
10:30 AM
Philip M.
yah, it's mainly for the expandable list view cause the sub lists' rows will be generated from a simplified xml code that i came up with and stored in the database along side the row items, if that makes sense. a lot of rows will end up being the same but not necessarily depending on what results from the db query so I want to ensure that no old incorrect view gets reused when it shouldn't be
star
but onwards and upwards, as I mentioned before with the spinner, it's part of a ScrollView. how do I get it to scroll all the way down to the newly generated views after the spinner item is clicked? Right now it's just adding the views but they disapear off the screen and it's annoying to have to manually scroll right off the bat.
star
10:35 AM
Mark M.
scroll.fullScroll(View.FOCUS_DOWN);
star
where scroll is the ScrollView
star
Philip M.
oh nice, so simple
star
ok, here's another issue i've been having. My second activity is basically a big image that's been chopped up into multiple sections to act like buttons. When the activity starts it takes about 2 - 2.5 seconds to load and does about 5-6 GCs right off the bat as it's loading. Any suggestions on how to reduce this?
star
Mark M.
In the abstract, no
star
Philip M.
would the fact that the image is actually way too big for the screen size matter? right now i'm scaling it as the resources for each section are loaded
star
10:40 AM
Mark M.
Well, that certainly won't helop
star
er, help
star
PNGs take time to decode, and scaling images takes time to do
star
Philip M.
they are PNGs, is bmp a better format to use then?
star
Mark M.
Can't you establish the proper images some other time (compile time? part of the download process?)
star
No, I would stick with PNGs
star
But I would try to make the PNGs require minimal additional image processing on the device at display time
star
Philip M.
how would i go about doing that at compile time?
star
Mark M.
I don't know enough about your application to say specifically
star
Whatever code you're executing at runtime, do the equivalent in Photoshop/the GIMP/whatever as part of your build process
star
10:45 AM
Philip M.
well, i think that only thing I'm doing with the images is scaling them really, then loading them. Would caching the images in a seperate thread started during my first activity be an idea?
star
Mark M.
Scaling isn't necessarily cheap, particularly if the images are "way too big for the screen size". Can't you pre-scale them before they get to the phone?
star
Doing the scaling in a background thread (in your first activity, when you download the images, etc.) is a fine fallback strategy if you have to do the scaling on-device
star
Philip M.
ya, wasn't sure if that's what you had meant before
star
K, then I have one last questions: what's the best way to get a hold of a cheap developer phone? besides buying one new from a carrier that just wants to rip me off that is(i'm in Canada, they suck up here)
star
10:50 AM
Mark M.
First, do you truly need a "developer" phone (i.e., one where you can replace the firmware)?
star
Philip M.
um, I don't know? it's mainly for testing purposes for my app and so that client can test it out in their work setting
star
Mark M.
Then you just need a regular Android phone.
star
Svetlin S.
OK, I have kind of a more beginner's/general question regarding JUnit and functional testing using instrumentation. I've read the chapter in Adv.Android + Diego torres blog, but I'd like to see a more complete example of a testing suite for an entire end user use case. Say, starting with logging-in into an end user account, performing a sequence of related actions and logging out. How does one implement the driving logic? Any pointers/hints, especially if using Eclipse with a separate test project?
star
Mark M.
If you were working on creating replacement firmware or adding stuff to the Android open source project, you'd need a "developer" phone.
star
In terms of ordinary Android phones, I'd use eBay.
star
Philip M.
k, that's the answer i was looking for. Thanks for all the help! I'll let you get to Svetlin's question
star
Mark M.
Svetlin: the reason you won't see such an example from me is that I think the test framework isn't suited for your sort of scenario
star
If you have good separation between the view layer and everything else (V vs. MC in MVC), I would test those sorts of chains against the model/controller layer
star
Then again, I used to do software testing a lot (my first published book was on the subject), and I'm a bit opinionated.
star
10:55 AM
Svetlin S.
OK, so I am accessing a web service -- do you suggest testing it "per se" is the way to go?
star
No point in trying to tie it all up?
star
but separately test the GUI vs. the web service?
star
Mark M.
If by "tie it all up" you mean "drive GUI test cases", you're welcome to try, but I think you will find that to be challenging.
star
I think the GUI testing available through the android.test package is mostly true GUI testing for individual activities
star
There may be ways to test a whole sequence of activities cleanly, but I'm skeptical
star
Svetlin S.
Can't I just use SuiteBuilder and order the instrumentation test cases however I think the user is likely to hit them?
star
Mark M.
Bear in mind that this is JUnit.
star
Particularly with Android's tie into JUnit, your activities get created and destroyed N times, once for each test method.
star
I'm really skeptical that even a suite of test classes will give you a flow that matches what a user would do
star
11:00 AM
Mark M.
If I ever get into messing with the firmware, what I'd like to do is create a "scripted Monkey", outside of JUnit, for these sorts of scenarios.
star
Well, that's the end of the office hour.
star
Svetlin S.
I see. OK, thanks for the feedback, appreciated.
star
Philip M.
Have a good weekend!
star
Mark M.
There will be two office hours next week, same times (more or less) as the ones from this week.
star
See you later!
star
Philip M.
has left the room
Mike Q.
has left the room
Stephen K.
has left the room
Svetlin S.
has left the room
Mark M.
turned off guest access

Tuesday, February 16

 

Office Hours

People in this transcript

  • Henrik Fredriksson
  • Mark Murphy
  • Mike Q
  • Philip M.
  • Stephen Knox
  • Svetlin Stanchev