| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.wm.shell; |
| 18 |
|
| 19 |
import android.annotation.UiContext; |
| 20 |
import android.content.Context; |
| 21 |
|
| 22 |
import com.android.wm.shell.common.ShellExecutor; |
| 23 |
import com.android.wm.shell.common.SyncTransactionQueue; |
| 24 |
import com.android.wm.shell.common.annotations.ExternalThread; |
| 25 |
|
| 26 |
import java.util.concurrent.Executor; |
| 27 |
import java.util.function.Consumer; |
| 28 |
|
| 29 |
|
| 30 |
public class TaskViewFactoryController { |
| 31 |
private final ShellTaskOrganizer mTaskOrganizer; |
| 32 |
private final ShellExecutor mShellExecutor; |
| 33 |
private final SyncTransactionQueue mSyncQueue; |
| 34 |
private final TaskViewTransitions mTaskViewTransitions; |
| 35 |
private final TaskViewFactory mImpl = new TaskViewFactoryImpl(); |
| 36 |
|
| 37 |
public TaskViewFactoryController(ShellTaskOrganizer taskOrganizer, |
| 38 |
ShellExecutor shellExecutor, SyncTransactionQueue syncQueue, |
| 39 |
TaskViewTransitions taskViewTransitions) { |
| 40 |
mTaskOrganizer = taskOrganizer; |
| 41 |
mShellExecutor = shellExecutor; |
| 42 |
mSyncQueue = syncQueue; |
| 43 |
mTaskViewTransitions = taskViewTransitions; |
| 44 |
} |
| 45 |
|
| 46 |
public TaskViewFactoryController(ShellTaskOrganizer taskOrganizer, |
| 47 |
ShellExecutor shellExecutor, SyncTransactionQueue syncQueue) { |
| 48 |
mTaskOrganizer = taskOrganizer; |
| 49 |
mShellExecutor = shellExecutor; |
| 50 |
mSyncQueue = syncQueue; |
| 51 |
mTaskViewTransitions = null; |
| 52 |
} |
| 53 |
|
| 54 |
public TaskViewFactory asTaskViewFactory() { |
| 55 |
return mImpl; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
public void create(@UiContext Context context, Executor executor, Consumer<TaskView> onCreate) { |
| 60 |
TaskView taskView = new TaskView(context, mTaskOrganizer, mTaskViewTransitions, mSyncQueue); |
| 61 |
executor.execute(() -> { |
| 62 |
onCreate.accept(taskView); |
| 63 |
}); |
| 64 |
} |
| 65 |
|
| 66 |
private class TaskViewFactoryImpl implements TaskViewFactory { |
| 67 |
@ExternalThread |
| 68 |
public void create(@UiContext Context context, |
| 69 |
Executor executor, Consumer<TaskView> onCreate) { |
| 70 |
mShellExecutor.execute(() -> { |
| 71 |
TaskViewFactoryController.this.create(context, executor, onCreate); |
| 72 |
}); |
| 73 |
} |
| 74 |
} |
| 75 |
} |