Office Hours — Today, August 5

Thursday, July 31

Aug 5
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Damian
has entered the room
Mark M.
hello Damian!
how can I help you today?
Damian
Hi Mark
I was going to ask you about animations. Give me some time to write a proper question, please
9:00 AM
Damian
I would like to create a layout with ListView, where first item is special. Initially, special item will be bigger presenting an image, when user scroll down first item smoothly change into regular item. When it is collapsed to regular item view, the list view scroll further normal way. Scrolling up should revert transition. How would you proceed with this?
Mark M.
I have absolutely no idea
Damian
:)
Mark M.
it's possible there is an existing library that offers this sort of "hero element" aspect
if there is, I'd use it
Damian
ok, i will look for it
by the way, did you try RecycleView from support library?
Mark M.
I have not yet played with it
from all reports, it is rather skeletal
requiring lots of additional code to get anywhere
9:05 AM
Mark M.
(at least, for some definition of "lots")
Damian
true, that's my opinion too
Mark M.
my focus this month is on getting my book moved over to cover Android Studio
that, and some camera library updates, are consuming all my time
I won't be poking at "L" too much until late this month, at best
so, RecyclerView is probably going to be a Very Good Thing over time
Damian
do you think there will be beta release of L before offical release?
Mark M.
possibly
there were hints that Google might do that, when this was all discussed at I|O
most of the screams of anguish appear to be tools-related (e.g., can't build for L and test on older environments)
that would seem to lessen any extrinsic pressure for a beta
it may be that they are adding enough new stuff than an L2 will be warranted
but I wouldn't be surprised if what we have is all we get before the next Android release
considering that it's more than we normally get before an upcoming release
Damian
another question just come to my mind, there is a lot of talk recently regarding Card UI, there is also new Cards view from Google. Is it not just another pattern? Why would they create separate view for that?
Mark M.
mostly for the drop-shadow backport, as I understand it
9:10 AM
Mark M.
on "L", that's all being handled natively in the GPU, as I understand it
but CardView will provide a similar, if not as slick, shadow on older devices
given the library name, the backport should work to API Level 7
the whole elevation-and-shadow thing is a big part of Material Design (motto: We Change Our Design Instructions More Frequently Than We Change Our Socks)
Damian
i see, so in the future I could is it once and it will work nicely on older versions, instead handling version prior to L with additional if statements
Mark M.
yes
basically, the if statements are baked into the CardView
Damian
I like new Design but i am worried that my code will get messy, probably Google will not provide support for all aspect of that design, there will be similar situation like with ActionBar for example
Mark M.
agreed
9:15 AM
Mark M.
though the picture should become a bit clearer once "L" turns into Android 5.0 (or whatever number they use)
ming
has entered the room
Damian
I prefer wait longer for L release but get it with full backport for older versions
Mark M.
hello, ming!
ming
HI MARK IM SO EXCITED!! ALL CAPS :D
Mark M.
Damian: I am not certain that the availability of a backport is necessarily tied to "L"'s ship date
Damian: let me take a question from ming, and I'll be back with you in a bit
ming: it's your turn! do you have a question?
ming
yes, i have a question about fragment and backstack
so I have activity A that is hosting fragment A
Damian
I have to leave now, my daily meeting starts in 3 min. Thanks for talking, bye
ming
inside fragment A, i have a take picture button, it invokes the camera app, capture the picutre, and save it inside the PICTURES file
Mark M.
Damian: see you later!
ming
once it finishes the task, it returns to the fragment A and sets a preview which is an imageview that was not visible until the image is captured
now i hit back button, go back in to the fragment A, the preview image is gone.
9:20 AM
ming
I want it to show the preview image, i tried setInstanceState(true) but it does not work
Mark M.
if the user pressed BACK, there is no instance state to save, as the instance is being destroyed
you will need to consider that the photo you took is part of your model data
and when the activity and fragment are created, see if the image is available, then use it if it is
ming
where do i save it?
do i save it in onSaveInstanceState()?
Mark M.
no
you already saved it
"save it inside the PICTURES file"
ming
oh yes, the actual image is saved but the uri is not saved
i dont want to save it to database, since the preview is only supposed to show the last image taken
9:25 AM
Mark M.
:: shrug ::
I cannot really help you with your business logic
ming
..............ok
I always come up with some weird ideas...
Mark M.
the biggest question, from a core implementation standpoint, is how long you need to remember about the "last image taken"
let's suppose the user runs your app and takes a picture
then the user leaves your app via BACK, as you described
hours pass
your process is terminated to free up memory for other apps
then the user returns to your app and brings up fragment A again
should you be showing the "last image taken" to the user in this case?
ming
hmm, i guess not hours
minutes probably
Mark M.
OK
ming
since I want to preserve the state for user if they hit back button accidently
Mark M.
in that case, you will probably wind up keeping a lastImageTaken static data member
if that static data member is null, you start over from scratch
if that static data member is not null, that's your Uri of the last picture taken, and you use it
this means that you will remember the last picture taken only so long as your process is around
ming
how does "static" make a difference
9:30 AM
Mark M.
your fragment and activity are being destroyed
Damian
has left the room
Mark M.
which means either you are caching this data in global scope (i.e., static in Java) or you are writing it to disk
you cannot just save the data in a non-static data member of the activity or fragment, as they are being destroyed and will no longer be relevant
BTW, I am assuming that the activity is being destroyed upon pressing the BACK button, as you did not indicate that the activity has any content other than the fragment
ming
yes
9:45 AM
ming
i gtg now
Thanks a lot!!!! See you next time!
Mark M.
have a pleasant day!
ming
you too thank you !
Damian
has entered the room
Mark M.
hello again, Damian!
do you have another question?
Damian
hi
yes
are you planning to add to your book chapter about AsyncAdapter?
Mark M.
AsyncAdapter?
9:50 AM
Mark M.
there's nothing by that name in the Android SDK
is this some library?
or do you mean SyncAdapter?
Damian
sorry, yes SyncAdapter
Mark M.
yes, I hope to cover it by the end of the year
assuming that I can work out some implementation of it that is not inextricably tied to the AccountAuthenticator system
or at least does not require a pile of icky permissions
Damian
great, I like to see your point of view
recently I have went through video training from Udacity by Google, have you seen it?
Mark M.
I know of it
I haven't watched any of it
Damian
it' really well prepared, I have to watch last part about SyncAdapter :)
9:55 AM
Damian
by the way, I am wondering how do you find time for learning all this stuff, writing book, running webinars and writing answers on stackoverflow :)
Mark M.
well, that's my job
Damian
time is running out, i will stop asking :) thanks again for talking, can't wait to see your opinion about SyncAdapter
bye
Mark M.
the chat transcript will be posted to http://commonsware.com/office-hours/ shortly
Damian
has left the room
ming
has left the room
Mark M.
turned off guest access

Thursday, July 31

 

Office Hours

People in this transcript

  • Damian
  • Mark Murphy
  • ming