Jan 5 | 8:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jan 5 | 9:05 AM |
Bill M. | has entered the room |
Bill M. |
Happy New Year Mark.
|
Mark M. |
howdy, Bill!
|
Mark M. |
Happy New Year to you as well!
|
Mark M. |
how can I help you today?
|
Bill M. |
I actually have a question.
|
Jan 5 | 9:10 AM |
Bill M. |
RE: Integration Tests
|
Jan 5 | 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.
|
Bill M. |
Howdi Gabriele.
|
Bill M. |
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.
|
Bill M. |
How might you go about this?
|
Mark M. |
can you be more specific about "nothing gets run"?
|
Mark M. |
what is the nature of the "nothing"?
|
Mark M. |
is it a WakefulBroadcastReceiver?
|
Jan 5 | 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.
|
Bill M. |
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
|
Mark M. |
whether that's WakefulBroadcastReceiver or my WakefulIntentService or something that you roll yourself
|
Bill M. |
Thank you Mark. I will give that a shot.
|
Bill M. |
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
|
Mark M. |
but, let me take a question from Gabriele, and I'll be back with you in a bit
|
Mark M. |
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
|
Mark M. |
I have not encountered remove() removing multiple things
|
Gabriele |
remove get an int, single, position, let me check if I call it twice
|
Gabriele |
it seems not and this does not happen every time
|
Gabriele |
after removing I'm calling mAdapter.notifyDataSetChanged();
|
Jan 5 | 9:20 AM |
Mark M. |
that should not be necessary, as remove() already does notifyDataSetChanged()
|
Mark M. |
in fact, calling notifyDataSetChanged() on an ArrayPagerAdapter is a code smell, as it should handle all of that for you
|
Mark M. |
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
|
Mark M. |
when you find that multiple private messages get closed, are they in sequential order?
|
Gabriele |
yes
|
Mark M. |
that's interesting
|
Mark M. |
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:
|
Gabriele |
open 3 private messages, go back to the first
|
Gabriele |
then I press the home button
|
Gabriele |
then I back to the app and close the first
|
Gabriele |
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?
|
Jan 5 | 9:25 AM |
Gabriele |
the home button is the device home button yes, back to the app in my case is the notification icon
|
Gabriele |
but I can try with recent task, too
|
Gabriele |
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
|
Mark M. |
to see if I can reproduce the problem there
|
Mark M. |
you might add some logging around your remove() calls, to confirm that you are not calling it twice somehow
|
Mark M. |
if you are not, then probably it is a bug in ArrayPagerAdapter somewhere
|
Mark M. |
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
|
Mark M. |
er, a bit
|
Mark M. |
Bill: your turn! do you have another question?
|
Bill M. |
Nope.
|
Jan 5 | 9:30 AM |
Mark M. |
OK, if you come up with another one, chime in
|
Mark M. |
Gabriele: back to you
|
Mark M. |
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"
|
Bill M. |
I'll go do some more testing of my app. See you at the next office hours Mark. Cheers.
|
Bill M. |
Good luck Gabriele.
|
Mark M. |
Bill: sounds good -- next one is tomorrow at 4pm US Eastern
|
Mark M. |
Gabriele: no luck in reproducing this with the regular demo app
|
Mark M. |
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
|
Mark M. |
there is com.commonsware.cwac.pager.ArrayPagerAdapter for native fragments
|
Gabriele |
I'm importing com.commonsware.cwac.pager.ArrayPagerAdapter;
|
Mark M. |
OK
|
Mark M. |
that's the demo I just tried
|
Mark M. |
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
|
Mark M. |
what IRC server and channels have you been testing against?
|
Jan 5 | 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
|
Gabriele |
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
|
Gabriele |
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
|
Mark M. |
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
|
Mark M. |
and I can try to make sense of what's going on with the adapter
|
Jan 5 | 9:40 AM |
Gabriele |
01-05 15:40:04.445 2674-2674/net.fr0g.mchat D/mChat﹕ RemoveConversation
|
Gabriele |
it seems that the method is called only one time
|
Gabriele |
but two conversation closed
|
Gabriele |
no, called two times, there is my error somewhere
|
Mark M. |
OK
|
Mark M. |
not much I can do to help with that from here
|
Jan 5 | 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
|
Gabriele |
no, I'm not overriding it
|
Gabriele |
or I can invite you to the repository, maybe you can see it easily
|
Mark M. |
probably not
|
Mark M. |
I am a bit slow to absorb large code bases
|
Mark M. |
I can do it, but it's not the sort of thing that 10 minutes of poking around will likely turn anything up
|
Jan 5 | 9:50 AM |
Gabriele |
if I don't press Home, sometimes it's working, sometimes not
|
Gabriele |
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
|
Gabriele |
I'm overriding onOptionsItemSelected from the fragment
|
Mark M. |
and it's being called twice?
|
Mark M. |
that's rather strange
|
Jan 5 | 9:55 AM |
Gabriele |
yes
|
Gabriele |
oh
|
Gabriele |
maybe because I'm returning super.onOptionsItemSelected(item);
|
Gabriele |
I should return true
|
Mark M. |
that in itself isn't a problem
|
Mark M. |
assuming you only do so if you did not handle the event yourself
|
Mark M. |
(i.e., only chain to super for action items that you do not recognize, so the superclass can handle them)
|
Mark M. |
I do wonder if you somehow have two instances of your fragment floating around, though
|
Gabriele |
hm
|
Gabriele |
how can I check this?
|
Mark M. |
more logging
|
Mark M. |
there's no way to ask a FragmentManager to iterate over the fragments it owns
|
Mark M. |
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?
|
Gabriele |
because if I use the same id, I get an exception
|
Jan 5 | 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?
|
Mark M. |
sorry, let me rephrase that
|
Mark M. |
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
|
Mark M. |
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
|
Mark M. |
I have to call setMenuVisibility() as fragments come and go from the foreground
|
Mark M. |
(and setUserVisibleHint() on newer devices)
|
Mark M. |
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
|
Gabriele |
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
|
Mark M. |
I'll post the chat transcript shortly
|
Mark M. |
the next chat is tomorrow at 4pm US Eastern
|
Gabriele |
thank you, see you the next tim
|
Jan 5 | 10:05 AM |
Mark M. |
have a pleasant day!
|
Gabriele |
e*
|
Gabriele |
you too :)
|
Gabriele | has left the room |
Mark M. | turned off guest access |