DragLayer.java revision 8a73c51ee87b6d9b12daba188034889caf7a905b
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 17package com.android.launcher2; 18 19import android.content.Context; 20import android.util.AttributeSet; 21import android.view.MotionEvent; 22import android.view.KeyEvent; 23import android.widget.FrameLayout; 24 25/** 26 * A ViewGroup that coordinated dragging across its dscendants 27 */ 28public class DragLayer extends FrameLayout { 29 DragController mDragController; 30 31 /** 32 * Used to create a new DragLayer from XML. 33 * 34 * @param context The application's context. 35 * @param attrs The attribtues set containing the Workspace's customization values. 36 */ 37 public DragLayer(Context context, AttributeSet attrs) { 38 super(context, attrs); 39 } 40 41 public void setDragController(DragController controller) { 42 mDragController = controller; 43 } 44 45 @Override 46 public boolean dispatchKeyEvent(KeyEvent event) { 47 return mDragController.dispatchKeyEvent(event) || super.dispatchKeyEvent(event); 48 } 49 50 @Override 51 public boolean onInterceptTouchEvent(MotionEvent ev) { 52 return mDragController.onInterceptTouchEvent(ev); 53 } 54 55 @Override 56 public boolean onTouchEvent(MotionEvent ev) { 57 return mDragController.onTouchEvent(ev); 58 } 59} 60