blob: b7a22fc9b9b3a7f2b6f92e9751c09b5a7895022a [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 Goyale396abf2020-04-06 15:11:17 -070024import com.android.launcher3.model.data.ItemInfo;
25
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 */
Hyunyoung Song3f471442015-04-08 19:01:34 -070032public class PendingAddItemInfo extends ItemInfo {
33
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
39 @Override
40 protected String dumpProperties() {
41 return super.dumpProperties() + " componentName=" + componentName;
42 }
thiruram6bf68482020-05-06 22:19:43 -070043
44 /**
45 * Returns shallow copy of the object.
46 */
Pinyao Ting96d3c582022-09-07 15:40:41 -070047 @NonNull
thiruram6bf68482020-05-06 22:19:43 -070048 @Override
49 public ItemInfo makeShallowCopy() {
50 PendingAddItemInfo itemInfo = new PendingAddItemInfo();
51 itemInfo.copyFrom(this);
52 itemInfo.componentName = this.componentName;
53 return itemInfo;
54 }
55
56 @Nullable
57 @Override
58 public ComponentName getTargetComponent() {
59 return Optional.ofNullable(super.getTargetComponent()).orElse(componentName);
60 }
61
Adam Cohen1b36dc32012-02-13 19:27:37 -080062}