blob: 000ddd8f7978e1d130d95a4dbfd86d2905b2395c [file] [log] [blame]
Michael Jurka0280c3b2010-09-17 15:00:07 -07001/*
2 * Copyright (C) 2010 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
Daniel Sandler325dc232013-06-05 22:57:57 -040017package com.android.launcher3;
Michael Jurka0280c3b2010-09-17 15:00:07 -070018
19import android.content.ComponentName;
20
Pinyao Ting96d3c582022-09-07 15:40:41 -070021import androidx.annotation.NonNull;
thiruram6bf68482020-05-06 22:19:43 -070022import androidx.annotation.Nullable;
23
Sunny Goyal239d6e92023-02-07 13:40:11 -080024import com.android.launcher3.model.data.ItemInfoWithIcon;
Sunny Goyale396abf2020-04-06 15:11:17 -070025
thiruram6bf68482020-05-06 22:19:43 -070026import java.util.Optional;
27
Michael Jurka0280c3b2010-09-17 15:00:07 -070028/**
thiruram6bf68482020-05-06 22:19:43 -070029 * Meta data that is used for deferred binding. e.g., this object is used to pass information on
30 * draggable targets when they are dropped onto the workspace from another container.
Michael Jurka0280c3b2010-09-17 15:00:07 -070031 */
Sunny Goyal239d6e92023-02-07 13:40:11 -080032public class PendingAddItemInfo extends ItemInfoWithIcon {
Hyunyoung Song3f471442015-04-08 19:01:34 -070033
Michael Jurka0280c3b2010-09-17 15:00:07 -070034 /**
35 * The component that will be created.
36 */
Hyunyoung Song3f471442015-04-08 19:01:34 -070037 public ComponentName componentName;
Sunny Goyal1edab712016-09-01 10:55:20 -070038
Sunny Goyal239d6e92023-02-07 13:40:11 -080039 public PendingAddItemInfo() { }
40
41 public PendingAddItemInfo(PendingAddItemInfo info) {
42 super(info);
43 componentName = info.componentName;
44 }
45
Sunny Goyal1edab712016-09-01 10:55:20 -070046 @Override
47 protected String dumpProperties() {
48 return super.dumpProperties() + " componentName=" + componentName;
49 }
thiruram6bf68482020-05-06 22:19:43 -070050
51 /**
52 * Returns shallow copy of the object.
53 */
Pinyao Ting96d3c582022-09-07 15:40:41 -070054 @NonNull
thiruram6bf68482020-05-06 22:19:43 -070055 @Override
Sunny Goyal239d6e92023-02-07 13:40:11 -080056 public PendingAddItemInfo makeShallowCopy() {
thiruram6bf68482020-05-06 22:19:43 -070057 PendingAddItemInfo itemInfo = new PendingAddItemInfo();
58 itemInfo.copyFrom(this);
59 itemInfo.componentName = this.componentName;
60 return itemInfo;
61 }
62
Sunny Goyal239d6e92023-02-07 13:40:11 -080063 @Override
64 public PendingAddItemInfo clone() {
65 return makeShallowCopy();
66 }
67
thiruram6bf68482020-05-06 22:19:43 -070068 @Nullable
69 @Override
70 public ComponentName getTargetComponent() {
71 return Optional.ofNullable(super.getTargetComponent()).orElse(componentName);
72 }
73
Adam Cohen1b36dc32012-02-13 19:27:37 -080074}