Office Hours — Today, November 11

Wednesday, November 9

Nov 11
3:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
3:55 PM
Chaitanya R.
has entered the room
Mark M.
howdy, Chaitanya!
Chaitanya R.
hello
Mark M.
how can I help you today?
Chaitanya R.
hi Mark
well this is my first time trying out the office hours
I don't know the scope of the questions, but I thought I'd try one
I was implementing a CWAC today
ViewSwiper
and noticed a large time difference between my swipe gesture and the actual view flip
Mark M.
well, the flip will not begin until the gesture is complete
that is inherent in the way GestureDetector works
Chaitanya R.
yes, I did mean the time difference from the point I finish my swipe. it takes a full second or more to flip
Mark M.
what are the views you are flipping between?
4:00 PM
Mark M.
in other words, what are the immediate children of the ViewSwiper?
Chaitanya R.
previously I had implemented viewFlipper with a custom GestureListener. Admittedly that had a slight lag too...around 0.5 seconds.
there are 3 grid views of 12 icons each
Mark M.
what you are probably seeing is the time to render all that
particularly depending on how the icons are being handled, that could be a bit slow
you might consider using Traceview to get a firmer grasp on where the time is being spent
Chaitanya R.
thank you, i'll give that a try
Mark M.
also, long term, you should probably consider ViewPager from the Android Support package (formerly known as the Android Compatibility Library)
Chaitanya R.
on the same topic, I think I should try to implement ViewPager to have an immediate effect
Mark M.
that is the long-term direction for horizontal-swipes-to-move-between-things
Chaitanya R.
haha yes
Mark M.
I need to cover ViewPager sometime soonish
Chaitanya R.
that would be very helpful indeed
well thank you for your time Mark. have a good weekend
Mark M.
you too!
Chaitanya R.
has left the room
4:05 PM
Adam W.
has entered the room
Mark M.
howdy, Adam!
Adam W.
Hi Mark!
Mark M.
how can I help you today?
Adam W.
I have a concept-y question about Fragments and being properly modular.
I'm working on an application that seems to have a clear architecture when I think about it using Activities.
For example, one part involves editing text.
If a user wants to use a different text editor for that part, it's easy to do so.
4:10 PM
Adam W.
I don't do anything special as a programmer to enable that.
If they want to use a different part for "processing the text", as long as the other programmer looks at my intents/documentation, they can make something that drops right in.
However, I seem to get lost thinking about it using Fragments.
Mark M.
if you want to have that sort of drop-in replaceability (is replaceability a word?), you will continue to have activities be your interface
fragments are simply an organizational tool to help you make a single code base support multiple screen sizes
Adam W.
One thing I was thinking of doing was making an activity for each conceptual piece, and then making a "jumbo activity" that looks nice on big screens.
On phones, it would work nearly exactly the same as it does now, but using fragments would possibly make it easier for me to make the "tabletactivity"
Mark M.
yes
Adam W.
Awesome. I'm not too far off the mark then.
Mark M.
however, you can't embed a third-party activity as a fragment in some activity of yours
if your text-editing portion would be a full-screen activity regardless of screen size, you can stick with your existing plan
4:15 PM
Mark M.
if, however, your text-editing portion would logically be only part of a screen on a tablet (e.g., to the right of a ListFragment), then you will be stuck with solely your own text-editing solution
4:15 PM
Adam W.
Would it be wrong to have an option for tablets to force the "loosely coupled activities" from happening, as compared to the integrated activity that has a bunch of fragments?
Mark M.
um, I didn't follow that
Adam W.
On phones, I plan on using fragments, but with most activities only having one fragment.
Mark M.
makes sense
Adam W.
If I don't do anything special, the same thing will happen on a tablet.
Mark M.
well, the point of bothering with fragments in the first place will be do something special
e.g., load a layout with multiple fragments in it
Adam W.
However, most nice Android 3+ applications will watch for the larger screens, and change the layout so I can reuse those fragments and show more than one.
Mark M.
right
Adam W.
The downside for my application of the "more than one fragment screen" is that it isn't as easy for third parties to integrate themselves in.
Mark M.
also right
4:20 PM
Adam W.
I suppose I could offer the option to users to not use that "more than one fragment screen"
Mark M.
in principle, yes
you have to ask yourself whether the resulting UX will be worth it
Adam W.
Yeah. If I expect that to be common, I might as well ignore fragments all together.
Mark M.
at least for that area of the app
Adam W.
Is this something that other people are wondering about?
Mark M.
integration like you're aiming for is an under-utilized feature of Android
dealing with tablet screen sizes is an under-utilized feature of Android, though growing
hence, the intersection of those two is not that popular
Adam W.
ha
understood
Mark M.
in an ideal world, this would be a bigger problem, strange as that sounds
Adam W.
I've written a few apps, not many, and never had a use for the loose-integration stuff I'm doing with this one
but this one is unique with the ones I've written in that it has an "open workflow"
and the intent system seems to be a really powerful way to allow the entire community to do what they want
Alright, I think that's it. Thanks!
Mark M.
happy to help!
4:25 PM
David R.
has entered the room
David R.
Hi all
Mark M.
howdy, David!
4:30 PM
David R.
I've got another question for you.
Mark M.
go right aehad
er, ahead
David R.
Lets say I have a library that someone is building with their project. Is there anyway to get the application Context and the top viewgroup without passing information to the library?
Mark M.
not really
there's absolutely no way to arbitrarily get views, such as the top ViewGroup
some people are creating true singletons out of the Application singleton (i.e., static data member to access the instance), though I'm a trifle nervous about that
(no solid reason for the nervousness, just a feeling)
David R.
Hmm, I have been passing the ViewGroup to my library and looping though them all using .getparent until I get the WindowDecor.
But I was trying to find a different way.
Mark M.
well, there's an ID for that, though I forget it off the top of my head
David R.
android.R.id.context
or content
I cant remember either off the top of my head.
Mark M.
yeah, I think it's content
4:35 PM
Mark M.
given the Activity, findViewById(android.R.id.content) gives you the DecorView
David R.
Yeah, but calling (ViewGroup)findViewById(android.R.id.content); doesn't work inside the activity.
Mark M.
however, you can't get it from an Application
David R.
Always returns null.
Mark M.
you'd have to wait until after setContentView()
David R.
Ah,
scottt
has entered the room
David R.
Well since my library doesn't really display anything I never call setContentView().
Mark M.
howdy, scottt!
scottt
hello! no questions today; just lurking.
Mark M.
then don't call your library until after setContentView()
or something like that
David R.
It is being called after the activity setContentView();
oh well.
Mark M.
I would expect that to work
FWIW, here's a sample project where I use android.R.id.content: https://github.com/commonsguy/cw-advandroi…
it's a sample from the next edition of the Advanced Android book, showing how to use setRetainInstance(true) with dynamic fragments for maintaining state across configuration changes
David R.
My last question is, do you know if it is possible to have a button/menu "float" above the application that the library is part of.
ohhh
Mark M.
well, that's really the application's job
the library has no way to know where it might be safe to display something
David R.
hmm
4:40 PM
David R.
Alright thanks.
Mark M.
if anyone has any questions, chime in
scottt
he he, i'm finalizing a contract for my first non-trivial professional android dev gig. it's basically tweaking and production-izing a mostly-done system and perhaps staying around to manage on-going dev
Mark M.
congrats!
David R.
Mark, does each activity have its own Window Decor?
scottt
thanks!
Mark M.
beats me
David R.
DecorView I should say
hmm
4:45 PM
Mark M.
off the cuff, my guess is "yes", but I've never examined them that way, and I'm not sure I would rely upon whatever the current behavior is
David R.
I'm not relying on it yet, just been testing it all out.
Using TapJacking to send all motionevents to the library in the application and send back the information.
Trying to allow it to record the interaction for testing applications.
Mark M.
oh, wait, this is your testing library
David R.
Cant figure out how to stop/start the recording.
Thats why I thought of the floating menu.
Yes this is my testing library.
Mark M.
well, the problem there is -- what if the menu is above something that needs to be tested?
David R.
Well, I am going to have it either A.) Be moving able B.) Allow you to like pull it and have it flip from being on the bottom to being on the top.
Question is though, how to I keep it on the screen.
I tried to do it in the tapjacking service but that didn't work at all.
Mark M.
actually, that would appear to be the right answer, though
what didn't work with that approach?
David R.
How would you do it though TapJacking?
Mark M.
Tapjacking involves adding a View to the Window
4:50 PM
Mark M.
most tapjacking involves that being transparent
it doesn't have to be
David R.
Well when I could click a box or somthing that I had drawn on the tapjacking layout it wouldn't notice that it was a button.
Mark M.
right
and, AFAIK, it doesn't have to be just a plain View
though I haven't tried anything else (e.g., RelativeLayout holding a Button that would be your toggle)
David R.
Hmm I tried that but I couldn't get the button listener to get any hits.
Mark M.
if you tried an OnClickListener, that's not surprising
David R.
Well not the relativelayout but I did inflate a button on the view.
Mark M.
it won't respond as a normal widget AFAIK
but touch events should register
just as they do on the transparent tapjacking view
David R.
What, just in the touchEvent test to see if that area was touched
Mark M.
right
David R.
Yeah I guess that is one way.
Sweet thanks, that a good idea.
Would I be able to use an xml layout to draw it?
Mark M.
I haven't tried using a LayoutInflater from a service that way
you can try it, but it might not work
David R.
I'll give it a shot.
4:55 PM
David R.
Thank you Mark!
Mark M.
happy to help!
we're running low on time -- any other questions?
David R.
No I am good thank you.
scottt
What's the meaning of life?
Mark M.
life has no meaning, because life is merely a breakfast cereal, or possibly a board game
scottt
lol! i was expecting "42"
Mark M.
no, that's how many roads must a man walk down
scottt
later, everyone
5:00 PM
scottt
(btw, i'm going to steal that response)
Mark M.
you're welcome to it
have a pleasant weekend, all!
scottt
u2
scottt
has left the room
Adam W.
has left the room
David R.
has left the room
Mark M.
turned off guest access

Wednesday, November 9

 

Office Hours

People in this transcript

  • Adam Wolf
  • Chaitanya Reddy Teegela
  • David Rumley
  • Mark Murphy
  • scottt