You can use a Canvas to draw an image into a Bitmap on a background
thread.  Then when that's finished, draw the Bitmap into the View (in
onDraw) on the main thread.

I'd be worried about a drawing function that takes several seconds to
run.  We like to keep drawing well under 16ms in order to ensure a
good framerate and smooth animations.

Jeff.

On Thu, Jul 7, 2011 at 9:53 AM, andrei-dmitriev
<[email protected]> wrote:
> The longRoutine is the drawing procedure which may take up to several
> seconds.
>
> Yep, I tried to relay that onto another thread and draw into the SurfaceView
> but the problem I've faced is that
> the original view(s) are still repainted with onDraw() thus the content (the
> background thread is rendering all the time) is missing. It's called from
> the deep android internals so I don't believe I trigger it somehow - it's
> just a reaction on the invalidate().
> Well, it is covered with blank rectangle but I can see the actual content
> under that rectangle.
> BTW that looks like a thread condition over there as sometimes (very rarely)
> I can see the content for a few moments which then becomes covered with
> background color.
>
> So far I also tried to:
> a) setWillNotDraw(true);
> b) unset the background color of the view
>
> Interestingly that in a sample application (a SurfaceView in a RelativeView)
> the b) approach does help and since that we don't have such a problem there.
>
> So the problem now could be read like this (I'm starting to think there is
> no way to peek events from the queue, right? :) :
> How to switch the SurfaceView's onDraw() method off?
> Any cluea of what can make it been called also appreciated.
>
> Thanks,
> Andrei
>
>
> 07.07.2011 17:18, Mark Murphy пишет:
>>
>> On Thu, Jul 7, 2011 at 9:11 AM, andrei-dmitriev
>> <[email protected]>  wrote:
>>>
>>> why there is no a way to poll or peek the message from the event queue?
>>> I want it to implement the break for the routine running on the UI
>>> thread.
>>> private void longRoutine() {
>>>    while (flag){
>>>        if (queue.peekMessage() != null) {
>>>            return;
>>>        }
>>> <whatever the code is>
>>>    }
>>> }
>>>
>>> Or am I missing something and actually a way exists?
>>
>> It's called a "background thread". All the cool programmers use them.
>>
>> Why do you think that you need longRoutine() to be on the main
>> application thread?
>>
>
> --
> 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
>

-- 
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