On Tue, Jun 8, 2010 at 9:03 PM, Raymond Rodgers <[email protected]>wrote:

>
>
> On Tue, Jun 8, 2010 at 7:14 PM, Steve Howard <[email protected]> wrote:
>
>> A simple solution is to add an Overlay, override the draw() method, and
>> not actually do any drawing, but simply use the method as a hook to know
>> anytime the map has potentially moved or zoomed.  The problem is, this will
>> get called more often than necessary, so you'll need some custom logic to
>> decide when the viewport has changed "enough" for you to make a new query.
>>  This shouldn't be too difficult however -- you can track the current center
>> and zoom in your Overlay subclass -- and you'd probably need some kind of
>> logic like this anyway.
>>
>> Let me know how that works for you, or if it works at all.
>>
>> Steve
>>
>>
>> Thanks Steve, I eventually came to give that very method a try, although I
> haven't yet decided on how to avoid the excessive updating. I may try to
> find out when the user's fingers are no longer on the touch screen or when
> the trackball (if present) is no longer moved.
>

Yeah, you do have to do some work here, which is unfortunate.  There are
several options, you may already be aware of them.  One is to use
Overlay.onTouchEvent() to detect ACTION_UP events, which could help detect
when touch gestures have finished.  Another is to use a timeout mechanism in
draw() itself.  On each draw() call, you can have a Handler to send a
message at a specified time in the near future, after canceling any other
such previously requested messages.  When you get the message, you know the
user's been idle for that short period of time.
 android.view.GestureDetector uses this approach for long press detection,
among other things -- check out lines 456-7,
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/GestureDetector.java
.


> Can I recommend that a simpler method of doing this sort of detection be
> added in the future? Perhaps an interface/listener combination like many
> other similar cases?
>

I agree with this sentiment.

Steve



>
> Thanks,
> Raymond
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to