Feb 21 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Feb 21 | 4:00 PM |
Oliver | has entered the room |
Mark M. |
hello, Oliver!
|
Mark M. |
how can I help you today?
|
Oliver |
Hey Mark, will be just a quick(ish) one today
|
Feb 21 | 4:05 PM |
Oliver |
I have been experimenting with rounded images
(ImageViews)...only I have been making them scale perfectly to make
things beautiful :)
|
Oliver |
I was originally going through some horrible logic
every time I needed one...which essentially was an async task which set
the bitmap
|
Oliver |
today I have bundled the AsyncTask into a view
|
Oliver |
so the question is whether this is sound...I can post some code
|
Mark M. |
I am not a big fan of views forking their own threads
|
Mark M. |
IMHO, there's a "separation of concerns" issue
|
Mark M. |
I would lean more towards putting the smarts inside your image cache
|
Oliver |
interesting that you say that....because ImageView can certainly do some scale processing (and I believe some caching)
|
Mark M. |
ImageView doesn't strictly do caching
|
Mark M. |
ImageView does scaling, but not a background thread
|
Mark M. |
where are the original images coming from? resource? network? file?
|
Oliver |
local images
|
Mark M. |
local meaning resource? file?
|
Oliver |
I am actually using the Novoda ImageLoader...with some modifications
|
Oliver |
file
|
Oliver |
the thing is...that when other views change...I need to scale the images again
|
Mark M. |
I'd extend their loader to do your long-running work that required the AsyncTask
|
Oliver |
and so I go back to source....and process
|
Feb 21 | 4:10 PM |
Mark M. |
yeah, the Loader API probably isn't ideal in this case
|
Oliver |
View paste
(36 more lines)
|
Oliver |
So I guess I could create a static utility method and pass in the ImageView
|
Mark M. |
File mCache?
|
Mark M. |
if you have to keep resizing the images, why are you persisting the resized editions?
|
Oliver |
mCache isn't important - I have been processing
and storing back to disk...but the performance is actually v.good on
Nexus devices
|
Mark M. |
OK
|
Mark M. |
I'd still put the "Roundy" smarts inside ImageLoader or some other image cache
|
Oliver |
the source images are actually ~3MiB
|
Mark M. |
roundification is an attribute of getting you an image to work with, not an attribute of rendering the image, IMHO
|
Mark M. |
but, that's just me
|
Oliver |
:)....I was thinking that 'onLayoutChange' could trigger such funky behaviour
|
Oliver |
which I am actually doing for other use cases....
|
Feb 21 | 4:15 PM |
Oliver |
cool.....I think that Qs done...cheers.
|
Mark M. |
ok
|
Mark M. |
if you have another question, go ahead -- quiet chat today
|
Oliver |
just a general comment on this.....with view
pager....I have quite a few views. Not insane amounts....but say on one
page....maybe 25 items (linear list). Things can get a little
janky....any thoughts on improving that?
|
Mark M. |
I'd run your app through Traceview and see what it comes up with
|
Mark M. |
I added a chapter on detecting and removing jank in the new Version 4.6 that was released on Tuesday
|
Oliver |
awesome...I haven't downloaded that....so will do
|
Mark M. |
I basically walk through ThreePaneDemoBC, one of my implementations of the Gmail three-fragment problem
|
Mark M. |
I had reports of jank
|
Mark M. |
so I used gfxinfo and systrace to confirm the jank, following Romain Guy's recipe
|
Feb 21 | 4:20 PM |
Mark M. |
then, I used Traceview to try to figure out where the problem was
|
Mark M. |
and then Chet Haase happened to chime in with the problem (trying to animate layout changes)
|
Mark M. |
which confirmed what Traceview was reporting
|
Oliver |
excellent. Sounds like it will be v.useful. I
know the views that are of concern....I was thinking that maybe hiding
them before loading the data might ease things when initially switching
pages.
|
Mark M. |
Traceview will help you ID logic that is on the
main application thread that perhaps shouldn't be, either because it
belongs on a background thread or just should not be done (e.g.,
animating the resize of a layout)
|
Oliver |
ok...so your example of animating the resize of a layout should not be done?
|
Mark M. |
yes
|
Mark M. |
I was using an ObjectAnimator to change the width
|
Oliver |
I actually have an 'expansion' button which, you guess it, shows many more views. It does get sluggish
|
Mark M. |
thinking that this was how Gmail transitioned the wider right-hand fragment to the narrower size on the left
|
Mark M. |
apparently, that's not what Gmail does
|
Mark M. |
and trying to resize/re-layout the contents (a ListView) was exceeding my available time before dropping frames
|
Mark M. |
hence, the jank
|
Feb 21 | 4:25 PM |
Oliver |
I see....I certainly need to check out your update then....
|
Oliver |
I haven't got any further immediate Qs - hopefully
I will have most of this sorted by next time that we speak...'now with
less jank' ;)
|
Mark M. |
OK
|
Oliver |
I am slightly surprised that there aren't lots of
other folks here! I has been kinda a one on one recently...at this rate
I'll be sending code for you to proof read ;)
|
Mark M. |
it comes and goes
|
Mark M. |
sometimes I have a half a dozen people here
|
Mark M. |
sometimes there's nobody
|
Oliver |
super....I'll leave it there....if you are
sticking around for the whole hour then I'll stay just in case something
else comes up. Else feel free to kick me :D
|
Feb 21 | 4:30 PM |
Mark M. |
oh, you are welcome to stay
|
Mark M. |
if another question comes to mind, chime in
|
Oliver |
super...thanks
|
Feb 21 | 4:35 PM |
David | has entered the room |
David |
hello
|
Mark M. |
howdy, David!
|
David |
how are you?
|
Mark M. |
David: do you have a question?
|
Mark M. |
(besides "how are you?", that is... :-)
|
David |
yes i have a few
|
David |
thanks
|
Mark M. |
go right ahead
|
Mark M. |
(Oliver: if another question comes to mind, chime in)
|
David |
i'm building custom views with resources, and I have a few quesitons about when I can get heights, widths, etc
|
Mark M. |
that's not my strong suit, by any stretch of the imagination
|
Oliver |
(Mark: thanks)
|
David |
if the dimensions of your view do not depend on the parent, can you call measure before laying it out
|
Mark M. |
yeah, beats me
|
Mark M. |
I can do composite widgets (e.g., ColorMixer from the book)
|
David |
ah okay
|
Mark M. |
but you start getting into layout/measure stuff, and I'm all thumbs
|
David |
i think I'm going to spend some time expirementing
|
David |
maybe I'll let you know
|
Oliver |
David: have you seen Romain's talk with FlowLayout as an example?
|
David |
no
|
Mark M. |
yes, that presentation should be a good one, though I haven't had a chance to watch it yet
|
Oliver |
one
|
Oliver |
sec
|
David |
i'd like to
|
Mark M. |
I think that was a Parleys.com one, IIRC
|
David |
i'll check them out
|
Feb 21 | 4:40 PM |
Oliver |
I have remembered a fair amount...you must call measure() on all your children 'cos it is in the contract ;)
|
David |
can i have another question?
|
Mark M. | |
David |
hmm...
|
Mark M. |
that link in turn contains a link to the presentation, FlowLayout implementation, etc.
|
David |
I'll read through it
|
Mark M. |
anyway
|
Oliver | |
Mark M. |
yes, you're welcome to ask more questions
|
David |
thanks
|
David |
i had a project where I was using actionbar sherlock, and the version 11 of the v4 support library
|
David |
i had a lot of problems with the childFragmentManager
|
David |
I finally got it working, it seems that you can't retain an instance of the fragment that it is in
|
Mark M. |
yeah, that's not shocking
|
David |
because its 'stuck' with the old activity
|
Mark M. |
that's a bit surprising -- I haven't tried that scenario
|
David |
i was using it with a viewpager
|
David |
i got a whole multitide of different errors, from a 'No Activity" error
|
David |
to an illegalstateException error that I had to remove a childs view from a parent
|
Mark M. |
I get the impression that the child
FragmentManager stuff is designed to work in narrow cases but isn't
necessarily as general-purpose as the regular FragmentManager
|
Mark M. |
that's based on other questions/issues I've seen floating around with it
|
Feb 21 | 4:45 PM |
David |
after about a day of expirementing I found that I
had to destroy activity in configuration changes, and save the fragment
in all other cases for it to work
|
David |
i wanted to ask if you knew how it worked
|
Mark M. |
what is "it"?
|
David |
the fragment the viewpager was in
|
Mark M. |
I have only used a child FragmentManager once, for the book sample of putting fragments in a ViewPager
|
Mark M. |
which was a fairly basic sample
|
Mark M. |
personally, I am still trying to avoid the child
FragmentManager in general, as I am unconvinced that it is "fully
baked", as it were
|
David |
i didn't know it was in the latest book...
|
Mark M. |
actually, that popped into 4.5, and the current is 4.6
|
David |
i have to for this project, or else create an activity for one screen
|
David |
which would break the architecture completely
|
Mark M. |
you can use a custom view (composite-style) for the pages in the ViewPager, instead of fragments, in many cases
|
David |
really?
|
Mark M. |
sure
|
David |
that would work very well in my case
|
Mark M. |
in many ways, that's all a fragment is
|
David |
what kind of adapter do you use?
|
Mark M. |
custom implementation of PagerAdapter
|
Mark M. |
I show one in my ViewPager coverage of showing multiple pages at a time, in the Large Screen chapter
|
David |
great!
|
David |
i will go with that
|
David |
...even though I got the stupid thing working...after lots of pain :)
|
David |
that answers my question
|
Feb 21 | 4:50 PM |
Oliver |
David, you are welcome to take my notes regarding Romain's talk https://docs.google.com/presentation/d/1uMM_wfC...
|
David |
thank you
|
Oliver |
(probably not a huge amount)
|
Oliver |
I would guess that you need to get the sizes on the layout pass
|
Oliver |
or after
|
David |
i would want to get the sizes on the layout pass, and then call setMeasuredDimension again on the container
|
David |
the container has to grow by a factor of one of the child views
|
Mark M. |
that could get messy
|
David |
and then set the dimensions of that new part in onSizeChanged
|
Oliver |
I think setMeasuredDimension has to occur at the end of onMeasure
|
Mark M. |
the general Android model is that the container dictates the size of the children, not the other way around
|
David |
yeah....
|
Mark M. |
are you sure that the container that depends on the child size *has* to contain that child? or could they be peers?
|
David |
they could be peers
|
Mark M. |
off the cuff, that might be more reliable
|
David |
the container could sit ontop of the child
|
David |
hmm...
|
David |
so I could layout the component first, then figure
out how large the container would have to be, and the rest to container
afterwards
|
Mark M. |
right
|
David |
ok cool
|
Oliver |
I think the presentation will explain a lot
|
Feb 21 | 4:55 PM |
Oliver |
if you press S I have typed some notes
|
David |
i'll go over it
|
Oliver |
sure
|
David |
thanks
|
David |
if I have some spare time I'll try out the first implementation as well
|
David |
if it works it has some useful purposes
|
David |
i find whenever I make custom views, i have to
hard code a dimension or get it from somewhere, and it never ends up
looking good on all form factors
|
Mark M. |
dimension resources provide some flexibility, but they are not a universal solution either
|
David |
i have thought of building something to get pixels from a percentage or scale
|
David |
using the DisplayManager
|
David |
but it ends up adding a lot of extra work
|
David |
trying to find out how much space the components occupy
|
Mark M. |
you are probably better off calculating from the size of the parent container, not the size of the screen
|
Mark M. |
see LinearLayout and layout_weight, for example
|
David |
you can get that from onLayout
|
David |
i have an image of a 'card'
|
David |
with a logo on it
|
Feb 21 | 5:00 PM |
David |
and on small devices it looks terrible beacause it takes up half the screen
|
David |
even when you adjust for density
|
Mark M. |
well, that's a wrap for today's chat
|
David |
outside of getting multiple resources for this
image, that is really a background image, I'm not sure how to get it
looking good on smaller phones
|
David |
thank you Mark & Oliver
|
David |
...sorry if i monopolized the chat
|
Mark M. |
the transcript will be posted shortly at http://commonsware.com/office-hours/ and the next chat is Wednesday at 10am
|
Mark M. |
not a problem -- Oliver had questions before you arrived
|
Mark M. |
have a pleasant day, all!
|
Oliver |
super...thanks for today Mark
|
Oliver |
bye
|
David |
:)
|
Oliver | has left the room |
David | has left the room |
Mark M. | turned off guest access |