2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.launcher;
19 import android.widget.GridView;
20 import android.widget.AdapterView;
21 import android.content.Context;
22 import android.util.AttributeSet;
23 import android.view.View;
25 public class AllAppsGridView extends GridView implements AdapterView.OnItemClickListener,
26 AdapterView.OnItemLongClickListener, DragSource {
28 private DragController mDragger;
29 private Launcher mLauncher;
31 public AllAppsGridView(Context context) {
35 public AllAppsGridView(Context context, AttributeSet attrs) {
36 super(context, attrs);
39 public AllAppsGridView(Context context, AttributeSet attrs, int defStyle) {
40 super(context, attrs, defStyle);
44 protected void onFinishInflate() {
45 setOnItemClickListener(this);
46 setOnItemLongClickListener(this);
49 public void onItemClick(AdapterView parent, View v, int position, long id) {
50 ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
51 mLauncher.startActivitySafely(app.intent);
54 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
55 if (!view.isInTouchMode()) {
59 ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
60 app = new ApplicationInfo(app);
62 mDragger.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
63 mLauncher.closeAllApplications();
68 public void setDragger(DragController dragger) {
72 public void onDropCompleted(View target, boolean success) {
75 void setLauncher(Launcher launcher) {