diff options
author | Winson Chung <winsonc@google.com> | 2012-02-23 15:23:44 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2012-02-23 15:23:56 -0800 |
commit | 88f334571fe41df620ba903ced9b2c69b0170d5c (patch) | |
tree | 10cab22bd80262aa11dfc12238eb07394a2b0bf6 /src/com/android/launcher2/CheckLongPressHelper.java | |
parent | 72d598400da7cef9c7fc4f99bb1fcd7ff0710011 (diff) | |
download | android_packages_apps_Trebuchet-88f334571fe41df620ba903ced9b2c69b0170d5c.tar.gz android_packages_apps_Trebuchet-88f334571fe41df620ba903ced9b2c69b0170d5c.tar.bz2 android_packages_apps_Trebuchet-88f334571fe41df620ba903ced9b2c69b0170d5c.zip |
Lowering long press time for workspace items.
Change-Id: I6a3b0e13681f07d0e50bf2dcec777037c4ef51a5
Diffstat (limited to 'src/com/android/launcher2/CheckLongPressHelper.java')
-rw-r--r-- | src/com/android/launcher2/CheckLongPressHelper.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/com/android/launcher2/CheckLongPressHelper.java b/src/com/android/launcher2/CheckLongPressHelper.java new file mode 100644 index 000000000..3ccda2635 --- /dev/null +++ b/src/com/android/launcher2/CheckLongPressHelper.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher2; + +import android.view.View; + +public class CheckLongPressHelper { + private View mView; + private boolean mHasPerformedLongPress; + private CheckForLongPress mPendingCheckForLongPress; + + class CheckForLongPress implements Runnable { + public void run() { + if ((mView.getParent() != null) && mView.hasWindowFocus() + && !mHasPerformedLongPress) { + if (mView.performLongClick()) { + mHasPerformedLongPress = true; + } + } + } + } + + public CheckLongPressHelper(View v) { + mView = v; + } + + public void postCheckForLongPress() { + mHasPerformedLongPress = false; + + if (mPendingCheckForLongPress == null) { + mPendingCheckForLongPress = new CheckForLongPress(); + } + mView.postDelayed(mPendingCheckForLongPress, LauncherApplication.getLongPressTimeout()); + } + + public void cancelLongPress() { + mHasPerformedLongPress = false; + if (mPendingCheckForLongPress != null) { + mView.removeCallbacks(mPendingCheckForLongPress); + mPendingCheckForLongPress = null; + } + } + + public boolean hasPerformedLongPress() { + return mHasPerformedLongPress; + } +} |