blob: 2eba49f143d71c7d5f591261a09d981c1398bd18 [file] [log] [blame]
Michael Jurkad4ede532010-08-04 18:14:08 -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
17
Michael Jurka0e260592010-06-30 17:07:39 -070018package com.android.launcher2;
19
20import android.content.Context;
21import android.util.AttributeSet;
22import android.view.MotionEvent;
23import android.widget.Gallery;
24
25public 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