Example usage for android.view HapticFeedbackConstants LONG_PRESS

List of usage examples for android.view HapticFeedbackConstants LONG_PRESS

Introduction

In this page you can find the example usage for android.view HapticFeedbackConstants LONG_PRESS.

Prototype

int LONG_PRESS

To view the source code for android.view HapticFeedbackConstants LONG_PRESS.

Click Source Link

Document

The user has performed a long press on an object that is resulting in an action being performed.

Usage

From source file:com.example.libwidgettv.bak.AbsListView.java

boolean performLongPress(final View child, final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) {
        if (mChoiceActionMode == null
                && (mChoiceActionMode = startActionMode(mMultiChoiceModeCallback)) != null) {
            setItemChecked(longPressPosition, true);
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        }/*from  w ww .  j  a  va  2s . c  om*/
        return true;
    }

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(AbsListView.this, child, longPressPosition,
                longPressId);
    }
    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(AbsListView.this);
    }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}

From source file:com.common.widget.hzlib.AbsHorizontalListView.java

boolean performLongPress(final View child, final int longPressPosition, final long longPressId) {

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(AbsHorizontalListView.this, child, longPressPosition,
                longPressId);//from w w  w  . java 2  s . c om
    }
    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(AbsHorizontalListView.this);
    }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}

From source file:com.common.widget.hzlib.AbsListView.java

boolean performLongPress(final View child, final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(AbsListView.this, child, longPressPosition,
                longPressId);//w w w .ja va  2s  .c  o m
    }
    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(AbsListView.this);
    }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}

From source file:com.android.launcher2.Launcher.java

public boolean onLongClick(View v) {
    if (!isDraggingEnabled())
        return false;
    if (isWorkspaceLocked())
        return false;
    if (mState != State.WORKSPACE)
        return false;

    if (!(v instanceof CellLayout)) {
        v = (View) v.getParent().getParent();
    }// w ww .  j  ava  2 s . c om

    resetAddInfo();
    CellLayout.CellInfo longClickCellInfo = (CellLayout.CellInfo) v.getTag();
    // This happens when long clicking an item with the dpad/trackball
    if (longClickCellInfo == null) {
        return true;
    }

    // The hotseat touch handling does not go through Workspace, and we always allow long press
    // on hotseat items.
    final View itemUnderLongClick = longClickCellInfo.cell;
    boolean allowLongPress = isHotseatLayout(v) || mWorkspace.allowLongPress();
    if (allowLongPress && !mDragController.isDragging()) {
        if (itemUnderLongClick == null) {
            // User long pressed on empty space
            mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                    HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
            startWallpaper();
        } else {
            if (!(itemUnderLongClick instanceof Folder)) {
                // User long pressed on an item
                mWorkspace.startDrag(longClickCellInfo);
            }
        }
    }
    return true;
}

From source file:com.appunite.list.AbsHorizontalListView.java

boolean performLongPress(final View child, final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) {
        if (mChoiceActionMode == null
                && (mChoiceActionMode = startActionModeCompat(mMultiChoiceModeCallback)) != null) {
            setItemChecked(longPressPosition, true);
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        }/*from  w w  w. j a  va 2  s  .com*/
        return true;
    }

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(AbsHorizontalListView.this, child, longPressPosition,
                longPressId);
    }
    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(AbsHorizontalListView.this);
    }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}

From source file:com.appunite.list.AbsListView.java

boolean performLongPress(final View child, final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) {
        if (mChoiceActionMode == null
                && (mChoiceActionMode = startActionModeCompat(mMultiChoiceModeCallback)) != null) {
            setItemChecked(longPressPosition, true);
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        }//from w  w  w  .  j a  v a  2 s  . c o  m
        return true;
    }

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(AbsListView.this, child, longPressPosition,
                longPressId);
    }
    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(AbsListView.this);
    }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}

From source file:caesar.feng.framework.widget.StaggeredGrid.ExtendableListView.java

private boolean performLongPress(final View child, final int longPressPosition, final long longPressId) {
    boolean handled = false;

    OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
    if (onItemLongClickListener != null) {
        handled = onItemLongClickListener.onItemLongClick(ExtendableListView.this, child, longPressPosition,
                longPressId);//from  ww  w .  jav  a  2 s.  com
    }
    //        if (!handled) {
    //            mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
    //            handled = super.showContextMenuForChild(AbsListView.this);
    //        }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}

From source file:com.sintn.hera.client.widget.view.stagegered.ExtendableListView.java

private boolean performLongPress(final View child, final int longPressPosition, final long longPressId) {
    boolean handled = false;

    OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
    if (onItemLongClickListener != null) {
        handled = onItemLongClickListener.onItemLongClick(ExtendableListView.this, child, longPressPosition,
                longPressId);//w  ww. jav a2s  .c om
    }
    // if (!handled) {
    // mContextMenuInfo = createContextMenuInfo(child, longPressPosition,
    // longPressId);
    // handled = super.showContextMenuForChild(AbsListView.this);
    // }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}

From source file:com.android.soma.Launcher.java

public boolean onLongClick(View v) {
    if (!isDraggingEnabled())
        return false;
    if (isWorkspaceLocked())
        return false;
    if (mState != State.WORKSPACE)
        return false;

    if (v instanceof Workspace) {
        if (!mWorkspace.isInOverviewMode()) {
            if (mWorkspace.enterOverviewMode()) {
                mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                        HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
                return true;
            } else {
                return false;
            }//from ww w.  j  a  v a 2 s.  co  m
        }
    }

    if (!(v instanceof CellLayout)) {
        v = (View) v.getParent().getParent();
    }

    resetAddInfo();
    CellLayout.CellInfo longClickCellInfo = (CellLayout.CellInfo) v.getTag();
    // This happens when long clicking an item with the dpad/trackball
    if (longClickCellInfo == null) {
        return true;
    }

    // The hotseat touch handling does not go through Workspace, and we always allow long press
    // on hotseat items.
    final View itemUnderLongClick = longClickCellInfo.cell;
    boolean allowLongPress = isHotseatLayout(v) || mWorkspace.allowLongPress();
    if (allowLongPress && !mDragController.isDragging()) {
        if (itemUnderLongClick == null) {
            // User long pressed on empty space
            mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                    HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
            // Disabling reordering until we sort out some issues.
            if (mWorkspace.isInOverviewMode()) {
                mWorkspace.startReordering(v);
            } else {
                mWorkspace.enterOverviewMode();
            }
        } else {
            if (!(itemUnderLongClick instanceof Folder)) {
                // User long pressed on an item
                mWorkspace.startDrag(longClickCellInfo);
            }
        }
    }
    return true;
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

public boolean onLongClick(View v) {
    if (mDesktopLocked) {
        return false;
    }/*from   w ww . j  a  v  a2 s. c  o  m*/
    // ADW: Show previews on longpressing the dots
    switch (v.getId()) {
    case R.id.btn_scroll_left:
        mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
        showPreviousPreview(v);
        return true;
    case R.id.btn_scroll_right:
        mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
        showNextPreview(v);
        return true;
    }

    if (!(v instanceof PersonaCellLayout)) {
        v = (View) v.getParent();
    }

    PersonaCellLayout.CellInfo cellInfo = (PersonaCellLayout.CellInfo) v.getTag();

    // This happens when long clicking an item with the dpad/trackball
    if (cellInfo == null) {
        return true;
    }

    if (mWorkspace.allowLongPress() && !mBlockDesktop) {
        if (cellInfo.cell == null) {
            if (cellInfo.valid) {
                // User long pressed on empty space
                mWorkspace.setAllowLongPress(false);
                showAddDialog(cellInfo);
            }
        } else {
            if (!(cellInfo.cell instanceof PersonaFolder)) {
                // User long pressed on an item
                mWorkspace.startDrag(cellInfo);
            }
        }
    }
    return true;
}