Debian Codegraph @

libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewFactoryController.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 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.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 /** Factory controller which can create {@link TaskView} */
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 /** Creates an {@link TaskView} */
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 }