Office Hours — Today, August 23

Thursday, August 18

Aug 23
3:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:35 PM
Ryan S.
has entered the room
Mark M.
hello, Ryan!
how can I help you today?
Ryan S.
Hi Mark, just bought the book!
Mark M.
thanks! :-)
Ryan S.
I don't have the code on me right now, so i'll have to just describe the issue
Mark M.
these office hours are held usually three times a week
go right ahead
Ryan S.
I have an CoordinatorLayout, AppBarLayout and a ViewPager
and that combination works well when I have a list of some sort in the viewpager
4:40 PM
Ryan S.
but when I tried a view that was relatively static (google map) it basically got pushed down below the navigation bar
could just see the top of the zoom button poking out
Mark M.
well, I have never used CoordinatorLayout nor AppBarLayout
I seem to recall that those things were specifically designed with vertically-scrolling content in mind
Ryan S.
That makes a lot of sense, i think it was created automaticlly by one of the new activity wizards
Mark M.
yeah, if you leaf through the book, you'll find that I am not a fan of those wizards
people think that they represent best practices
in reality, they represent stuff that Google wants to promot
Ryan S.
oof, that includes me
Mark M.
er, promote
Ryan S.
Got time for one more?
Mark M.
with a particular emphasis on "lets all do lots of Material Design stuff before we figure out how 'Hello, world' works!"
sure, it's a quiet chat room today
if there are several people, I rotate among them to give everyone a shot
4:45 PM
Ryan S.
This one is from my old school project last term, basically the issue was that my app would crash if you rotated the screen while doing a network request
I think it had to do with the activity being recreated
Mark M.
activities are destroyed and re-created by default on a configuration change
where rotating the screen is perhaps the most common such change
Ryan S.
I'm just not sure how you're supposed to update the reference to the activity in an asynctask while it's running
Mark M.
you don't
you keep the AsyncTask loosely coupled to whatever is consuming the results of the work
one common approach is to use a retained fragment to manage the task
Android already is responsible for keeping the fragment up to date with respect to what the current activity instance is that manages the fragment
so long as your AsyncTask does not try touching the activity in doInBackground(), by the time onPostExecute() is called, the task can work with the fragment (and, by extension, the activity) without issue
Ryan S.
alright, interesting
Thank you very much
Mark M.
that's my main AsyncTask sample app from the book, covered in the chapter on threads
it implements the retained fragment approach
Ryan S.
I am very impressed with how often I find your answers to questions I find on StackOverflow
Mark M.
yeah, I type a lot :-)
Ryan S.
Well, I'm going to be reading through a chapter or two tonight, thanks for the pointers
Maybe see you again soon
Mark M.
the calendar of upcoming chats is on the Warescription site
4:50 PM
Mark M.
and transcripts get posted to https://commonsware.com/office-hours/
Ryan S.
has left the room
5:00 PM
Mark M.
turned off guest access

Thursday, August 18

 

Office Hours

People in this transcript

  • Mark Murphy
  • Ryan Speets