blob: 9b03c5d76d18017e8eb2955023df9903227efb6b [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.model;
18
19import android.content.Intent;
20import android.graphics.Bitmap;
21import android.graphics.drawable.Drawable;
22import com.android.systemui.recents.Constants;
23
24
25/**
26 * A task represents the top most task in the system's task stack.
27 */
28public class Task {
29 public final int id;
30 public final Intent intent;
31 public String title;
32 public Drawable icon;
33 public Bitmap thumbnail;
34
35 TaskCallbacks mCb;
36
37 public Task(int id, Intent intent, String activityTitle, Drawable icon, Bitmap thumbnail) {
38 this.id = id;
39 this.intent = intent;
40 this.title = activityTitle;
41 this.icon = icon;
42 this.thumbnail = thumbnail;
43 }
44
45 /** Set the callbacks */
46 public void setCallbacks(TaskCallbacks cb) {
47 mCb = cb;
48 }
49
50 /** Notifies the callback listeners that this task's data has changed */
51 public void notifyTaskDataChanged() {
52 if (mCb != null) {
53 mCb.onTaskDataChanged(this);
54 }
55 }
56
57 @Override
58 public boolean equals(Object o) {
59 // If we have multiple task entries for the same task, then we do the simple object
60 // equality check
61 if (Constants.Values.RecentsTaskLoader.TaskEntryMultiplier > 1) {
62 return super.equals(o);
63 }
64
65 // Otherwise, check that the id and intent match (the other fields can be asynchronously
66 // loaded and is unsuitable to testing the identity of this Task)
67 Task t = (Task) o;
68 return (id == t.id) &&
69 (intent.equals(t.intent));
70 }
71
72 @Override
73 public String toString() {
74 return "Task: " + intent.getComponent().getPackageName() + " [" + super.toString() + "]";
75 }
76}