Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 1 | /* |
| 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 Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 18 | |
| 19 | import android.content.ComponentName; |
| 20 | |
Pinyao Ting | 96d3c58 | 2022-09-07 15:40:41 -0700 | [diff] [blame] | 21 | import androidx.annotation.NonNull; |
thiruram | 6bf6848 | 2020-05-06 22:19:43 -0700 | [diff] [blame] | 22 | import androidx.annotation.Nullable; |
| 23 | |
Sunny Goyal | e396abf | 2020-04-06 15:11:17 -0700 | [diff] [blame] | 24 | import com.android.launcher3.model.data.ItemInfo; |
| 25 | |
thiruram | 6bf6848 | 2020-05-06 22:19:43 -0700 | [diff] [blame] | 26 | import java.util.Optional; |
| 27 | |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 28 | /** |
thiruram | 6bf6848 | 2020-05-06 22:19:43 -0700 | [diff] [blame] | 29 | * 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 Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 31 | */ |
Hyunyoung Song | 3f47144 | 2015-04-08 19:01:34 -0700 | [diff] [blame] | 32 | public class PendingAddItemInfo extends ItemInfo { |
| 33 | |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 34 | /** |
| 35 | * The component that will be created. |
| 36 | */ |
Hyunyoung Song | 3f47144 | 2015-04-08 19:01:34 -0700 | [diff] [blame] | 37 | public ComponentName componentName; |
Sunny Goyal | 1edab71 | 2016-09-01 10:55:20 -0700 | [diff] [blame] | 38 | |
| 39 | @Override |
| 40 | protected String dumpProperties() { |
| 41 | return super.dumpProperties() + " componentName=" + componentName; |
| 42 | } |
thiruram | 6bf6848 | 2020-05-06 22:19:43 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Returns shallow copy of the object. |
| 46 | */ |
Pinyao Ting | 96d3c58 | 2022-09-07 15:40:41 -0700 | [diff] [blame] | 47 | @NonNull |
thiruram | 6bf6848 | 2020-05-06 22:19:43 -0700 | [diff] [blame] | 48 | @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 Cohen | 1b36dc3 | 2012-02-13 19:27:37 -0800 | [diff] [blame] | 62 | } |