Mar 5 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Gabriele | has entered the room |
Mark M. |
hello, Gabriele!
|
Mark M. |
how can I help you today?
|
Marcin | has entered the room |
Marcin |
Hi
|
Mark M. |
hello, Marcin!
|
Mark M. |
how can I help you today?
|
Gabriele |
re-hi, sorry, my connection
|
Gabriele |
hi marcin
|
Marcin |
Hi Mark
|
Mar 5 | 4:00 PM |
Marcin |
my question is... I have a ui element (not on action bar) which when you press it invokes onSearchRequested
|
Marcin |
which in turn invokes Search Dialog
|
Marcin |
this app already has a custom action bar with its own gradient colors
|
Marcin |
when search dialog comes up on top of actionbar it has different styling
|
Marcin |
is there a way to style it so that it matches to my action bar?
|
Mark M. |
what "search dialog" are you referring to?
|
Marcin |
implementation as per google docs
|
Mark M. |
AFAIK, that's no longer your app and therefore cannot be styled
|
Mark M. |
but, I am far from certain on that
|
Mark M. |
I apologize for not being able to give you a definitive answer
|
Mark M. |
Gabriele: do you have a question?
|
Gabriele |
I'd like to do that when somebody connect to a
specified wi-fi's ssid, I execute some code, should I do this using a
Service/Intent so I don't need the user to open the app?
|
Marcin |
thats ok, google docs say "that's controlled by the Android system"
|
Marcin |
thanks Mark
|
Mar 5 | 4:05 PM |
Mark M. |
Gabriele: you should be able to create a
manifest-registered BroadcastReceiver that listens for
android.net.conn.CONNECTIVITY_CHANGE
|
Mark M. | |
Mark M. |
you should then be able to interrogate the system and see what the newly-connected network is
|
Gabriele |
then I check if it's wifi, if it's my ssid and then I execute some code (in a service, I suppose?)
|
Mark M. |
yes, since onReceive() runs on the main application thread
|
Mark M. |
you will want a Service with a background thread
|
Mark M. |
(e.g., my WakefulIntentService)
|
Gabriele |
then from the Service, can I run a method inside my app, or I should "copy" the method, in the service?
|
Gabriele |
can I call*
|
Mark M. |
your service is "inside" your "app"
|
Mark M. |
if you need that logic to be available from multiple components, put it in a helper class or static method
|
Gabriele |
ok, thank you
|
Mark M. |
Marcin: do you have another question?
|
Marcin |
nop
|
Mark M. |
OK
|
Mark M. |
Gabriele: do you have another question?
|
Gabriele |
no, thank you :)
|
Mark M. |
OK
|
Mark M. |
if either of you come up with a question, just ask
|
Mar 5 | 4:10 PM |
Marcin |
Im using this implementation https://github.com/woozzu/RefreshableListView
of pull-to refresh listview.. however when i pull down and swipe (to
switch tabs) the loader freezes. Any clue why it might be happening? or
maybe you know some other nice pull-down to refresh lib?
|
Mark M. |
well, AFAIK, the leading pull-to-refresh implementation (in terms of popularity) is https://github.com/chrisbanes/Android-PullToRef...
|
Mark M. |
I have not used any of them, as I am not a huge fan of pull-to-refresh as a UI paradigm
|
Mark M. |
what do you mean by "the loader freezes"?
|
Marcin |
thanks for the link. By freezes I mean that when I
swipe back to the tab which was loading.. I can still see a part of the
"Loading" message with arrow
|
Marcin |
and it doesnt dissapear
|
Mar 5 | 4:15 PM |
Mark M. |
oh
|
Mark M. |
I have no idea
|
Marcin |
np
|
Marcin |
why coders use m[Variable] pattern in android?
|
Marcin |
sorry for general question :)
|
Mark M. |
The m prefix is for data members
|
Mark M. |
You will sometimes see an s prefix for static data members
|
Mark M. |
it is just a coding convention, from their internal style guide http://source.android.com/source/code-style.htm...
|
Mark M. |
personally, I burned out on variable prefixes after a decade of Hungarian notation in the 1990s
|
Mar 5 | 4:20 PM |
Marcin |
:-)
|
Marcin |
had to look up Hungarian notation
|
Marcin |
thanks for link
|
Gabriele |
oh, I was using it, without knowning its name :P
|
Mark M. |
yeah, I am showing my age
|
Marcin |
I'm suppose to fix search system in one app
|
Marcin |
the search button is at the bottom tab (tabhost)
|
Marcin |
tabhost serves fragments
|
Marcin |
all in one MainActivity
|
Marcin |
when someone is going to press a search tab
|
Marcin |
the search fragment with action bar appears
|
Marcin |
... they created a searchable activity
|
Mar 5 | 4:25 PM |
Marcin |
but this activity is connected in a very funny ui-less way with MainActivity
|
Marcin |
View paste
(11 more lines)
|
Marcin |
notice finish() at the end
|
Marcin |
this is inside Searchable activity class
|
Mark M. |
what the heck is mainA?
|
Marcin |
:-)
|
Marcin |
as you probably guessed its instance of MainActivty
|
Mark M. |
let me guess: static data member?
|
Marcin |
private static MainActivity mainA;
|
Mark M. |
ick
|
Marcin |
proper way to fix it is to make the MainActivity searchable, right?
|
Mark M. |
presumably
|
Marcin |
and make all this in its own newIntent call
|
Mark M. |
again, presumably
|
Oliver | has entered the room |
Mar 5 | 4:30 PM |
Mark M. |
hello, Oliver!
|
Mark M. |
Oliver: do you have a question?
|
Oliver |
Hi Mark...a couple of Qs if you wouldn't mind
|
Mark M. |
go ahead with your first one
|
Oliver |
first regarding fragment options menus and activities with multiple fragments (like EU4YOU)
|
Oliver |
sometimes the options menus don't make sense....because the said fragment is already shown
|
Oliver |
like an action
|
Oliver |
should I be filtering those with the containing activity? if you follow me
|
Mark M. |
let me restate your question to see if I have this right, in the form of a scenario
|
Oliver |
a) activity -> fragment 1 [options menu fragment 2] -> fragment 2
|
Mark M. |
let's say you have a classic master-detail pattern
|
Oliver |
sure
|
Mark M. |
so you have a list on the left, details on the right
|
Mark M. |
and you have an edit action bar item, that when clicked replaces the details display view with an editing fragment
|
Mark M. |
and you want to know what to do about the edit action bar item... right?
|
Mar 5 | 4:35 PM |
Oliver |
erm...I don't think so
|
Oliver |
b) activity -> fragment 1 + fragment 2 [options menu fragment 2 - doesn't make sense]
|
Mark M. |
your shorthand does not make sense to me, in turn
|
Mark M. |
can you provide a scenario?
|
Oliver |
fragment 1 is say a control panel
|
Oliver |
and fragment 2 is, say, a list of 'saved items'
|
Oliver |
sometimes you navigate from the control panel to the 'saved items' via an options menu
|
Oliver |
_but_ in instances (e.g. tablet) where they are
both shown on the screen at the same time then the action to travel to
saved items doesn't make sense...because they are already shown
|
Mark M. |
um, OK
|
Mark M. |
have the activity be the one to contribute that item to the action bar/legacy options menu
|
Mark M. |
since the activity knows whether there is one
fragment or two, and what the second fragment is (if it exists), it can
know how to manage that item (e.g., disable or make it invisible)
|
Mar 5 | 4:40 PM |
Oliver |
ok...that makes sense...I can move the fragment options menu code into the activity
|
Oliver |
cheers
|
Mark M. |
the rest of the options menu items could be handled by the fragment, assuming they aren't in a similar boat
|
Mark M. |
the activity and all visible fragments collaborate on the action bar/options menu contents
|
Mark M. |
this navigation concept seems like something the
activity should own, as it is not tied to anything in the control panel
fragment
|
Mark M. |
but, if there are other things in the menu that are peculiar to the control panel fragment, the fragment could manage those
|
Oliver |
yup...with you... fragments / nested fragments add
when necessary.....but with tablets it can become feasible to show
separate concerns quite easily (because one has the space) - which can
cause this sort of an issue
|
Oliver |
nevermind
|
Oliver |
so my next Q was with regard to navigation recommendations
|
Oliver |
hierarchical vs temporal navigation
|
Mark M. |
(BTW: Marcin & Gabriele, if you have a question, chime in)
|
Oliver |
oh yes...sorry folks...can wait my turn
|
Mark M. |
Oliver: they were out of questions before you arrived
|
Mark M. |
so you can continue -- I'm just making sure they know to pipe up if they came up with a question in the interim
|
Mar 5 | 4:45 PM |
Oliver |
super
|
Oliver | |
Mark M. |
yeah, that's one of my pet peeves with Android
|
Mark M. |
back vs. up is on my list of things to cover in
the book, but no time real soon, hoping a new answer comes along that I
like better... :-)
|
Marcin |
bye guys
|
Mark M. |
anyway, I can still try to help
|
Mark M. |
what is your specific concern?
|
Oliver |
so I guess what I am saying is that navigating up
can pretty much always been done...but is that only recommended where
one has a web of activities...I actually decided earlier to only support
temporal...because back was essentially doing the same as up...although
things aren't finished yet.
|
Oliver |
I was just checking that ignoring the up concept is acceptable these days
|
Mark M. |
oh, I sure hope so
|
Mark M. |
besides, there are other ways you can get users to wherever "up" is
|
Mark M. |
action bar item, sliding menu, etc.
|
Oliver |
and I found that up basically fills the back stack full of useful junk
|
Oliver |
whereas 'back' keeps things clean
|
Mark M. |
that's my major concern with it
|
Mar 5 | 4:50 PM |
Oliver |
I am thinking right now that the sliding menu pattern _might_ allow one to put things on the back stack
|
Oliver |
_but_ otherwise back is sufficient
|
Mark M. |
sliding menus are third-party components and cannot mess with the back stack
|
Mark M. |
if someday a sliding menu is added to the OS, then perhaps it can mess with the back stack, but not until then
|
Oliver |
sure...but a sliding menu it can start an activity and add to the back stack
|
Mark M. |
that's not unique to a sliding menu though -- an action bar item, an options menu item, a Button, etc. can all start an activity
|
Oliver |
sure
|
Mark M. |
I thought you were referring to the up "feature" of adding a bunch of semi-fake stuff to the back stack automatically
|
Mark M. |
that's an OS-level capability
|
Mar 5 | 4:55 PM |
Oliver |
I was really thinking that when folk a buried deep
in the hierarchy...they don't have to press back to return to
main...they could use a sliding menu
|
Oliver |
which is a little like up
|
Mark M. |
yes
|
Mark M. |
the menu would use either
FLAG_ACTIVITY_REORDER_TO_FRONT or the
FLAG_ACTIVITY_CLEAR_TOP/FLAG_ACTIVITY_SINGLE_TOP pair to navigate to the
activity
|
Mark M. |
depending upon what BACK should do after having gone "up" via the menu
|
Oliver |
I think of back always as temporal
|
Oliver |
so sliding menu takes you somewhere....back returns you
|
Oliver |
I can see it can get quite messy
|
Mark M. |
agreed, though one common break from that is if you go to a "home" or "main" activity in your app, BACK would exit the app
|
Oliver |
ummmm..... A -> B -> A (then back) would exit the app? I would have assumed it would return you to B?
|
Mark M. |
by default, it will return you to B
|
Mark M. |
but not every app chooses to do it that way
|
Oliver |
sure
|
Oliver |
I think we are out of time
|
Oliver |
cheers for thay
|
Mar 5 | 5:00 PM |
Oliver |
*that
|
Mark M. |
yes, the chat is about over
|
Mark M. |
transcript will be posted shortly to http://commonsware.com/office-hours/
|
Oliver |
thanks
|
Gabriele |
thank you very much Mark, see you the next time :)
|
Mark M. |
the next office hours is tomorrow, 10am Eastern Time
|
Mark M. |
have a pleasant day, all!
|
Oliver | has left the room |
Gabriele | has left the room |
Marcin | has left the room |
Mark M. | turned off guest access |