Office Hours — Today, March 5

Yesterday, March 4

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!
how can I help you today?
Marcin
has entered the room
Marcin
Hi
Mark M.
hello, Marcin!
how can I help you today?
Gabriele
re-hi, sorry, my connection
hi marcin
Marcin
Hi Mark
4:00 PM
Marcin
my question is... I have a ui element (not on action bar) which when you press it invokes onSearchRequested
which in turn invokes Search Dialog
this app already has a custom action bar with its own gradient colors
when search dialog comes up on top of actionbar it has different styling
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
but, I am far from certain on that
I apologize for not being able to give you a definitive answer
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"
thanks Mark
4:05 PM
Mark M.
Gabriele: you should be able to create a manifest-registered BroadcastReceiver that listens for android.net.conn.CONNECTIVITY_CHANGE
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
you will want a Service with a background thread
(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?
can I call*
Mark M.
your service is "inside" your "app"
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
Gabriele: do you have another question?
Gabriele
no, thank you :)
Mark M.
OK
if either of you come up with a question, just ask
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...
I have not used any of them, as I am not a huge fan of pull-to-refresh as a UI paradigm
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
and it doesnt dissapear
4:15 PM
Mark M.
oh
I have no idea
Marcin
np
why coders use m[Variable] pattern in android?
sorry for general question :)
Mark M.
The m prefix is for data members
You will sometimes see an s prefix for static data members
it is just a coding convention, from their internal style guide http://source.android.com/source/code-style.htm...
personally, I burned out on variable prefixes after a decade of Hungarian notation in the 1990s
4:20 PM
Marcin
:-)
had to look up Hungarian notation
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
the search button is at the bottom tab (tabhost)
tabhost serves fragments
all in one MainActivity
when someone is going to press a search tab
the search fragment with action bar appears
... they created a searchable activity
4:25 PM
Marcin
but this activity is connected in a very funny ui-less way with MainActivity
View paste (11 more lines)
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ZLog.e(LOG, "onCreate");
		Intent intent = getIntent();
		Intent startingIntent = new Intent(this, MainActivity.class);
		Bundle bundle = new Bundle();
		bundle.putString("tab", MainActivity.TAB_SEARCH);
		String query = intent.getExtras().getString(SearchManager.QUERY);
		bundle.putString("query", query);
		bundle.putBoolean("show_results", true);
		startingIntent.putExtras(bundle);
		if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
			ZLog.d(LOG, "Intent.ACTION_SEARCH");
			updateRecentQueries(query);
...
notice finish() at the end
this is inside Searchable activity class
Mark M.
what the heck is mainA?
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
4:30 PM
Mark M.
hello, Oliver!
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)
sometimes the options menus don't make sense....because the said fragment is already shown
like an action
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
and you have an edit action bar item, that when clicked replaces the details display view with an editing fragment
and you want to know what to do about the edit action bar item... right?
4:35 PM
Oliver
erm...I don't think so
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
can you provide a scenario?
Oliver
fragment 1 is say a control panel
and fragment 2 is, say, a list of 'saved items'
sometimes you navigate from the control panel to the 'saved items' via an options menu
_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
have the activity be the one to contribute that item to the action bar/legacy options menu
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)
4:40 PM
Oliver
ok...that makes sense...I can move the fragment options menu code into the activity
cheers
Mark M.
the rest of the options menu items could be handled by the fragment, assuming they aren't in a similar boat
the activity and all visible fragments collaborate on the action bar/options menu contents
this navigation concept seems like something the activity should own, as it is not tied to anything in the control panel fragment
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
nevermind
so my next Q was with regard to navigation recommendations
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
so you can continue -- I'm just making sure they know to pipe up if they came up with a question in the interim
4:45 PM
Oliver
super
Mark M.
yeah, that's one of my pet peeves with Android
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
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.
I was just checking that ignoring the up concept is acceptable these days
Mark M.
oh, I sure hope so
besides, there are other ways you can get users to wherever "up" is
action bar item, sliding menu, etc.
Oliver
and I found that up basically fills the back stack full of useful junk
whereas 'back' keeps things clean
Mark M.
that's my major concern with it
4:50 PM
Oliver
I am thinking right now that the sliding menu pattern _might_ allow one to put things on the back stack
_but_ otherwise back is sufficient
Mark M.
sliding menus are third-party components and cannot mess with the back stack
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
that's an OS-level capability
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
which is a little like up
Mark M.
yes
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
depending upon what BACK should do after having gone "up" via the menu
Oliver
I think of back always as temporal
so sliding menu takes you somewhere....back returns you
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
but not every app chooses to do it that way
Oliver
sure
I think we are out of time
cheers for thay
5:00 PM
Oliver
*that
Mark M.
yes, the chat is about over
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
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

Yesterday, March 4

 

Office Hours

People in this transcript

  • Gabriele
  • Marcin
  • Mark Murphy
  • Oliver