blob: 5df5e4dd901cbc31ee25cb4a720b887f7c0a6f66 [file] [log] [blame]
Winson Chung303e1ff2014-03-07 15:06:19 -08001/*
2 * Copyright (C) 2014 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
17package com.android.systemui.recents.views;
18
Winson Chung14926462014-04-14 18:57:14 -070019import android.animation.TimeInterpolator;
20import android.animation.ValueAnimator;
Winson Chung303e1ff2014-03-07 15:06:19 -080021import android.content.Context;
Winson Chung14926462014-04-14 18:57:14 -070022import android.graphics.Canvas;
Winson Chung96e3bc12014-05-06 16:44:12 -070023import android.graphics.Outline;
Winson Chung14926462014-04-14 18:57:14 -070024import android.graphics.Path;
Winson Chung9f9679d2014-04-11 16:49:09 -070025import android.graphics.Point;
Winson Chung303e1ff2014-03-07 15:06:19 -080026import android.graphics.Rect;
Winson Chung14926462014-04-14 18:57:14 -070027import android.graphics.RectF;
Winson Chung37c8d8e2014-03-24 14:53:07 -070028import android.util.AttributeSet;
Winson Chung9f9679d2014-04-11 16:49:09 -070029import android.view.MotionEvent;
Winson Chung303e1ff2014-03-07 15:06:19 -080030import android.view.View;
Winson Chung14926462014-04-14 18:57:14 -070031import android.view.animation.AccelerateInterpolator;
Winson Chung303e1ff2014-03-07 15:06:19 -080032import android.widget.FrameLayout;
Winson Chung37c8d8e2014-03-24 14:53:07 -070033import com.android.systemui.R;
Winson Chung14926462014-04-14 18:57:14 -070034import com.android.systemui.recents.Constants;
Winson Chung303e1ff2014-03-07 15:06:19 -080035import com.android.systemui.recents.RecentsConfiguration;
36import com.android.systemui.recents.model.Task;
Winson Chung303e1ff2014-03-07 15:06:19 -080037
Winson Chung303e1ff2014-03-07 15:06:19 -080038
Winson Chung37c8d8e2014-03-24 14:53:07 -070039/* A task view */
Winson Chung6cb485f2014-05-19 10:30:43 -070040public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.OnClickListener,
41 View.OnLongClickListener {
Winson Chung37c8d8e2014-03-24 14:53:07 -070042 /** The TaskView callbacks */
43 interface TaskViewCallbacks {
44 public void onTaskIconClicked(TaskView tv);
Winson Chung9f9679d2014-04-11 16:49:09 -070045 public void onTaskAppInfoClicked(TaskView tv);
Winson Chung47a3e652014-05-21 16:03:42 -070046 public void onTaskFocused(TaskView tv);
Winson Chung54e297a2014-05-09 17:15:32 -070047 public void onTaskDismissed(TaskView tv);
Winson Chung9f9679d2014-04-11 16:49:09 -070048
Winson Chung37c8d8e2014-03-24 14:53:07 -070049 // public void onTaskViewReboundToTask(TaskView tv, Task t);
50 }
51
Winson Chung14926462014-04-14 18:57:14 -070052 int mDim;
53 int mMaxDim;
54 TimeInterpolator mDimInterpolator = new AccelerateInterpolator();
55
Winson Chung303e1ff2014-03-07 15:06:19 -080056 Task mTask;
Winson Chung37c8d8e2014-03-24 14:53:07 -070057 boolean mTaskDataLoaded;
Winson Chung1e8d71b2014-05-16 17:05:22 -070058 boolean mIsFocused;
Winson Chung5a9b0b02014-05-20 17:32:03 -070059 boolean mClipViewInStack;
Winson Chung9f9679d2014-04-11 16:49:09 -070060 Point mLastTouchDown = new Point();
Winson Chung14926462014-04-14 18:57:14 -070061 Path mRoundedRectClipPath = new Path();
Winson Chung37c8d8e2014-03-24 14:53:07 -070062
63 TaskThumbnailView mThumbnailView;
64 TaskBarView mBarView;
65 TaskViewCallbacks mCb;
Winson Chung303e1ff2014-03-07 15:06:19 -080066
Winson Chung37c8d8e2014-03-24 14:53:07 -070067
68 public TaskView(Context context) {
69 this(context, null);
Winson Chung303e1ff2014-03-07 15:06:19 -080070 }
71
Winson Chung37c8d8e2014-03-24 14:53:07 -070072 public TaskView(Context context, AttributeSet attrs) {
73 this(context, attrs, 0);
74 }
Winson Chung303e1ff2014-03-07 15:06:19 -080075
Winson Chung37c8d8e2014-03-24 14:53:07 -070076 public TaskView(Context context, AttributeSet attrs, int defStyleAttr) {
77 this(context, attrs, defStyleAttr, 0);
78 }
79
80 public TaskView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
81 super(context, attrs, defStyleAttr, defStyleRes);
Winson Chung14926462014-04-14 18:57:14 -070082 setWillNotDraw(false);
Winson Chung37c8d8e2014-03-24 14:53:07 -070083 }
84
85 @Override
86 protected void onFinishInflate() {
Winson Chung14926462014-04-14 18:57:14 -070087 RecentsConfiguration config = RecentsConfiguration.getInstance();
88 mMaxDim = config.taskStackMaxDim;
89
Winson Chung5a9b0b02014-05-20 17:32:03 -070090 // By default, all views are clipped to other views in their stack
91 mClipViewInStack = true;
92
Winson Chung37c8d8e2014-03-24 14:53:07 -070093 // Bind the views
94 mThumbnailView = (TaskThumbnailView) findViewById(R.id.task_view_thumbnail);
95 mBarView = (TaskBarView) findViewById(R.id.task_view_bar);
Winson Chung9f9679d2014-04-11 16:49:09 -070096
Winson Chung37c8d8e2014-03-24 14:53:07 -070097 if (mTaskDataLoaded) {
98 onTaskDataLoaded(false);
Winson Chung303e1ff2014-03-07 15:06:19 -080099 }
100 }
101
Winson Chung9f9679d2014-04-11 16:49:09 -0700102 @Override
Winson Chung14926462014-04-14 18:57:14 -0700103 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
104 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
105
106 // Update the rounded rect clip path
107 RecentsConfiguration config = RecentsConfiguration.getInstance();
108 float radius = config.taskViewRoundedCornerRadiusPx;
109 mRoundedRectClipPath.reset();
110 mRoundedRectClipPath.addRoundRect(new RectF(0, 0, getMeasuredWidth(), getMeasuredHeight()),
111 radius, radius, Path.Direction.CW);
Winson Chung96e3bc12014-05-06 16:44:12 -0700112
113 // Update the outline
114 Outline o = new Outline();
Winson Chung602de032014-05-27 12:19:28 -0700115 o.setRoundRect(0, 0, getMeasuredWidth(), getMeasuredHeight() -
116 config.taskViewShadowOutlineBottomInsetPx, radius);
Winson Chung96e3bc12014-05-06 16:44:12 -0700117 setOutline(o);
Winson Chung14926462014-04-14 18:57:14 -0700118 }
119
120 @Override
Winson Chung9f9679d2014-04-11 16:49:09 -0700121 public boolean onInterceptTouchEvent(MotionEvent ev) {
122 switch (ev.getAction()) {
123 case MotionEvent.ACTION_DOWN:
124 case MotionEvent.ACTION_MOVE:
125 mLastTouchDown.set((int) ev.getX(), (int) ev.getY());
126 break;
127 }
128 return super.onInterceptTouchEvent(ev);
129 }
130
Winson Chung04dfe0d2014-03-14 14:06:29 -0700131 /** Set callback */
132 void setCallbacks(TaskViewCallbacks cb) {
Winson Chung303e1ff2014-03-07 15:06:19 -0800133 mCb = cb;
134 }
135
Winson Chung303e1ff2014-03-07 15:06:19 -0800136 /** Gets the task */
137 Task getTask() {
138 return mTask;
139 }
140
141 /** Synchronizes this view's properties with the task's transform */
Winson Chungc6a16232014-04-01 14:04:48 -0700142 void updateViewPropertiesToTaskTransform(TaskViewTransform animateFromTransform,
143 TaskViewTransform toTransform, int duration) {
Winson Chung96e3bc12014-05-06 16:44:12 -0700144 RecentsConfiguration config = RecentsConfiguration.getInstance();
Winson Chung96e3bc12014-05-06 16:44:12 -0700145
Winson Chung54e297a2014-05-09 17:15:32 -0700146 // Update the bar view
147 mBarView.updateViewPropertiesToTaskTransform(animateFromTransform, toTransform, duration);
148
149 // Update this task view
Winson Chung303e1ff2014-03-07 15:06:19 -0800150 if (duration > 0) {
151 if (animateFromTransform != null) {
152 setTranslationY(animateFromTransform.translationY);
Winson Chung814086d2014-05-07 15:01:14 -0700153 if (Constants.DebugFlags.App.EnableShadows) {
Winson Chungb13c46e2014-06-09 18:33:08 -0700154 setTranslationZ(animateFromTransform.translationZ);
Winson Chung814086d2014-05-07 15:01:14 -0700155 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800156 setScaleX(animateFromTransform.scale);
157 setScaleY(animateFromTransform.scale);
Winson Chungc6a16232014-04-01 14:04:48 -0700158 setAlpha(animateFromTransform.alpha);
Winson Chung303e1ff2014-03-07 15:06:19 -0800159 }
Winson Chung814086d2014-05-07 15:01:14 -0700160 if (Constants.DebugFlags.App.EnableShadows) {
Winson Chungb13c46e2014-06-09 18:33:08 -0700161 animate().translationZ(toTransform.translationZ);
Winson Chung814086d2014-05-07 15:01:14 -0700162 }
Winson Chungc6a16232014-04-01 14:04:48 -0700163 animate().translationY(toTransform.translationY)
164 .scaleX(toTransform.scale)
165 .scaleY(toTransform.scale)
166 .alpha(toTransform.alpha)
Winson Chung303e1ff2014-03-07 15:06:19 -0800167 .setDuration(duration)
Winson Chungb01ed682014-05-29 14:25:42 -0700168 .setInterpolator(config.fastOutSlowInInterpolator)
Winson Chungc6a16232014-04-01 14:04:48 -0700169 .withLayer()
Winson Chung14926462014-04-14 18:57:14 -0700170 .setUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
171 @Override
172 public void onAnimationUpdate(ValueAnimator animation) {
173 updateDimOverlayFromScale();
174 }
175 })
Winson Chung303e1ff2014-03-07 15:06:19 -0800176 .start();
177 } else {
Winson Chungc6a16232014-04-01 14:04:48 -0700178 setTranslationY(toTransform.translationY);
Winson Chung814086d2014-05-07 15:01:14 -0700179 if (Constants.DebugFlags.App.EnableShadows) {
Winson Chungb13c46e2014-06-09 18:33:08 -0700180 setTranslationZ(toTransform.translationZ);
Winson Chung814086d2014-05-07 15:01:14 -0700181 }
Winson Chungc6a16232014-04-01 14:04:48 -0700182 setScaleX(toTransform.scale);
183 setScaleY(toTransform.scale);
184 setAlpha(toTransform.alpha);
Winson Chung303e1ff2014-03-07 15:06:19 -0800185 }
Winson Chung14926462014-04-14 18:57:14 -0700186 updateDimOverlayFromScale();
187 invalidate();
Winson Chung303e1ff2014-03-07 15:06:19 -0800188 }
189
190 /** Resets this view's properties */
191 void resetViewProperties() {
192 setTranslationX(0f);
193 setTranslationY(0f);
Winson Chung814086d2014-05-07 15:01:14 -0700194 if (Constants.DebugFlags.App.EnableShadows) {
195 setTranslationZ(0f);
196 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800197 setScaleX(1f);
198 setScaleY(1f);
199 setAlpha(1f);
Winson Chung14926462014-04-14 18:57:14 -0700200 invalidate();
Winson Chung303e1ff2014-03-07 15:06:19 -0800201 }
202
Winson Chung11ca76a52014-04-10 17:29:13 -0700203 /**
204 * When we are un/filtering, this method will set up the transform that we are animating to,
205 * in order to hide the task.
206 */
Winson Chungc6a16232014-04-01 14:04:48 -0700207 void prepareTaskTransformForFilterTaskHidden(TaskViewTransform toTransform) {
208 // Fade the view out and slide it away
209 toTransform.alpha = 0f;
210 toTransform.translationY += 200;
211 }
212
Winson Chung11ca76a52014-04-10 17:29:13 -0700213 /**
214 * When we are un/filtering, this method will setup the transform that we are animating from,
215 * in order to show the task.
216 */
Winson Chungc6a16232014-04-01 14:04:48 -0700217 void prepareTaskTransformForFilterTaskVisible(TaskViewTransform fromTransform) {
218 // Fade the view in
219 fromTransform.alpha = 0f;
220 }
221
Winson Chung24cf1522014-05-29 12:03:33 -0700222 /** Prepares this task view for the enter-recents animations. This is called earlier in the
223 * first layout because the actual animation into recents may take a long time. */
224 public void prepareAnimateOnEnterRecents() {
225 mBarView.setVisibility(View.INVISIBLE);
226 }
227
Winson Chung303e1ff2014-03-07 15:06:19 -0800228 /** Animates this task view as it enters recents */
229 public void animateOnEnterRecents() {
Winson Chung37c8d8e2014-03-24 14:53:07 -0700230 RecentsConfiguration config = RecentsConfiguration.getInstance();
Winson Chung24cf1522014-05-29 12:03:33 -0700231 mBarView.setVisibility(View.VISIBLE);
232 mBarView.setTranslationY(-mBarView.getMeasuredHeight());
Winson Chung37c8d8e2014-03-24 14:53:07 -0700233 mBarView.animate()
Winson Chung24cf1522014-05-29 12:03:33 -0700234 .translationY(0)
Winson Chung521e7dc2014-06-02 15:31:56 -0700235 .setStartDelay(config.taskBarEnterAnimDelay)
Winson Chungb01ed682014-05-29 14:25:42 -0700236 .setInterpolator(config.fastOutSlowInInterpolator)
Winson Chung0d767552014-04-09 14:33:23 -0700237 .setDuration(config.taskBarEnterAnimDuration)
Winson Chung37c8d8e2014-03-24 14:53:07 -0700238 .withLayer()
239 .start();
Winson Chung303e1ff2014-03-07 15:06:19 -0800240 }
241
242 /** Animates this task view as it exits recents */
243 public void animateOnLeavingRecents(final Runnable r) {
Winson Chung37c8d8e2014-03-24 14:53:07 -0700244 RecentsConfiguration config = RecentsConfiguration.getInstance();
Winson Chung37c8d8e2014-03-24 14:53:07 -0700245 mBarView.animate()
Winson Chung24cf1522014-05-29 12:03:33 -0700246 .translationY(-mBarView.getMeasuredHeight())
Winson Chung37c8d8e2014-03-24 14:53:07 -0700247 .setStartDelay(0)
Winson Chungb01ed682014-05-29 14:25:42 -0700248 .setInterpolator(config.fastOutLinearInInterpolator)
Winson Chungf5e22e72014-05-02 18:35:35 -0700249 .setDuration(config.taskBarExitAnimDuration)
Winson Chung37c8d8e2014-03-24 14:53:07 -0700250 .withLayer()
Winson Chung0d767552014-04-09 14:33:23 -0700251 .withEndAction(new Runnable() {
252 @Override
253 public void run() {
254 post(r);
255 }
256 })
Winson Chung37c8d8e2014-03-24 14:53:07 -0700257 .start();
Winson Chung303e1ff2014-03-07 15:06:19 -0800258 }
259
Winson Chung9f49df92014-05-07 18:08:34 -0700260 /** Animates the deletion of this task view */
261 public void animateRemoval(final Runnable r) {
Winson Chung5a9b0b02014-05-20 17:32:03 -0700262 // Disabling clipping with the stack while the view is animating away
263 setClipViewInStack(false);
264
Winson Chung9f49df92014-05-07 18:08:34 -0700265 RecentsConfiguration config = RecentsConfiguration.getInstance();
266 animate().translationX(config.taskViewRemoveAnimTranslationXPx)
267 .alpha(0f)
268 .setStartDelay(0)
Winson Chungb01ed682014-05-29 14:25:42 -0700269 .setInterpolator(config.fastOutSlowInInterpolator)
Winson Chung9f49df92014-05-07 18:08:34 -0700270 .setDuration(config.taskViewRemoveAnimDuration)
271 .withLayer()
272 .withEndAction(new Runnable() {
273 @Override
274 public void run() {
275 post(r);
Winson Chung5a9b0b02014-05-20 17:32:03 -0700276
277 // Re-enable clipping with the stack (we will reuse this view)
278 setClipViewInStack(false);
Winson Chung9f49df92014-05-07 18:08:34 -0700279 }
280 })
281 .start();
282 }
283
Winson Chung303e1ff2014-03-07 15:06:19 -0800284 /** Returns the rect we want to clip (it may not be the full rect) */
Winson Chung0d767552014-04-09 14:33:23 -0700285 Rect getClippingRect(Rect outRect) {
Winson Chung303e1ff2014-03-07 15:06:19 -0800286 getHitRect(outRect);
287 // XXX: We should get the hit rect of the thumbnail view and intersect, but this is faster
288 outRect.right = outRect.left + mThumbnailView.getRight();
289 outRect.bottom = outRect.top + mThumbnailView.getBottom();
Winson Chung303e1ff2014-03-07 15:06:19 -0800290 return outRect;
291 }
292
293 /** Enable the hw layers on this task view */
294 void enableHwLayers() {
Winson Chung303e1ff2014-03-07 15:06:19 -0800295 mThumbnailView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
296 }
297
298 /** Disable the hw layers on this task view */
299 void disableHwLayers() {
Winson Chung303e1ff2014-03-07 15:06:19 -0800300 mThumbnailView.setLayerType(View.LAYER_TYPE_NONE, null);
301 }
302
Winson Chung5a9b0b02014-05-20 17:32:03 -0700303 /**
304 * Returns whether this view should be clipped, or any views below should clip against this
305 * view.
306 */
307 boolean shouldClipViewInStack() {
308 return mClipViewInStack;
309 }
310
311 /** Sets whether this view should be clipped, or clipped against. */
312 void setClipViewInStack(boolean clip) {
313 if (clip != mClipViewInStack) {
314 mClipViewInStack = clip;
315 if (getParent() instanceof View) {
316 Rect r = new Rect();
317 getHitRect(r);
318 ((View) getParent()).invalidate(r);
319 }
320 }
321 }
322
Winson Chung14926462014-04-14 18:57:14 -0700323 /** Update the dim as a function of the scale of this view. */
324 void updateDimOverlayFromScale() {
325 float minScale = Constants.Values.TaskStackView.StackPeekMinScale;
326 float scaleRange = 1f - minScale;
327 float dim = (1f - getScaleX()) / scaleRange;
328 dim = mDimInterpolator.getInterpolation(Math.min(dim, 1f));
329 mDim = Math.max(0, Math.min(mMaxDim, (int) (dim * 255)));
Winson Chung14926462014-04-14 18:57:14 -0700330 }
331
332 @Override
333 public void draw(Canvas canvas) {
334 // Apply the rounded rect clip path on the whole view
335 canvas.clipPath(mRoundedRectClipPath);
336
337 super.draw(canvas);
338
339 // Apply the dim if necessary
340 if (mDim > 0) {
341 canvas.drawColor(mDim << 24);
342 }
343 }
344
Winson Chung1e8d71b2014-05-16 17:05:22 -0700345 /**
346 * Sets the focused task explicitly. We need a separate flag because requestFocus() won't happen
347 * if the view is not currently visible, or we are in touch state (where we still want to keep
348 * track of focus).
349 */
350 public void setFocusedTask() {
351 mIsFocused = true;
352 requestFocus();
Winson Chung47a3e652014-05-21 16:03:42 -0700353 invalidate();
354 mCb.onTaskFocused(this);
Winson Chung1e8d71b2014-05-16 17:05:22 -0700355 }
356
357 /**
358 * Updates the explicitly focused state when the view focus changes.
359 */
360 @Override
361 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
362 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
363 if (!gainFocus) {
364 mIsFocused = false;
Winson Chung47a3e652014-05-21 16:03:42 -0700365 invalidate();
Winson Chung1e8d71b2014-05-16 17:05:22 -0700366 }
367 }
368
369 /**
370 * Returns whether we have explicitly been focused.
371 */
372 public boolean isFocusedTask() {
373 return mIsFocused || isFocused();
374 }
375
Winson Chung4d7b0922014-03-13 17:14:17 -0700376 /**** TaskCallbacks Implementation ****/
377
Winson Chung04dfe0d2014-03-14 14:06:29 -0700378 /** Binds this task view to the task */
379 public void onTaskBound(Task t) {
380 mTask = t;
381 mTask.setCallbacks(this);
Winson Chung303e1ff2014-03-07 15:06:19 -0800382 }
383
384 @Override
Winson Chung4c71aef2014-03-21 15:15:11 -0700385 public void onTaskDataLoaded(boolean reloadingTaskData) {
Winson Chung863db8a2014-05-20 14:27:39 -0700386 if (mThumbnailView != null && mBarView != null) {
Winson Chung37c8d8e2014-03-24 14:53:07 -0700387 // Bind each of the views to the new task data
388 mThumbnailView.rebindToTask(mTask, reloadingTaskData);
389 mBarView.rebindToTask(mTask, reloadingTaskData);
Winson Chung9f9679d2014-04-11 16:49:09 -0700390 // Rebind any listeners
391 mBarView.mApplicationIcon.setOnClickListener(this);
Winson Chung54e297a2014-05-09 17:15:32 -0700392 mBarView.mDismissButton.setOnClickListener(this);
Winson Chung6cb485f2014-05-19 10:30:43 -0700393 if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
Winson Chung47a3e652014-05-21 16:03:42 -0700394 RecentsConfiguration config = RecentsConfiguration.getInstance();
395 if (config.developerOptionsEnabled) {
Winson Chung6cb485f2014-05-19 10:30:43 -0700396 mBarView.mApplicationIcon.setOnLongClickListener(this);
397 }
398 }
Winson Chung37c8d8e2014-03-24 14:53:07 -0700399 }
400 mTaskDataLoaded = true;
Winson Chung4d7b0922014-03-13 17:14:17 -0700401 }
402
403 @Override
Winson Chung04dfe0d2014-03-14 14:06:29 -0700404 public void onTaskDataUnloaded() {
Winson Chung863db8a2014-05-20 14:27:39 -0700405 if (mThumbnailView != null && mBarView != null) {
Winson Chung37c8d8e2014-03-24 14:53:07 -0700406 // Unbind each of the views from the task data and remove the task callback
407 mTask.setCallbacks(null);
408 mThumbnailView.unbindFromTask();
409 mBarView.unbindFromTask();
Winson Chung9f9679d2014-04-11 16:49:09 -0700410 // Unbind any listeners
411 mBarView.mApplicationIcon.setOnClickListener(null);
Winson Chung6cb485f2014-05-19 10:30:43 -0700412 mBarView.mDismissButton.setOnClickListener(null);
413 if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
414 mBarView.mApplicationIcon.setOnLongClickListener(null);
415 }
Winson Chung37c8d8e2014-03-24 14:53:07 -0700416 }
417 mTaskDataLoaded = false;
Winson Chung4d7b0922014-03-13 17:14:17 -0700418 }
419
420 @Override
Winson Chung303e1ff2014-03-07 15:06:19 -0800421 public void onClick(View v) {
Winson Chung863db8a2014-05-20 14:27:39 -0700422 if (v == mBarView.mApplicationIcon) {
Winson Chung9f9679d2014-04-11 16:49:09 -0700423 mCb.onTaskIconClicked(this);
Winson Chung54e297a2014-05-09 17:15:32 -0700424 } else if (v == mBarView.mDismissButton) {
425 // Animate out the view and call the callback
426 final TaskView tv = this;
427 animateRemoval(new Runnable() {
428 @Override
429 public void run() {
430 mCb.onTaskDismissed(tv);
431 }
432 });
Winson Chung9f9679d2014-04-11 16:49:09 -0700433 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800434 }
Winson Chung6cb485f2014-05-19 10:30:43 -0700435
436 @Override
437 public boolean onLongClick(View v) {
438 if (v == mBarView.mApplicationIcon) {
439 mCb.onTaskAppInfoClicked(this);
440 return true;
441 }
442 return false;
443 }
Winson Chung7bb18852014-05-20 23:25:41 +0000444}