Office Hours — Today, April 7

Tuesday, April 5

Apr 7
7:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Suzanne A.
has entered the room
Mark M.
howdy, Suzanne!
Suzanne A.
hallo (again) got your chapter on fragments
have a question about your comment on same fragments for different orientations
Mark M.
OK
Suzanne A.
is there any workaround?
8:00 PM
Mark M.
hmmm...thought I covered that somewhat
the best workaround is a FragmentTransaction
but that's a bit beyond what I want to cover in that chapter
I'll be covering it in the Advanced Android book shortly
Suzanne A.
ok, i've only read through page 389 .. sorry
is it possible to tap a fragment, or ui control in a fragment, and show or hide it?
Mark M.
lacking that, the next-best workaround is to make the unnecessary fragment's view gone, which is what I'm doing in EU4You_6
you can't hide a fragment, but you can hide its View
which amounts to the same thing from a UI standpoint, AFAICT
Suzanne A.
yes
Mark M.
again, FragmentTranscation is the right way to accomplish it
Suzanne A.
and EU4You_6 does that already? please excuse that I didn't finish the chapter yet
NetApex
has entered the room
fitz
has entered the room
Mark M.
EU4You_6 takes the hide-the-unnecessary-fragment's-view approach
(btw, howdy NetApex and fitz!)
NetApex
Hey there Mark
Suzanne A.
ok. I'll go back and look more
fitz
hello
Mark M.
I am sure that there are gaps that I need to close in that chapter, so I am certainly up for suggestions
Suzanne A.
okay. will finish it on the plane tomorrow, and lyk
Mark M.
NetApex: do you have a question?
8:05 PM
NetApex
Working with an array... kicking my butt trying to get the view correctly
I have a runnable and when the array gets the data from the Internet and tries to update the view it can't because it is not the main ui
I am trying to figure out how to set the adapter correctly basically
Mark M.
personally, I'd use an AsyncTask, with the background work in doInBackground() and the adapter-update in onPostExecute()
if you want to stick with your existing code, just wrap your adapter-update logic in a Runnable and call post() on some View
or runOnUiThread() on your activity
NetApex
does AsyncTask give you the option of showing a progress indicator of some sort?
Mark M.
sure
doInBackground() can call publishProgress()
NetApex
Ok then that is the direction I shall head
Mark M.
that routes to your onProgressUpdate() method on the AsyncTask
which is called on the main application thread
NetApex
Ahh ok cool
Mark M.
I have examples of it in the threading and rotation chapters of The BCG to Android Development.
fitz: do you have a question?
fitz
na just getting more coffee so I can concentrate on topics :)
8:10 PM
Mark M.
OK
fitz
been a LOOOOONNNNGGGGG day
Mark M.
Suzanne: got another question?
OK, if anyone has a question, chime in
NetApex
I have another related question then
Mark M.
go right ahead
NetApex
ArrayList.. where do I make a change in the spacing of the lines?
Mark M.
ArrayList doesn't have lines
do you mean the rows created by your ArrayAdapter?
NetApex
Err, yeah sorry about that
Suzanne A.
has left the room
Mark M.
I think there's an attribute on TextView, hold on...
android:lineSpacingExtra
or android:lineSpacingMultiplier
NetApex
Is there by chance a "word wrap" type function too?
Mark M.
that's built in
it automatically wraps
8:15 PM
NetApex
Hmm, okay cool
Mark M.
you may need to adjust android:minLines, android:maxLines, or android:lines to suit
NetApex
Ok
That gives me plenty to start from
Suzanne A.
has entered the room
8:20 PM
Mark M.
welcome back, Suzanne!
8:20 PM
Suzanne A.
thanks
I just came back to say .. it does, I found it
sorry I didn't see it sooner :-)
Mark M.
what does what?
Suzanne A.
EU4You detects orientation and hides a view
Mark M.
ah, yes
Suzanne A.
I'm just moving too fast these days
Mark M.
nah, that's just the jet lag talking
Suzanne A.
okay. we'll tweet you from berlin and london
Mark M.
thanks!
Suzanne A.
danke, and see you soon :-)
Suzanne A.
has left the room
NetApex
So, Google I/O, are you going?
Mark M.
scheduled to, yes
NetApex
Cool, I want to get the chance to shake your hand for the helo!
err.. help
Mark M.
that could be challenging, with ~8,000 attendees
I|O isn't CES, but it's still a pretty big crowd
8:25 PM
NetApex
Hehe, yeah... just look for the Android fan lol
Mark M.
again, if anyone comes up with a question, just ask
NetApex
Alright, so I have adapter that I want to post end layout...
View paste
final ItemAdapter adapter = new ItemAdapter(this, items);
setListAdapter(adapter);
8:30 PM
Mark M.
"post end layout"?
NetApex
Where do I place that part of the code?
Mark M.
on the main application thread
NetApex
(man, I am typing bad tonight)
Mark M.
so, if you're using an AsyncTask, that feels like onPostExecute()
NetApex
so I have to pass the items to the onPostExecute() call then?
Mark M.
well, onPostExecute() needs them somehow
option #1: return the items from doInBackground(), and get them as a parameter to onPostExecute()
option #2: put the items in a data member of the AsyncTask in doInBackground(), then access the data member in onPostExecute()
option #3: just generate random garbage for the data in onPostExecute() and hope the user doesn't notice
:-)
NetApex
lol
seems option #2 might be the one I will shoot for
Essentially, I will be gathering post from a site and enabling a mobile view, so having something local and possibly in a sql stae may be good
8:35 PM
Mark M.
"a sql stae"?
NetApex
dear lord!! sql state
Mark M.
you really need to cut back on the bourbon when you're on these chats... :-)
NetApex
I have been limiting myself to two bottles lol
Mark M.
if your data is in a SQLite database, rather than converting the data into objects in an ArrayList, you might consider just using a CursorAdapter or SimpleCursorAdapter
NetApex
well currently it isn't, but I had thought of placing it into one just in case the user doesn't always have a network connection
Mark M.
depending on the data format, it may be simpler just to cache the downloaded file, rather than fuss with pouring it into a database
it all really depends on what you're trying to do
NetApex
Hmmm, interesting idea
8:40 PM
NetApex
It's only post from a website, to title, an occasional image, and some text
Mark M.
you're downloading this as... HMTL?
er, HTML?
NetApex
no, json
Mark M.
oh, yeah, I'd seriously consider just hanging onto the file
NetApex
ok I will take that advice
Mark M.
assuming the objective isn't for the user to modify the data offline, for something that small, parsing the JSON probably won't be any slower than querying a database, and it can simplify your code by not bothering with SQLite
NetApex
I am all for simple code
ok thanks, I will get started, thanks!
8:45 PM
fitz
cya
fitz
has left the room
8:55 PM
Mark M.
any last questions?
9:00 PM
Mark M.
ok, that's a wrap then
two more chats next week
have a pleasant day!
NetApex
has left the room
Mark M.
turned off guest access

Tuesday, April 5

 

Office Hours

People in this transcript

  • fitz
  • Mark Murphy
  • NetApex
  • Suzanne Alexandra