Problem with ImageView and sheduled task in Timer (FIXED)

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Problem with ImageView and sheduled task in Timer (FIXED)

Postby Hebus » Wed Apr 15, 2009 1:23 pm

Hello guys,

I'm trying to implement an animated panning on an image, just like what we have in google map. I have one image loaded in an ImageView view, this image is zoomed in an panned to a specific area using a transform matrix.
When the screen is touch, the image follows the finger movement, and when you release your finger, the image should keep following its movement and slow down un til it stops.

But the problem is when I move the image in an OnTouchListener, I get the satisfying moving result on my android screen, but when I try to perform the same move, using the same implementation in a callback called from a timertask run method, the ImageView screen is then stuck, and I have to reload the ImageView bitmap to have it working again.

It seems that there is some problem when calling ImageView methods within a TimerTask... :(
Last edited by Hebus on Fri Apr 17, 2009 12:51 pm, edited 2 times in total.
Hebus
Junior Developer
Junior Developer
 
Posts: 14
Joined: Wed Apr 15, 2009 1:10 pm

Top

Postby Hebus » Wed Apr 15, 2009 4:56 pm

I found out a solution : http://markmail.org/message/ff4uttrjpi7tjnrg

Basically, it use an Animator to force constant redraw. It's not very clean but it works fine.
Hebus
Junior Developer
Junior Developer
 
Posts: 14
Joined: Wed Apr 15, 2009 1:10 pm

Postby Hebus » Thu Apr 16, 2009 1:20 pm

The previous solution was really not clean as it force redraw even if not needed.

I found a best way to do this, it uses handle.post() function to update the view from its thread and not from another.
Hebus
Junior Developer
Junior Developer
 
Posts: 14
Joined: Wed Apr 15, 2009 1:10 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests