Office Hours — Today, January 5

Tuesday, December 23, 2014

Jan 5
8:50 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:05 AM
Bill M.
has entered the room
Bill M.
Happy New Year Mark.
Mark M.
howdy, Bill!
Happy New Year to you as well!
how can I help you today?
Bill M.
I actually have a question.
9:10 AM
Bill M.
RE: Integration Tests
9:10 AM
Gabriele
has entered the room
Bill M.
Scenario: phone app sends an update to our middle tier. Middle tier handles millions of updates a day so it bundles them and updates the backend servers every 15 min.
Mark M.
(BTW, hello, Gabriele -- I will be with you shortly!)
Gabriele
Hello (happy new year)
Bill M.
I want to make an update to the middle tier, wait 15 min. and then validate that change.
Howdi Gabriele.
I setup the test easy enough. I even setup an alarmmanager to go off after the delay. I can see it when asking ADB about alarms and pending intents. It definitely runs as I see alarms and wakes incrementing, but nothing gets run.
How might you go about this?
Mark M.
can you be more specific about "nothing gets run"?
what is the nature of the "nothing"?
is it a WakefulBroadcastReceiver?
9:15 AM
Mark M.
and how are you determining that it isn't run? logging? debugger? some other form of output?
Bill M.
I set the PI as getService() and tried to have it start a service. Negatory. I set the PI as a getActivity() and tried to have it start another activity in my test project. Negatory. I have logging in both. Neither ever does anything. So, I tried debugging and I'm not getting into those things.
I did not extend wakeful ... maybe that's the clue I need :)
Mark M.
if this is a _WAKEUP alarm, you need to use something Wakeful
whether that's WakefulBroadcastReceiver or my WakefulIntentService or something that you roll yourself
Bill M.
Thank you Mark. I will give that a shot.
Right on.
Mark M.
now, if you are artificially preventing the device from falling asleep (e.g., USB power and developer settings), then something else is afoot
but, let me take a question from Gabriele, and I'll be back with you in a bit
Gabriele: your turn! do you have a question?
Gabriele
I'm using ArrayPagerAdapter, however when I close a private message using myadapter.remove(getPager().getCurrentItem()); sometimes it happen that more than one private message gets closed, how is this possible?
Mark M.
either you are accidentally calling that twice, or remove() is somehow removing multiple things
I have not encountered remove() removing multiple things
Gabriele
remove get an int, single, position, let me check if I call it twice
it seems not and this does not happen every time
after removing I'm calling mAdapter.notifyDataSetChanged();
9:20 AM
Mark M.
that should not be necessary, as remove() already does notifyDataSetChanged()
in fact, calling notifyDataSetChanged() on an ArrayPagerAdapter is a code smell, as it should handle all of that for you
if you find scenarios in which you need to call notifyDataSetChanged(), file issues
Gabriele
ok, thank you
Mark M.
now, remove() is a bit complicated, because not only do we need to really get rid of the page, but we also are shifting positions of every page after it
when you find that multiple private messages get closed, are they in sequential order?
Gabriele
yes
Mark M.
that's interesting
are these being closed in response to user input, or are you spontaneously closing them based on stuff coming in from the network?
Gabriele
user input
Mark M.
OK, that's what the demo app does too
Gabriele
to reproduce it, I do like this:
open 3 private messages, go back to the first
then I press the home button
then I back to the app and close the first
now first and second get removed, but third not
Mark M.
to be clear, "the home button" is the device HOME button, and "back to the app" means something like the recent-tasks list?
9:25 AM
Gabriele
the home button is the device home button yes, back to the app in my case is the notification icon
but I can try with recent task, too
yes, same thing with the recent list
Mark M.
basically, I am looking for a scenario that I can test using the ArrayPagerAdapter demo app
to see if I can reproduce the problem there
you might add some logging around your remove() calls, to confirm that you are not calling it twice somehow
if you are not, then probably it is a bug in ArrayPagerAdapter somewhere
and that's where being able to reproduce it with code that I can run is necessary
Gabriele
I see
Mark M.
let me take another question from Bill, and I'll be back with you in abit
er, a bit
Bill: your turn! do you have another question?
Bill M.
Nope.
9:30 AM
Mark M.
OK, if you come up with another one, chime in
Gabriele: back to you
I am firing up an emulator to see if I can get the same behavior with the demo app
Gabriele
ok
Bill M.
I have seen a similar behavior to Gabriele's though. A developer implemented an onTouch() rather than an onSelected() (vague memory here) ... every now and then it would fire multiple "touches"
I'll go do some more testing of my app. See you at the next office hours Mark. Cheers.
Good luck Gabriele.
Mark M.
Bill: sounds good -- next one is tomorrow at 4pm US Eastern
Gabriele: no luck in reproducing this with the regular demo app
launch app, swipe to Editor #3, swipe back to Editor #1, HOME, RECENTS, go back into app, close Editor #1, and Editor #2 is still there
Gabriele
probably my error somewhere
Mark M.
BTW, are you using the regular ArrayPagerAdapter or the v4 edition for the fragments backport?
Gabriele
extends android.support.v4.view.PagerAdapter
Mark M.
no, I mean ArrayPagerAdapter
there is com.commonsware.cwac.pager.ArrayPagerAdapter for native fragments
Gabriele
I'm importing com.commonsware.cwac.pager.ArrayPagerAdapter;
Mark M.
OK
that's the demo I just tried
so, at the moment, there's not a ton that I can do
Gabriele
can I give you access to the code?
Mark M.
well, in your case, IIRC, the code is an IRC client
what IRC server and channels have you been testing against?
9:35 AM
Mark M.
and is anyone looking at you funny for popping in and out of private channels this way? :-)
Gabriele
it is a network where I'm admin
the channel I'm using is public so they're seeying join/part :P
Mark M.
personally, I haven't used IRC in a decade or so
Gabriele
eheh
Mark M.
so I don't have a server, nicks, etc.
Gabriele
it is already filled, you don't have to, just put a random nick
if you don't get banned from the bot
Mark M.
yay bots
Gabriele
:P
Mark M.
well, add the logging, and confirm that you are not somehow calling remove() twice
if you are really sure that the problem is in ArrayPagerAdapter, and you don't mind me popping in and out of your server, you can send me the code and instructions
and I can try to make sense of what's going on with the adapter
9:40 AM
Gabriele
01-05 15:40:04.445 2674-2674/net.fr0g.mchat D/mChat﹕ RemoveConversation
it seems that the method is called only one time
but two conversation closed
no, called two times, there is my error somewhere
Mark M.
OK
not much I can do to help with that from here
9:45 AM
Mark M.
though it is odd that it takes a HOME-and-RECENTS flow to make it occur, rather than just every time you remove a conversation
Gabriele
yes
Mark M.
your process probably is intact across a quick pop to the home screen and back
Gabriele
I've tried "Find usages" from android studio, too
Mark M.
if you are overriding onUserLeaveHint() anywhere, that might be a place to investigate
Gabriele
but I call it only one time
no, I'm not overriding it
or I can invite you to the repository, maybe you can see it easily
Mark M.
probably not
I am a bit slow to absorb large code bases
I can do it, but it's not the sort of thing that 10 minutes of poking around will likely turn anything up
9:50 AM
Gabriele
if I don't press Home, sometimes it's working, sometimes not
but from Logs I always see two calls
Mark M.
what is the trigger that causes your call to the method with the RemoveConversation log entry? you said it was user input, but what specifically is the action?
Gabriele
the fact is that onOptionsItemSelected is called twice
Mark M.
so, the user taps an action bar item?
Gabriele
yes
I'm overriding onOptionsItemSelected from the fragment
Mark M.
and it's being called twice?
that's rather strange
9:55 AM
Gabriele
yes
oh
maybe because I'm returning super.onOptionsItemSelected(item);
I should return true
Mark M.
that in itself isn't a problem
assuming you only do so if you did not handle the event yourself
(i.e., only chain to super for action items that you do not recognize, so the superclass can handle them)
I do wonder if you somehow have two instances of your fragment floating around, though
Gabriele
hm
how can I check this?
Mark M.
more logging
there's no way to ask a FragmentManager to iterate over the fragments it owns
and in the case of a duplicate fragment, methods like findFragmentById() only return one fragment
Gabriele
but to do so, I have to use myadapterm.add(new SimplePageDescriptor(); with different id, right?
because if I use the same id, I get an exception
10:00 AM
Mark M.
wait
Bill M.
has left the room
Mark M.
the remove conversation action bar item is being declared by a page in the action bar itself?
sorry, let me rephrase that
the remove conversation action bar item is being put in the action bar by the conversation page?
Gabriele
yes
Mark M.
in which case, you'll have "duplicate" fragments, but still only one should get the onOptionsItemSelected() call
Gabriele
why?
Mark M.
specifically, whatever fragment is the current page
if by "why?" you mean "why a duplicate?", because I presume each of your pages is from the same fragment class
Gabriele
yes, all conversations are from the same fragment class
Mark M.
if by "why?" you mean "why only one call?", that should be handled by ArrayPagerAdapter
I have to call setMenuVisibility() as fragments come and go from the foreground
(and setUserVisibleHint() on newer devices)
it's possible there's a bug in there somewhere, but again, I haven't ever seen a problem
Gabriele
I will try to investigate and let you know the next time :P
thank you for your help and patience
Mark M.
what you might do is include some more information in your logging, such as the toString() of the fragment that was called with onOptionsItemSelected(), to confirm whether the duplicate calls are going to separate fragments
Gabriele
ok
Mark M.
and, yes, the office hours time is up
I'll post the chat transcript shortly
the next chat is tomorrow at 4pm US Eastern
Gabriele
thank you, see you the next tim
10:05 AM
Mark M.
have a pleasant day!
Gabriele
e*
you too :)
Gabriele
has left the room
Mark M.
turned off guest access

Tuesday, December 23, 2014

 

Office Hours

People in this transcript

  • Bill Mote
  • Gabriele
  • Mark Murphy