The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Joe Onorato | a590252 | 2009-07-30 13:37:37 -0700 | [diff] [blame^] | 17 | package com.android.launcher2; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
Jeff Sharkey | 7086428 | 2009-04-07 21:08:40 -0700 | [diff] [blame] | 19 | import android.graphics.Rect; |
| 20 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 21 | /** |
| 22 | * Interface defining an object that can receive a drag. |
| 23 | * |
| 24 | */ |
| 25 | public interface DropTarget { |
| 26 | |
| 27 | /** |
| 28 | * Handle an object being dropped on the DropTarget |
| 29 | * |
| 30 | * @param source DragSource where the drag started |
| 31 | * @param x X coordinate of the drop location |
| 32 | * @param y Y coordinate of the drop location |
| 33 | * @param xOffset Horizontal offset with the object being dragged where the original touch happened |
| 34 | * @param yOffset Vertical offset with the object being dragged where the original touch happened |
| 35 | * @param dragInfo Data associated with the object being dragged |
| 36 | * |
| 37 | */ |
| 38 | void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, Object dragInfo); |
| 39 | |
| 40 | void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, Object dragInfo); |
| 41 | |
| 42 | void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset, Object dragInfo); |
| 43 | |
| 44 | void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset, Object dragInfo); |
| 45 | |
| 46 | /** |
Jeff Sharkey | 7086428 | 2009-04-07 21:08:40 -0700 | [diff] [blame] | 47 | * Check if a drop action can occur at, or near, the requested location. |
| 48 | * This may be called repeatedly during a drag, so any calls should return |
| 49 | * quickly. |
| 50 | * |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 51 | * @param source DragSource where the drag started |
| 52 | * @param x X coordinate of the drop location |
| 53 | * @param y Y coordinate of the drop location |
Jeff Sharkey | 7086428 | 2009-04-07 21:08:40 -0700 | [diff] [blame] | 54 | * @param xOffset Horizontal offset with the object being dragged where the |
| 55 | * original touch happened |
| 56 | * @param yOffset Vertical offset with the object being dragged where the |
| 57 | * original touch happened |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 58 | * @param dragInfo Data associated with the object being dragged |
Jeff Sharkey | 7086428 | 2009-04-07 21:08:40 -0700 | [diff] [blame] | 59 | * @return True if the drop will be accepted, false otherwise. |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 60 | */ |
| 61 | boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset, Object dragInfo); |
Jeff Sharkey | 7086428 | 2009-04-07 21:08:40 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * Estimate the surface area where this object would land if dropped at the |
| 65 | * given location. |
| 66 | * |
| 67 | * @param source DragSource where the drag started |
| 68 | * @param x X coordinate of the drop location |
| 69 | * @param y Y coordinate of the drop location |
| 70 | * @param xOffset Horizontal offset with the object being dragged where the |
| 71 | * original touch happened |
| 72 | * @param yOffset Vertical offset with the object being dragged where the |
| 73 | * original touch happened |
| 74 | * @param dragInfo Data associated with the object being dragged |
| 75 | * @param recycle {@link Rect} object to be possibly recycled. |
| 76 | * @return Estimated area that would be occupied if object was dropped at |
| 77 | * the given location. Should return null if no estimate is found, |
| 78 | * or if this target doesn't provide estimations. |
| 79 | */ |
| 80 | Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset, Object dragInfo, Rect recycle); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 81 | } |