Michael Jurka | d4ede53 | 2010-08-04 18:14:08 -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 | |
| 17 | |
Michael Jurka | 0e26059 | 2010-06-30 17:07:39 -0700 | [diff] [blame] | 18 | package com.android.launcher2; |
| 19 | |
| 20 | import android.content.Context; |
| 21 | import android.util.AttributeSet; |
| 22 | import android.view.MotionEvent; |
| 23 | import android.widget.Gallery; |
| 24 | |
| 25 | public abstract class HomeCustomizationItemGallery extends Gallery |
| 26 | implements Gallery.OnItemLongClickListener { |
| 27 | |
| 28 | protected Context mContext; |
| 29 | |
| 30 | protected Launcher mLauncher; |
| 31 | |
| 32 | protected int mMotionDownRawX; |
| 33 | protected int mMotionDownRawY; |
| 34 | |
| 35 | public HomeCustomizationItemGallery(Context context, AttributeSet attrs) { |
| 36 | super(context, attrs); |
| 37 | setLongClickable(true); |
| 38 | setOnItemLongClickListener(this); |
| 39 | mContext = context; |
| 40 | |
| 41 | setCallbackDuringFling(false); |
| 42 | } |
| 43 | |
| 44 | public void setLauncher(Launcher launcher) { |
| 45 | mLauncher = launcher; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public boolean onTouchEvent(MotionEvent ev) { |
| 50 | if (ev.getAction() == MotionEvent.ACTION_DOWN && mLauncher.isAllAppsVisible()) { |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | super.onTouchEvent(ev); |
| 55 | |
| 56 | int x = (int) ev.getX(); |
| 57 | int y = (int) ev.getY(); |
| 58 | |
| 59 | switch (ev.getAction()) { |
| 60 | case MotionEvent.ACTION_DOWN: |
| 61 | mMotionDownRawX = (int) ev.getRawX(); |
| 62 | mMotionDownRawY = (int) ev.getRawY(); |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | } |
| 67 | |