Sep 27 | 9:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 27 | 9:55 AM |
tunneling | has entered the room |
Mark M. |
howdy tunneling!
|
Mark M. |
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
|
Mark M. |
if you come up with a question, just chime in
|
tunneling |
will do.
|
Marcin | has entered the room |
Mark M. |
howdy Marcin
|
Mark M. |
how can I help you today?
|
Marcin |
ahh found the chat input
|
Marcin |
Hi Mark
|
Sep 27 | 10:00 AM |
Marcin |
I have an issue in my android app
|
Marcin |
could u help me with it
|
Mark M. |
possibly
|
Mark M. |
please explain the issue
|
Marcin |
I did describe it on SO, sorry for tagging u with it
|
Marcin | |
Mark M. |
I have never attempted to apply an animation to a row in a ListView like this
|
Mark M. |
however, I am not surprised that you are running into this problem
|
Mark M. |
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
|
Mark M. |
it is eminently possible that, after the reload, the View that had been row 1 is now in the position of row 4
|
Mark M. |
the simplest solution would be to cancel any outstanding animation just before your call to swapCursor()
|
Mark M. |
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
|
Marcin |
and then forceLoad on Adapter
|
Sep 27 | 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
|
Mark M. |
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
|
Mark M. |
(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
|
Marcin |
we thought it will be faster and more intuituive
|
Marcin |
but Im not sure I agree :)
|
Marcin |
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
|
Mark M. |
not for toggling a yes/no state
|
Sep 27 | 10:10 AM |
Mark M. |
but, that's just me
|
Marcin |
thanks Mark, please take question from Pedro
|
Marcin |
I have another one after that
|
Mark M. |
OK
|
Mark M. |
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
|
Mark M. | |
Mark M. |
or, for a strict alphabetical one, http://developer.android.com/reference/and…
|
Mark M. |
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 |
Mark, my next question : http://stackoverflow.com/questions/1262227…
|
Sep 27 | 10:15 AM |
Mark M. |
what do you mean by "If user closes the app"?
|
Marcin |
lets say he will press back,back,back
|
Marcin |
till home screen appear
|
Marcin |
s
|
Mark M. |
if you fail to unregister the LocationListener, you will be leaking it
|
Mark M. |
you will continue to be handed locations until Android terminates your process
|
Mark M. |
which could be in milliseconds or hours
|
Mark M. |
oh, wait
|
Mark M. |
you are using the PendingIntent flavor
|
Mark M. |
hmmm...
|
Mark M. |
I have not tried that
|
Mark M. |
I have no idea how long that will live
|
Mark M. |
it might go away when your process does, but that would be unusual for a PendingIntent-based API
|
Mark M. |
more likely, it runs until a phone reboot, as you indicate
|
Mark M. |
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
|
Sep 27 | 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
|
tunneling |
so if I choose Fruit from the spinner, i would have a Fragment for Apples, Bannanas, and Peaches.
|
tunneling |
then if I choose Meat from the spinner, I would have Fragments for Steak and Chicken.
|
Sep 27 | 10:25 AM |
Mark M. |
and these Fragments are in the ViewPager?
|
tunneling |
yea.. listviews
|
tunneling |
they aren't updating
|
tunneling |
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
|
tunneling |
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
|
Mark M. |
let me guess: you are using FragmentPagerAdapter or FragmentStatePagerAdapter, right?
|
tunneling |
yea
|
Mark M. |
those classes cheat
|
Mark M. |
they store the fragments under certain tags in the FragmentManager
|
Mark M. |
and that sometimes confounds the sorts of things you're trying to do
|
Mark M. |
it also messes up having multiple ViewPagers at once
|
tunneling |
hmm
|
Mark M. |
is the sole content of those Fragments just a ListView?
|
Sep 27 | 10:30 AM |
tunneling |
yea.. but the ListViews are custom layouts with listeners on the data
|
tunneling |
i mean list items
|
Mark M. |
that's fine
|
Mark M. |
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
|
Mark M. |
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..
|
tunneling | |
tunneling |
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
|
Mark M. |
Marcin: do you have another question?
|
Sep 27 | 10:35 AM |
Marcin |
yes
|
Marcin |
When I remove the item from ListView
|
Marcin |
is it possible to make a collapsable effect
|
Mark M. | |
Mark M. |
however, this is only for API Level 11, and I'm not sure if it is in the NineOldAndroids backport
|
Mark M. |
and I haven't tried that yet myself
|
Mark M. |
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
|
Sep 27 | 10:40 AM |
Marcin |
I have one more question Mark
|
Mark M. |
go ahead
|
Marcin |
I have a ContentProvider with DB
|
Marcin |
I use CursorLoader to bind it with ListView
|
Marcin |
I return CursorLoader in onCreateLoader
|
Marcin |
and swap it withhin onLoadFinished
|
Marcin |
my question is
|
Marcin |
If I update the DB through contentResolver, will the ListView update?
|
Mark M. |
it should
|
Mark M. |
your CursorLoader will register a ContentObserver automatically
|
Mark M. |
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?
|
Marcin |
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
|
Sep 27 | 10:45 AM |
Marcin |
but to no efffect
|
Marcin |
When debuging I see that the DB is updated
|
Marcin |
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
|
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
|
Marcin |
can I check somehow if ContentObserver is existent (I have no idea about them)
|
Marcin |
?
|
Mark M. |
you could look at the CursorLoader source code and see what it is doing
|
Mark M. |
is the problem limited to updates? in other words, do inserts and deletes work properly?
|
Sep 27 | 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
|
Mark M. | |
Marcin |
I will try that
|
Marcin |
ok Thanks Mark, that was helpful. Keep up good work!
|
Mark M. |
thanks!
|
Mark M. |
anyone else have a question?
|
tunneling |
im good for now. thanks mark.
|
Sep 27 | 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!!
|
Marcin |
Mark are you fluent in OpenGL ?
|
Marcin |
for Android :)
|
Mark M. |
definitely not
|
Mark M. |
I can barely spell LoGpen
|
Marcin |
hhehe
|
Mark M. |
pLoGne
|
Mark M. |
OpenGL
|
Mark M. |
whatever
|
Mark M. |
:-)
|
Sep 27 | 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
|
Mark M. |
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 |