Michael Jurka | 2763be3 | 2011-02-24 11:19:57 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.launcher2; |
| 18 | |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 19 | import android.animation.Animator; |
Michael Jurka | 2763be3 | 2011-02-24 11:19:57 -0800 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.util.AttributeSet; |
| 22 | import android.widget.TabHost; |
| 23 | |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 24 | public class CustomizeTrayTabHost extends TabHost implements LauncherTransitionable { |
| 25 | private boolean mFirstLayout = true; |
| 26 | |
Michael Jurka | 2763be3 | 2011-02-24 11:19:57 -0800 | [diff] [blame] | 27 | public CustomizeTrayTabHost(Context context) { |
| 28 | super(context); |
| 29 | } |
| 30 | |
| 31 | public CustomizeTrayTabHost(Context context, AttributeSet attrs) { |
| 32 | super(context, attrs); |
| 33 | } |
| 34 | |
| 35 | @Override |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 36 | public void onLauncherTransitionStart(Animator animation) { |
| 37 | if (animation != null) { |
| 38 | setLayerType(LAYER_TYPE_HARDWARE, null); |
| 39 | // just a sanity check that we don't build a layer before a call to onLayout |
| 40 | if (!mFirstLayout) { |
| 41 | // force building the layer at the beginning of the animation, so you don't get a |
| 42 | // blip early in the animation |
| 43 | buildLayer(); |
| 44 | } |
| 45 | } |
Michael Jurka | 2763be3 | 2011-02-24 11:19:57 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | @Override |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 49 | public void onLauncherTransitionEnd(Animator animation) { |
| 50 | if (animation != null) { |
| 51 | setLayerType(LAYER_TYPE_NONE, null); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | protected void onLayout(boolean changed, int l, int t, int r, int b) { |
| 57 | mFirstLayout = false; |
| 58 | super.onLayout(changed, l, t, r, b); |
Michael Jurka | 2763be3 | 2011-02-24 11:19:57 -0800 | [diff] [blame] | 59 | } |
| 60 | } |