1282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/*
2282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Copyright (C) 2010 The Android Open Source Project
3282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
4282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Licensed under the Apache License, Version 2.0 (the "License");
5282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * you may not use this file except in compliance with the License.
6282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * You may obtain a copy of the License at
7282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
8282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *      http://www.apache.org/licenses/LICENSE-2.0
9282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
10282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Unless required by applicable law or agreed to in writing, software
11282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * distributed under the License is distributed on an "AS IS" BASIS,
12282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * See the License for the specific language governing permissions and
14282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * limitations under the License.
15282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */
16282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
17282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipackage com.android.layoutlib.bridge.impl;
18282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
19282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.ide.common.rendering.api.IAnimationListener;
20282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.ide.common.rendering.api.Result;
21282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.ide.common.rendering.api.Result.Status;
22282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
23282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.animation.AnimationThread;
24282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.animation.Animator;
25282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
26282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipublic class PlayAnimationThread extends AnimationThread {
27282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
28282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    private final Animator mAnimator;
29282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
30282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    public PlayAnimationThread(Animator animator, RenderSessionImpl scene, String animName,
31282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            IAnimationListener listener) {
32282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        super(scene, animName, listener);
33282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        mAnimator = animator;
34282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
35282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
36282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @Override
37282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    public Result preAnimation() {
38282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        // start the animation. This will send a message to the handler right away, so
39282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        // the queue is filled when this method returns.
40282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        mAnimator.start();
41282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
42282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        return Status.SUCCESS.createResult();
43282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
44282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
45282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @Override
46282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    public void postAnimation() {
47282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        // nothing to be done.
48282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
49282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski}
50