Sep 24 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 24 | 4:00 PM |
Paul R. | has entered the room |
Mark M. |
hello, Paul!
|
Mark M. |
how can I help you today?
|
Paul R. |
Greetings.
|
Paul R. |
I have a question I will paste to you and then we can discuss it.
|
Paul R. |
View paste
|
Paul R. |
Is that clear enough for you to grok?
|
Mark M. |
um, well, to be honest, I'm having some trouble
|
Mark M. |
first, "two panels in a view pager" -- do you mean two pages in a ViewPager?
|
Mark M. |
IOW, only one of those is visible at a time?
|
Paul R. |
Yes.
|
Paul R. |
Correct, User sees only one at a time.
|
Mark M. |
OK
|
Mark M. |
I guess I don't understand what Y is exactly
|
Paul R. |
The number of distinct menus
|
Sep 24 | 4:05 PM |
Mark M. |
do you really mean "menus"? or do you mean "menu items"?
|
Mark M. |
(where a menu has 1+ items)
|
Paul R. |
menus
|
Mark M. |
um, well, IMHO, if Y>1, I really don't understand
|
Paul R. |
I am trying to make the point that managing 1 menu is way harder than showing 3 different menus.
|
Mark M. |
um, if you say so
|
Mark M. |
from what I can see, your entire UI would consist of floating buttons
|
Mark M. |
on the whole, I'm really not a fan of FAB/FAM
|
Paul R. |
I think you are answering my question as "context" not "popup", editorial comments aside. :-)
|
Mark M. |
I am using them in CWAC-Cam2, because there isn't anything else that's better
|
Mark M. |
is your distinction between "context" and "popup" is coming from some Google terminology in their design guide?
|
Paul R. |
Google advertises three types of menus: options, context and popup.
|
Sep 24 | 4:10 PM |
Paul R. |
The latter two I ill understand, or at least when to use one vs the other.
|
Mark M. |
well, when I last looked at their design guide, they didn't even have guidance for a FAM
|
Paul R. |
What I'm reading is apart from the FAB docs.
|
Paul R. |
Currently I have a single menu associated with the FAB that is really just a layout menu. But I am reaching limits with that approach and have to find a better solution.
|
Paul R. |
Or to be accurate, each of the pages uses this approach.
|
Paul R. |
One fab with menu per page.
|
Mark M. |
OK
|
Mark M. |
let's back up a step
|
Paul R. |
sure
|
Mark M. |
why FAM vs. action bar/toolbar items (including overflow)?
|
Mark M. |
there are fairly clear patterns for fragments contributing to those based on visibility
|
Mark M. |
is there a reason, from the user's standpoint, why these menu choices are tied to a floating button?
|
Sep 24 | 4:15 PM |
Paul R. |
I currently use action bar/toolbar with overflow for other things, like settings, help, learn more, etc.
|
Paul R. |
The fab menu is for doing new things pertinent to each fragment.
|
Mark M. |
OK
|
Mark M. |
what is the actual thing that represents one of your panels/ViewPager pages?
|
Mark M. |
is it a fragment, and you're using nested fragments?
|
Mark M. |
or are you using something else?
|
Paul R. |
One page is for "chat", the other page is for "games", like chess, checkers and tictactoe
|
Mark M. |
OK, but is "chat" a fragment, containing other fragments?
|
Mark M. |
or is "chat" a View, holding fragments?
|
Paul R. |
Yes.
|
Paul R. |
The chat panel shows grooups, rooms and messages each in it's own fragment.
|
Mark M. |
you said "yes"... but I gave you two options (chat panel is a fragment, chat panel is a View)
|
Paul R. |
Chat panel is a fragment.
|
Mark M. |
OK
|
Paul R. |
Game panel is a fragment.
|
Mark M. |
IMHO, then, the chat panel owns its FAM, and the game panel owns its FAM
|
Paul R. |
Correct.
|
Mark M. |
why can't the nested fragments just tell their parent fragment what things to contribute to the panel's FAM?
|
Sep 24 | 4:20 PM |
Mark M. |
basically, rolling your own mechanism akin to how fragments contribute to action bar/toolbar based on visibility
|
Paul R. |
That's what I currently do and I find it a little messy, too many moving parts.
|
Mark M. |
messy in terms of code? or messy in terms of UX?
|
Paul R. |
in terms of code
|
Paul R. |
UX looks good.
|
Mark M. |
but, my interpretation of your original pasted-in material is that you want to change the UX
|
Mark M. |
if you like the UX, isn't this a matter of figuring out what makes you feel the code is messy, and figure out how to improve upon that?
|
Paul R. |
Not really. My bad if I misled you.
|
Mark M. |
then I'm a bit lost again
|
Paul R. |
I am trying to figure out to improve the current code.
|
Paul R. |
Now I ssy, remove this item, add these and change the order. It would be easier if I could say, just use this named menu instead of the last one.
|
Sep 24 | 4:25 PM |
Mark M. |
what are you using for your FAM implementation?
|
Mark M. |
IIRC, the Design Support library has a FAB but no FAM
|
Paul R. |
Correct, so I am using standard layout code using image views and text views in a linear layout. I control the visibility of the layout on a FAB press.
|
Mark M. |
oh, OK, I thought perhaps you were using an existing FAM library
|
Paul R. |
I figured Menu objects would be better.
|
Paul R. |
I try to avoid third party libraries in general.
|
Paul R. |
Some are compelling though.
|
Mark M. |
I haven't looked at trying to reuse Menu for things other than what the framework/support library uses them for
|
Mark M. |
so I don't know how practical that is
|
Mark M. |
but if you're then rolling this all yourself, you're in charge of your own API
|
Paul R. |
Me either but I figured if anyone would know it would be you. :-)
|
Mark M. |
so if you want to have a higher level of abstraction, with the child fragments telling the panel fragment to use a menu by some name, go right ahead
|
Mark M. |
your panel fragment would need to know how to obtain the details about the named menu to be able to fill in your widgets
|
Paul R. |
I'll give it a shot and see how I like it. And let you know at some future office hour.
|
Mark M. |
whether that's really using Menu and menu resources (but perhaps only as model objects), or whether that's something else that you cook up, is your call
|
Sep 24 | 4:30 PM |
Paul R. |
It's either Menu or View objects as near as I can tell.
|
Mark M. |
well, not necessarily
|
Paul R. |
I'm all ears.
|
Mark M. |
android.view.Menu is an interface
|
Mark M. |
really, it's a view model, describing a UI, but not actually implementing much of it directly
|
Mark M. |
e.g., it does not have onDraw() or other rendering-related logic
|
Mark M. |
there's nothing stopping you from creating your own Menu implementation, perhaps cribbing parts of it from the AOSP
|
Mark M. |
that is used by your existing rendering code
|
Mark M. |
personally, I'd consider that overkill
|
Paul R. |
Truly.
|
Mark M. |
but, it would allow you to use the existing menu inflation logic, if you wanted to use menu resources
|
Paul R. |
It is clear to me that I will be inflating if I use menu objects.
|
Paul R. |
That's ok.
|
Sep 24 | 4:35 PM |
Mark M. |
the problem is that neither of the concrete Menu implementations has a constructor
|
Mark M. |
so they aren't much help
|
Mark M. |
the Menu classes really are designed to be driven by the framework, not by SDK apps
|
Mark M. |
we just implement the requisite callbacks (e.g., onCreateOptionsMenu())
|
Mark M. |
and the existing menu UIs aren't a FAM
|
Mark M. |
so, if you want to keep the FAM, as that's the UX you want, either you're creating your own Menu implementation, or you're eschewing Menu and doing your own thing entirely
|
Mark M. |
I can't rule out the possibility that there's a way to use Menu for a FAM without you creating your own implementation of the Menu interface, but I don't see how
|
Paul R. |
I don't know that I agree with you. And I think I will soon know if you are correct.
|
Mark M. |
oh, it's entirely possible that I'm wrong here
|
Mark M. |
this isn't the sort of thing that I think about much
|
Paul R. |
If the menu approach get's messier than the current approach, then I'll toss the menu approach.
|
Paul R. |
And live with my current "poor man's" FAM.
|
Mark M. |
your FAM implementation probably isn't a problem
|
Mark M. |
it's how you want to populate that FAM that's your problem, in terms of messy code
|
Mark M. |
at least, as I understand it
|
Paul R. |
Correct. And I might be able to modularize that to make it more appealing.
|
Sep 24 | 4:40 PM |
Paul R. |
At this point, I'm going to bid you good afternoon and start working on my menu solution. Thanks for your help.
|
Mark M. |
sorry I didn't have a magic bullet for you
|
Paul R. |
Talk to you again soon, I'm sure.
|
Paul R. |
No problem.
|
Paul R. |
I learned it is not an easy problem to solve.
|
Paul R. |
That is good to know.
|
Paul R. | has left the room |
Sep 24 | 4:50 PM |
Lucy | has entered the room |
Lucy |
Hi Mark!
|
Mark M. |
hello, Lucy!
|
Mark M. |
how can I help you today?
|
Lucy |
Glad I made it before its over. I have two questions:
|
Lucy |
1. I have a Fragment that takes an argument and based on that argument the Fragment populates a ListView. In order to refresh the list with a new set of data I am currently calling, from the Activity, fragmentTransaction.replace(). I replace the Fragment with a new copy of itself with a new argument. I'm wondering if this is a pattern that is OK?
|
Mark M. |
that seems like overkill
|
Lucy |
Oh
|
Mark M. |
why not just call a method on the fragment to say "here's your new argument?"
|
Mark M. |
that method can update the arguments Bundle plus reload the list
|
Lucy |
:-)
|
Mark M. |
the arguments Bundle can be modified beyond when it is first created
|
Mark M. |
and this would save you fragment transaction overhead
|
Lucy |
Absolutely. It didn't feel right. I'm looking at my code now. I pass the argument to newInstance().
|
Mark M. |
and for providing the starting value, that's fine, but you can still have a method that replaces the argument value and reloads the ListView with a fresh adapter
|
Sep 24 | 4:55 PM |
Lucy |
I see. And keep the same instance of the Fragment.
|
Mark M. |
yes
|
Lucy |
When I call: MyFragment myFrag = MyFragment.newInstance(arg1)
|
Lucy |
Is it OK to make myFrag an instance variable, say, mMyFrag instead?
|
Mark M. |
um, sure
|
Mark M. |
that's fairly typical when an activity needs to work with the fragment after the fragment was initially created
|
Lucy |
Oh cool. So far I've only made myFrag local to the newInstance() method.
|
Mark M. |
wait, what?
|
Lucy |
Oh well of course it gets returned by newInstance()
|
Mark M. |
ah, OK
|
Lucy |
Sorry I see now how it works.
|
Lucy |
I will have that reference already!
|
Lucy |
Second question, quickly...I am storing a value that I need globally in the SharedPreferences. Not sure there is a better way to store a value globally? Its a String value.
|
Mark M. |
SharedPreferences itself is effectively a global
|
Lucy |
So for each Activity/Fragment that needs to the value I then fetch it from SharedPreferences
|
Lucy |
OK cool
|
Mark M. |
it gets cached at the process level automatically
|
Mark M. |
right
|
Lucy |
Oh fab. I didn't know that. So it will be both fast and reliable.
|
Lucy |
Thank you! I see time is almost up. Have a nice weekend.
|
Mark M. |
fast *after* the first access, when the SharedPreferences get read in from disk
|
Mark M. |
you too!
|
Lucy |
OK fast after the first read. This is excellent.
|
Sep 24 | 5:00 PM |
Lucy |
Thanks!
|
Lucy | has left the room |
Mark M. | turned off guest access |