Office Hours — Today, September 27

Tuesday, September 25

Sep 27
9:50 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:55 AM
tunneling
has entered the room
Mark M.
howdy tunneling!
how can I help you today?
tunneling
hello Mark. I don't have any specific questions. just going to hang out and see what I can learn today.
Mark M.
OK
if you come up with a question, just chime in
tunneling
will do.
Marcin
has entered the room
Mark M.
howdy Marcin
how can I help you today?
Marcin
ahh found the chat input
Hi Mark
10:00 AM
Marcin
I have an issue in my android app
could u help me with it
Mark M.
possibly
please explain the issue
Marcin
I did describe it on SO, sorry for tagging u with it
Mark M.
I have never attempted to apply an animation to a row in a ListView like this
however, I am not surprised that you are running into this problem
you are correct that if you call swapCursor(), ListView will reload its rows
Marcin
please continue :)
Mark M.
thanks to row recycling, there is no guarantee that row 1 will wind up in the same visual position after the reload
it is eminently possible that, after the reload, the View that had been row 1 is now in the position of row 4
the simplest solution would be to cancel any outstanding animation just before your call to swapCursor()
however, that won't handle the case where the user scrolls while your animation is going on, as that too will cause your row to be recycled, and so your animation will finish on some other data
Marcin
How I do it now is I use postDelayed - for the duration of animation
and then forceLoad on Adapter
10:05 AM
Marcin
while for duration of the animation blocking the possibility of interaction with other list items
Mark M.
if you feel that will be acceptable for your users, and it is behaving properly, I suppose that approach can work
Marcin
This kind of works, but from time to time if I click on items really fast after the animation.. still some of the rows move
Mark M.
it is possible that the touch events are being registered before you get a chance to run the code to block them
let's back up a step: why are you doing this animation in the first place?
Pedro T.
has entered the room
Pedro T.
Hi!
Mark M.
particularly a one-second "bounce" (out then in) would seem confusing to me as a user
(BTW, howdy, Pedro -- I will take a question from you shortly)
Pedro T.
ok no problem
Marcin
its for testing now.. but users swipe left or right on items to say yes/no per item
we thought it will be faster and more intuituive
but Im not sure I agree :)
anyway we want to play with it for now
Mark M.
horizontal swiping in a list really should be for "remove from the list", IMHO
not for toggling a yes/no state
10:10 AM
Mark M.
but, that's just me
Marcin
thanks Mark, please take question from Pedro
I have another one after that
Mark M.
OK
Pedro: do you have a question?
Pedro T.
dear Mark I have a question, I was wondering. Is there a way to add letters to the scrollbar of a ListView like in contact List of some phone apps?
Mark M.
yes
or, for a strict alphabetical one, http://developer.android.com/reference/and…
I don't have a sample handy, unfortunately
Pedro T.
ok thanks
Mark M.
though there are plenty of questions on StackOverflow that discuss AlphabetIndexer, such as http://stackoverflow.com/questions/5122749…
Pedro T.
I will try it!!
Marcin
10:15 AM
Mark M.
what do you mean by "If user closes the app"?
Marcin
lets say he will press back,back,back
till home screen appear
s
Mark M.
if you fail to unregister the LocationListener, you will be leaking it
you will continue to be handed locations until Android terminates your process
which could be in milliseconds or hours
oh, wait
you are using the PendingIntent flavor
hmmm...
I have not tried that
I have no idea how long that will live
it might go away when your process does, but that would be unusual for a PendingIntent-based API
more likely, it runs until a phone reboot, as you indicate
but those are guesses
Marcin
if we step back a bit the question would be : "can my app BroadcastReciver get Intent that is fired whenever user lcoation changes every 100m, without being active"..
Mark M.
in principle, the version of requestLocationUpdates() you are using would offer that
10:20 AM
Marcin
I guess I have to check that, thanks Mark for suggestions
Mark M.
Pedro: do you have another question?
Pedro T.
no, thanks. I'm playing with AlphabetIndexer for now.
tunneling
hey mark, i have a question...
Mark M.
tunneling: go ahead
tunneling
i was trying to implement an activity that used the action bar spinner navigation with a ViewPager
so if I choose Fruit from the spinner, i would have a Fragment for Apples, Bannanas, and Peaches.
then if I choose Meat from the spinner, I would have Fragments for Steak and Chicken.
10:25 AM
Mark M.
and these Fragments are in the ViewPager?
tunneling
yea.. listviews
they aren't updating
so if the ViewPager index 1 already had displayed a Fruit.. it wouldn't change to a Meat after choosing from the spinner
Mark M.
what specifically are you doing when the spinner selection changes?
tunneling
i tried to instantiate a new ViewPager once I got to my wits end, but that didn't work either
I think it's because the FragmentManager belongs to the main activity.. and I can't find a way to flush it
Mark M.
oh, I see what you're running into
let me guess: you are using FragmentPagerAdapter or FragmentStatePagerAdapter, right?
tunneling
yea
Mark M.
those classes cheat
they store the fragments under certain tags in the FragmentManager
and that sometimes confounds the sorts of things you're trying to do
it also messes up having multiple ViewPagers at once
tunneling
hmm
Mark M.
is the sole content of those Fragments just a ListView?
10:30 AM
tunneling
yea.. but the ListViews are custom layouts with listeners on the data
i mean list items
Mark M.
that's fine
you might consider rolling your own PagerAdapter, and perhaps just use plain ListViews rather than ListFragments
tunneling
ok.
Mark M.
or, fork whichever FragmentPagerAdapter you are using and tweak it as needed to get it to handle your scenario better
those classes are designed to handle fairly simple situations, not necessarily every possible way of using ViewPagers with fragments
tunneling
i tried a few things there.. i saw one comment on stackoverflow..
View paste
public int getItemPosition(Object object) {
    return POSITION_NONE;
}
but that didn't work for me
Mark M.
that's the default behavior, anyway, IIRC
tunneling
ok, i'll play with it some more and get back with you
Mark M.
OK
Marcin: do you have another question?
10:35 AM
Marcin
yes
When I remove the item from ListView
is it possible to make a collapsable effect
Mark M.
however, this is only for API Level 11, and I'm not sure if it is in the NineOldAndroids backport
and I haven't tried that yet myself
if anyone has any other questions, chime in
Marcin
Sorry for this question :) How sure are you that it can be made with info in that link ?
Mark M.
I'm not
Marcin
:) thanks!
Mark M.
however, it should be related to your question
10:40 AM
Marcin
I have one more question Mark
Mark M.
go ahead
Marcin
I have a ContentProvider with DB
I use CursorLoader to bind it with ListView
I return CursorLoader in onCreateLoader
and swap it withhin onLoadFinished
my question is
If I update the DB through contentResolver, will the ListView update?
Mark M.
it should
your CursorLoader will register a ContentObserver automatically
causing it to re-execute the query for the Loader and deliver that to you in onLoadFinished()
Marcin
I also thought so, but it is not happening.. any idea why?
I tried to init SimpleCursorAdapter with flags 0.. and others
Mark M.
not off the top of my head, sorry
Marcin
which corespond to ContentObservers
10:45 AM
Marcin
but to no efffect
When debuging I see that the DB is updated
but the onLoadFinished is not firing
Mark M.
are you doing the work in update() of your ContentProvider to trigger the observers?
Marcin
let me check
Mark M.
getContext().getContentResolver().notifyChange(url, null);
Marcin
View paste
// Notify any observers of the change in the data set.
    getContext().getContentResolver().notifyChange(uri, null);
Mark M.
and that's always executed in update() (i.e., it is not inside some if() check or something)?
Marcin
yes
Mark M.
that should trigger the ContentObservers then
Marcin
it does refresh when I forceLoad on CursorLoader right after I update on ContentProvider
can I check somehow if ContentObserver is existent (I have no idea about them)
?
Mark M.
you could look at the CursorLoader source code and see what it is doing
is the problem limited to updates? in other words, do inserts and deletes work properly?
10:50 AM
Marcin
good point.. i only use update for now
Mark M.
my ContentProvider sample from the book works for inserts and deletes but does not try updates
Marcin
I will try that
ok Thanks Mark, that was helpful. Keep up good work!
Mark M.
thanks!
anyone else have a question?
tunneling
im good for now. thanks mark.
10:55 AM
Mark M.
BTW, I should be releasing Version 4.2 of _The Busy Coder's Guide to Android Development_ later today
Marcin
Great!!
Mark are you fluent in OpenGL ?
for Android :)
Mark M.
definitely not
I can barely spell LoGpen
Marcin
hhehe
Mark M.
pLoGne
OpenGL
whatever
:-)
11:00 AM
Mark M.
that's a wrap for today's chat
Pedro T.
has left the room
Mark M.
next one is 4pm Eastern on Tuesday
have a pleasant day, all!
Marcin
have a nice evng Mark
tunneling
has left the room
Marcin
has left the room
Mark M.
turned off guest access

Tuesday, September 25

 

Office Hours

People in this transcript

  • Marcin
  • Mark Murphy
  • Pedro Teran
  • tunneling