The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Joe Onorato | a590252 | 2009-07-30 13:37:37 -0700 | [diff] [blame] | 17 | package com.android.launcher2; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 19 | import android.content.Context; |
| 20 | import android.content.res.TypedArray; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 21 | import android.graphics.PorterDuff; |
| 22 | import android.graphics.PorterDuffColorFilter; |
Michael Jurka | 3adcb0c | 2010-10-15 18:07:21 -0700 | [diff] [blame] | 23 | import android.graphics.Rect; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 24 | import android.graphics.RectF; |
| 25 | import android.graphics.drawable.TransitionDrawable; |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 26 | import android.util.AttributeSet; |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 27 | import android.view.View; |
| 28 | import android.view.animation.AccelerateInterpolator; |
| 29 | import android.view.animation.AlphaAnimation; |
| 30 | import android.view.animation.Animation; |
| 31 | import android.view.animation.AnimationSet; |
| 32 | import android.view.animation.TranslateAnimation; |
Romain Guy | edcce09 | 2010-03-04 13:03:17 -0800 | [diff] [blame] | 33 | |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 34 | import com.android.launcher.R; |
| 35 | |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 36 | public class DeleteZone extends IconDropTarget { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 37 | private static final int ORIENTATION_HORIZONTAL = 1; |
| 38 | private static final int TRANSITION_DURATION = 250; |
| 39 | private static final int ANIMATION_DURATION = 200; |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 40 | private static final int XLARGE_TRANSITION_DURATION = 150; |
| 41 | private static final int XLARGE_ANIMATION_DURATION = 200; |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 42 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 43 | private AnimationSet mInAnimation; |
| 44 | private AnimationSet mOutAnimation; |
| 45 | private Animation mHandleInAnimation; |
| 46 | private Animation mHandleOutAnimation; |
| 47 | |
| 48 | private int mOrientation; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 49 | private DragController mDragController; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 50 | |
Michael Jurka | 3adcb0c | 2010-10-15 18:07:21 -0700 | [diff] [blame] | 51 | private final RectF mRegionF = new RectF(); |
| 52 | private final Rect mRegion = new Rect(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 53 | private TransitionDrawable mTransition; |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 54 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 55 | public DeleteZone(Context context, AttributeSet attrs) { |
| 56 | this(context, attrs, 0); |
| 57 | } |
| 58 | |
| 59 | public DeleteZone(Context context, AttributeSet attrs, int defStyle) { |
| 60 | super(context, attrs, defStyle); |
| 61 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 62 | final int srcColor = context.getResources().getColor(R.color.delete_color_filter); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 63 | mHoverPaint.setColorFilter(new PorterDuffColorFilter(srcColor, PorterDuff.Mode.SRC_ATOP)); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 64 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 65 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeleteZone, defStyle, 0); |
| 66 | mOrientation = a.getInt(R.styleable.DeleteZone_direction, ORIENTATION_HORIZONTAL); |
| 67 | a.recycle(); |
Winson Chung | be5212b | 2010-12-20 11:36:33 -0800 | [diff] [blame] | 68 | |
| 69 | int tb = getResources().getDimensionPixelSize(R.dimen.delete_zone_vertical_drag_padding); |
| 70 | int lr = getResources().getDimensionPixelSize(R.dimen.delete_zone_horizontal_drag_padding); |
| 71 | setDragPadding(tb, lr, tb, lr); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | @Override |
| 75 | protected void onFinishInflate() { |
| 76 | super.onFinishInflate(); |
Joe Onorato | a9c28f6 | 2009-09-14 18:38:49 -0400 | [diff] [blame] | 77 | mTransition = (TransitionDrawable) getDrawable(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 81 | DragView dragView, Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 82 | return true; |
| 83 | } |
| 84 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 85 | public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
| 86 | DragView dragView, Object dragInfo) { |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 87 | if (!mDragAndDropEnabled) return; |
| 88 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 89 | final ItemInfo item = (ItemInfo) dragInfo; |
| 90 | |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 91 | // On x-large screens, you can uninstall an app by dragging from all apps |
| 92 | if (item instanceof ApplicationInfo && LauncherApplication.isScreenXLarge()) { |
Patrick Dubroy | 5539af7 | 2010-09-07 15:22:01 -0700 | [diff] [blame] | 93 | mLauncher.startApplicationUninstallActivity((ApplicationInfo) item); |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 94 | } |
| 95 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 96 | if (item.container == -1) return; |
| 97 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 98 | if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { |
The Android Open Source Project | 7376fae | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 99 | if (item instanceof LauncherAppWidgetInfo) { |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 100 | mLauncher.removeAppWidget((LauncherAppWidgetInfo) item); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 101 | } |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 102 | } else if (source instanceof UserFolder) { |
| 103 | final UserFolder userFolder = (UserFolder) source; |
| 104 | final UserFolderInfo userFolderInfo = (UserFolderInfo) userFolder.getInfo(); |
| 105 | // Item must be a ShortcutInfo otherwise it couldn't have been in the folder |
| 106 | // in the first place. |
| 107 | userFolderInfo.remove((ShortcutInfo)item); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 108 | } |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 109 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 110 | if (item instanceof UserFolderInfo) { |
| 111 | final UserFolderInfo userFolderInfo = (UserFolderInfo)item; |
| 112 | LauncherModel.deleteUserFolderContentsFromDatabase(mLauncher, userFolderInfo); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 113 | mLauncher.removeFolder(userFolderInfo); |
The Android Open Source Project | 7376fae | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 114 | } else if (item instanceof LauncherAppWidgetInfo) { |
| 115 | final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item; |
| 116 | final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost(); |
| 117 | if (appWidgetHost != null) { |
Brad Fitzpatrick | 73013bf | 2010-09-14 12:15:32 -0700 | [diff] [blame] | 118 | final int appWidgetId = launcherAppWidgetInfo.appWidgetId; |
| 119 | // Deleting an app widget ID is a void call but writes to disk before returning |
| 120 | // to the caller... |
| 121 | new Thread("deleteAppWidgetId") { |
| 122 | public void run() { |
| 123 | appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId); |
| 124 | } |
| 125 | }.start(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 126 | } |
| 127 | } |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 128 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 129 | LauncherModel.deleteItemFromDatabase(mLauncher, item); |
| 130 | } |
| 131 | |
| 132 | public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 133 | DragView dragView, Object dragInfo) { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 134 | if (mDragAndDropEnabled) { |
| 135 | mTransition.reverseTransition(getTransitionAnimationDuration()); |
| 136 | super.onDragEnter(source, x, y, xOffset, yOffset, dragView, dragInfo); |
| 137 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset, |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 141 | DragView dragView, Object dragInfo) { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 142 | if (mDragAndDropEnabled) { |
| 143 | mTransition.reverseTransition(getTransitionAnimationDuration()); |
| 144 | super.onDragExit(source, x, y, xOffset, yOffset, dragView, dragInfo); |
| 145 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 146 | } |
| 147 | |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 148 | public void onDragStart(DragSource source, Object info, int dragAction) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 149 | final ItemInfo item = (ItemInfo) info; |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 150 | if (item != null && mDragAndDropEnabled) { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 151 | mActive = true; |
Michael Jurka | 3adcb0c | 2010-10-15 18:07:21 -0700 | [diff] [blame] | 152 | getHitRect(mRegion); |
| 153 | mRegionF.set(mRegion); |
| 154 | |
| 155 | if (LauncherApplication.isScreenXLarge()) { |
| 156 | // This region will be a "dead zone" for scrolling; make it extend to the edge of |
| 157 | // the screen so users don't accidentally trigger a scroll while deleting items |
| 158 | mRegionF.top = mLauncher.getWorkspace().getTop(); |
| 159 | mRegionF.right = mLauncher.getWorkspace().getRight(); |
| 160 | } |
| 161 | |
| 162 | mDragController.setDeleteRegion(mRegionF); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 163 | |
| 164 | // Make sure the icon is set to the default drawable, not the hover drawable |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 165 | mTransition.resetTransition(); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 166 | |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 167 | createAnimations(); |
| 168 | startAnimation(mInAnimation); |
| 169 | if (mHandle != null) { |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 170 | mHandle.startAnimation(mHandleOutAnimation); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 171 | } |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 172 | setVisibility(VISIBLE); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
| 176 | public void onDragEnd() { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 177 | if (mActive && mDragAndDropEnabled) { |
| 178 | mActive = false; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 179 | mDragController.setDeleteRegion(null); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 180 | |
| 181 | if (mOutAnimation != null) startAnimation(mOutAnimation); |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 182 | if (mHandleInAnimation != null && mHandle != null) { |
| 183 | mHandle.startAnimation(mHandleInAnimation); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 184 | } |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 185 | setVisibility(GONE); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
| 189 | private void createAnimations() { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 190 | int duration = getAnimationDuration(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 191 | if (mHandleInAnimation == null) { |
Daniel Sandler | c9b1877 | 2010-04-22 14:37:59 -0400 | [diff] [blame] | 192 | mHandleInAnimation = new AlphaAnimation(0.0f, 1.0f); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 193 | mHandleInAnimation.setDuration(duration); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 194 | } |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 195 | |
| 196 | if (mInAnimation == null) { |
| 197 | mInAnimation = new FastAnimationSet(); |
| 198 | if (!LauncherApplication.isScreenXLarge()) { |
| 199 | final AnimationSet animationSet = mInAnimation; |
| 200 | animationSet.setInterpolator(new AccelerateInterpolator()); |
| 201 | animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f)); |
| 202 | if (mOrientation == ORIENTATION_HORIZONTAL) { |
| 203 | animationSet.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0.0f, |
| 204 | Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, |
| 205 | Animation.RELATIVE_TO_SELF, 0.0f)); |
| 206 | } else { |
| 207 | animationSet.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, |
| 208 | 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, 0.0f, |
| 209 | Animation.ABSOLUTE, 0.0f)); |
| 210 | } |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 211 | animationSet.setDuration(duration); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 212 | } else { |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 213 | mInAnimation.addAnimation(mHandleInAnimation); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 214 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 215 | } |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 216 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 217 | if (mHandleOutAnimation == null) { |
Daniel Sandler | c9b1877 | 2010-04-22 14:37:59 -0400 | [diff] [blame] | 218 | mHandleOutAnimation = new AlphaAnimation(1.0f, 0.0f); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 219 | mHandleOutAnimation.setFillAfter(true); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 220 | mHandleOutAnimation.setDuration(duration); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 221 | } |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 222 | |
| 223 | if (mOutAnimation == null) { |
| 224 | mOutAnimation = new FastAnimationSet(); |
| 225 | if (!LauncherApplication.isScreenXLarge()) { |
| 226 | final AnimationSet animationSet = mOutAnimation; |
| 227 | animationSet.setInterpolator(new AccelerateInterpolator()); |
| 228 | animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f)); |
| 229 | if (mOrientation == ORIENTATION_HORIZONTAL) { |
| 230 | animationSet.addAnimation(new FastTranslateAnimation(Animation.ABSOLUTE, 0.0f, |
| 231 | Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, |
| 232 | Animation.RELATIVE_TO_SELF, 1.0f)); |
| 233 | } else { |
| 234 | animationSet.addAnimation(new FastTranslateAnimation(Animation.RELATIVE_TO_SELF, |
| 235 | 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.ABSOLUTE, 0.0f, |
| 236 | Animation.ABSOLUTE, 0.0f)); |
| 237 | } |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 238 | animationSet.setDuration(duration); |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 239 | } else { |
| 240 | mOutAnimation.addAnimation(mHandleOutAnimation); |
| 241 | } |
| 242 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 243 | } |
| 244 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 245 | void setDragController(DragController dragController) { |
| 246 | mDragController = dragController; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 247 | } |
| 248 | |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 249 | private int getTransitionAnimationDuration() { |
| 250 | return LauncherApplication.isScreenXLarge() ? |
| 251 | XLARGE_TRANSITION_DURATION : TRANSITION_DURATION; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 254 | private int getAnimationDuration() { |
| 255 | return LauncherApplication.isScreenXLarge() ? |
| 256 | XLARGE_ANIMATION_DURATION : ANIMATION_DURATION; |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 257 | } |
| 258 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 259 | private static class FastTranslateAnimation extends TranslateAnimation { |
| 260 | public FastTranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, |
| 261 | int fromYType, float fromYValue, int toYType, float toYValue) { |
| 262 | super(fromXType, fromXValue, toXType, toXValue, |
| 263 | fromYType, fromYValue, toYType, toYValue); |
| 264 | } |
| 265 | |
| 266 | @Override |
| 267 | public boolean willChangeTransformationMatrix() { |
| 268 | return true; |
| 269 | } |
| 270 | |
| 271 | @Override |
| 272 | public boolean willChangeBounds() { |
| 273 | return false; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | private static class FastAnimationSet extends AnimationSet { |
| 278 | FastAnimationSet() { |
| 279 | super(false); |
| 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public boolean willChangeTransformationMatrix() { |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | @Override |
| 288 | public boolean willChangeBounds() { |
| 289 | return false; |
| 290 | } |
| 291 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 292 | } |