Java Code Examples for android.view.HapticFeedbackConstants

The following are top voted examples for showing how to use android.view.HapticFeedbackConstants. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: PeSanKita-android   File: RepeatableImageKey.java   View source code 7 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}
 
Example 2
Project: Quran   File: PagerActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onAyahSelected(EventType eventType, SuraAyah suraAyah, AyahTracker tracker) {
  switch (eventType) {
    case SINGLE_TAP:
      if (isInAyahMode) {
        updateAyahStartSelection(suraAyah, tracker);
        return true;
      }
      return false;
    case LONG_PRESS:
      if (isInAyahMode) {
        updateAyahEndSelection(suraAyah);
      } else {
        startAyahMode(suraAyah, tracker);
      }
      viewPager.performHapticFeedback(
          HapticFeedbackConstants.LONG_PRESS);
      return true;
    default:
      return false;
  }
}
 
Example 3
Project: LaunchTime   File: LaunchAppWidgetHostView.java   View source code 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mLongClickStarted = System.currentTimeMillis();
            break;
        case MotionEvent.ACTION_MOVE:
            boolean upVal = System.currentTimeMillis() - mLongClickStarted > ViewConfiguration.getLongPressTimeout();
            if (upVal && mLongClickListener != null) {
                mLongClickListener.onLongClick(LaunchAppWidgetHostView.this);
                performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            }
            break;
        case MotionEvent.ACTION_UP:
            mLongClickStarted = -1;
    }

    return false;
}
 
Example 4
Project: PlusGram   File: EntityView.java   View source code 6 votes vote down vote up
public EntityView(Context context, Point pos) {
    super(context);

    uuid = UUID.randomUUID();
    position = pos;

    gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        public void onLongPress(MotionEvent e) {
            if (hasPanned || hasTransformed || hasReleased) {
                return;
            }

            recognizedLongPress = true;
            if (delegate != null) {
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                delegate.onEntityLongClicked(EntityView.this);
            }
        }
    });
}
 
Example 5
Project: treetracker-android   File: NewTreeFragment.java   View source code 6 votes vote down vote up
public void onClick(View v) {

		v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
				HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);

		switch (v.getId()) {

		case R.id.fragment_new_tree_save:

			saveToDb();

			Toast.makeText(getActivity(), "Tree saved", Toast.LENGTH_SHORT).show();
			getActivity().getSupportFragmentManager().popBackStack();
			break;
		case R.id.fragment_new_tree_take_photo:
			takePicture();
			break;
		}

	}
 
Example 6
Project: treetracker-android   File: DataFragment.java   View source code 6 votes vote down vote up
@Override
public void onClick(View v) {
    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    String userId = mSharedPreferences.getString(ValueHelper.MAIN_DB_USER_ID, "-1");
    switch (v.getId()) {
        case R.id.fragment_data_sync:
            Toast.makeText(getActivity(), "Start syncing", Toast.LENGTH_SHORT).show();
            syncTask = new SyncTask(getActivity(), this, Integer.parseInt(userId)).execute();
            break;
        case R.id.fragment_data_pause:
            if (syncTask != null) {
                syncTask.cancel(true);
            }
            Toast.makeText(getActivity(), "Pause syncing", Toast.LENGTH_SHORT).show();
            break;
        case R.id.fragment_data_resume:
            Toast.makeText(getActivity(), "Resume syncing", Toast.LENGTH_SHORT).show();
            syncTask = new SyncTask(getActivity(), this, Integer.parseInt(userId)).execute();
            break;

    }
}
 
Example 7
Project: sealtalk-android-master   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                              .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 8
Project: Cable-Android   File: RepeatableImageKey.java   View source code 6 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}
 
Example 9
Project: Channelize   File: ToDoListAdapter.java   View source code 6 votes vote down vote up
private void showPopupMenu(View view) {
    final CharSequence[] items = {"Edit", "Delete"};
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);

    builder.setTitle(mTextName.getText());
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            int position = getAdapterPosition();
            switch (which){
                case 0://Edit
                    listener.editTask(position);
                    break;
                case 1://Delete
                    listener.deleteTask(position);
                    break;
            }
        }
    });
    builder.show();
}
 
Example 10
Project: rongyunDemo   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                              .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 11
Project: RongCloudJcenter   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                              .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 12
Project: GalleryFinal-master   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                    .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 13
Project: android-wgallery   File: EcoGallery.java   View source code 6 votes vote down vote up
private boolean dispatchLongPress(View view, int position, long id) {
    boolean handled = false;

    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(this, mDownTouchView, mDownTouchPosition, id);
    }

    if (!handled) {
        mContextMenuInfo = new AdapterContextMenuInfo(view, position, id);
        handled = super.showContextMenuForChild(this);
    }

    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example 14
Project: RongChat   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                    .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 15
Project: openlauncher   File: AppItemView.java   View source code 6 votes vote down vote up
public static OnLongClickListener getLongClickDragAppListener(final Item item, final DragAction.Action action, @Nullable final LongPressCallBack eventAction) {
    return new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (Setup.Companion.appSettings().isDesktopLock()) {
                return false;
            }
            if (eventAction != null && !eventAction.readyForDrag(v)) {
                return false;
            }
            v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            DragNDropHandler.startDrag(v, item, action, eventAction);
            return true;
        }
    };
}
 
Example 16
Project: openlauncher   File: AppItemView.java   View source code 6 votes vote down vote up
public Builder withOnLongClick(final Item item, final DragAction.Action action, @Nullable final LongPressCallBack eventAction) {
    view.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (Setup.Companion.appSettings().isDesktopLock()) {
                return false;
            }
            if (eventAction != null && !eventAction.readyForDrag(v)) {
                return false;
            }
            if (view.vibrateWhenLongPress) {
                v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
            DragNDropHandler.startDrag(view, item, action, eventAction);
            return true;
        }
    });
    return this;
}
 
Example 17
Project: FloatingSearchView   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_clear:
            mSearchView.setText(null);
            mSearchView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
            break;
        case R.id.menu_toggle_icon:
            item.setChecked(!item.isChecked());
            mSearchView.showIcon(item.isChecked());
            break;
        case R.id.menu_tts:
            PackageUtils.startTextToSpeech(this, getString(R.string.speech_prompt), REQ_CODE_SPEECH_INPUT);
            break;
        case R.id.menu_icon_search:
        case R.id.menu_icon_drawer:
        case R.id.menu_icon_custom:
            updateNavigationIcon(item.getItemId());
            Toast.makeText(MainActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
            break;
    }
    return true;
}
 
Example 18
Project: BigApp_Discuz_Android   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                    .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 19
Project: sealtalk-android   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                              .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 20
Project: ticdesign   File: TrackSelectionAdapterWrapper.java   View source code 6 votes vote down vote up
boolean performLongPress(final View child,
                         final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL) {
        if (mChoiceActionMode == null) {
            setItemChecked(longPressPosition, true);
            child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        }
        return true;
    }

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(this, child,
                longPressPosition, longPressId);
    }
    if (handled) {
        child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example 21
Project: MoleMapperAndroid   File: ZoneView.java   View source code 6 votes vote down vote up
@Override
public boolean onSingleTapConfirmed(MotionEvent e)
{
    if(currentState == STATE_MOLE_CREATE)
    {
        Mole emptyMole = new Mole();
        emptyMole.moleX = (int) e.getX();
        emptyMole.moleY = (int) e.getY();
        moles.add(emptyMole);

        postInvalidate();
    }
    else
    {
        if(touchEventMole != null)
        {
            LogExt.e(MoleOnGestureListener.class, "onMoleClick " + touchEventMole.id);
            performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            listener.onMoleClick(touchEventMole);
            touchEventMole = null;
            return true;
        }
    }

    return super.onSingleTapConfirmed(e);
}
 
Example 22
Project: android-jungle-framework   File: CommonHotTagAdapter.java   View source code 6 votes vote down vote up
@Override
public View getTagView(int position) {
    String tag = mTagList.get(position);
    TextView view = (TextView) View.inflate(mContext, R.layout.view_hot_tag, null);
    view.setText(tag);
    view.setTag(tag);
    view.setTextColor(ColorList.randomNextColor());
    view.setOnClickListener(mTagViewClickListener);

    if (mEditable) {
        view.setOnLongClickListener(mTagViewLongClickListener);

        view.performHapticFeedback(
                HapticFeedbackConstants.LONG_PRESS,
                HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
        view.playSoundEffect(SoundEffectConstants.CLICK);
    }

    return view;
}
 
Example 23
Project: android-jungle-framework   File: FavoriteLayoutView.java   View source code 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ItemHolder holder = null;

    if (convertView == null) {
        convertView = View.inflate(getContext(), R.layout.layout_favorite_item, null);
        holder = new ItemHolder(convertView);

        convertView.setTag(holder);
        convertView.setOnClickListener(mItemClickListener);
        convertView.setOnLongClickListener(mItemLongClickListener);

        convertView.performHapticFeedback(
                HapticFeedbackConstants.LONG_PRESS,
                HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
        convertView.playSoundEffect(SoundEffectConstants.CLICK);
    } else {
        holder = (ItemHolder) convertView.getTag();
    }

    FavoriteEntity entity = FavoriteManager.getInstance().getFavoriteEntity(position);
    holder.updateItem(entity);

    return convertView;
}
 
Example 24
Project: Vafrinn   File: ContextMenuHelper.java   View source code 6 votes vote down vote up
/**
 * Starts showing a context menu for {@code view} based on {@code params}.
 * @param contentViewCore The {@link ContentViewCore} to show the menu to.
 * @param params          The {@link ContextMenuParams} that indicate what menu items to show.
 */
@CalledByNative
private void showContextMenu(ContentViewCore contentViewCore, ContextMenuParams params) {
    final View view = contentViewCore.getContainerView();

    if (!shouldShowMenu(params)
            || view == null
            || view.getVisibility() != View.VISIBLE
            || view.getParent() == null) {
        return;
    }

    mCurrentContextMenuParams = params;

    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    view.setOnCreateContextMenuListener(this);
    view.showContextMenu();
}
 
Example 25
Project: GeneqiaoGallery   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                    .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 26
Project: RxZhihuDaily   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                    .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example 27
Project: WebStarter   File: TwoWayView.java   View source code 6 votes vote down vote up
private boolean performLongPress(final View child,
        final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    boolean handled = false;

    OnItemLongClickListener listener = getOnItemLongClickListener();
    if (listener != null) {
        handled = listener.onItemLongClick(TwoWayView.this, child,
                longPressPosition, longPressId);
    }

    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(TwoWayView.this);
    }

    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example 28
Project: speechutils   File: MicButton.java   View source code 6 votes vote down vote up
private void init(Context context) {
    initAnimations(context);

    // Vibrate when the microphone key is pressed down
    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                // TODO: what is the diff between KEYBOARD_TAP and the other constants?
                // TODO: does not seem to work on Android 7.1
                v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
            }
            return false;
        }
    });
}
 
Example 29
Project: recent-images   File: TwoWayAbsListView.java   View source code 6 votes vote down vote up
private boolean performLongPress(final View child,
		final int longPressPosition, final long longPressId) {
	boolean handled = false;

	if (mOnItemLongClickListener != null) {
		handled = mOnItemLongClickListener.onItemLongClick(TwoWayAbsListView.this, child,
				longPressPosition, longPressId);
	}
	if (!handled) {
		mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
		handled = super.showContextMenuForChild(TwoWayAbsListView.this);
	}
	if (handled) {
		performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
	}
	return handled;
}
 
Example 30
Project: Android-MuPDF_as   File: TwoWayView.java   View source code 6 votes vote down vote up
private boolean performLongPress(final View child,
        final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    boolean handled = false;

    OnItemLongClickListener listener = getOnItemLongClickListener();
    if (listener != null) {
        handled = listener.onItemLongClick(TwoWayView.this, child,
                longPressPosition, longPressId);
    }

    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(TwoWayView.this);
    }

    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example 31
Project: Tada   File: TextView.java   View source code 6 votes vote down vote up
@Override
public boolean performLongClick() {
    boolean handled = false;

    if (super.performLongClick()) {
        handled = true;
    }

    if (mEditor != null) {
        handled |= mEditor.performLongClick(handled);
    }

    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        if (mEditor != null) mEditor.mDiscardNextActionUp = true;
    }

    return handled;
}
 
Example 32
Project: test4XXX   File: AbsListView.java   View source code 6 votes vote down vote up
private boolean performLongPress(final View child, final int longPressPosition,
		final long longPressId) {
	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;
}
 
Example 33
Project: MultiTreeListView   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
	unpressTouchedChild();

	final int index = getChildIndex((int) e.getX(), (int) e.getY());
	if (index >= 0 && !mBlockTouchAction) {
		View child = getChildAt(index);
		OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
		if (onItemLongClickListener != null) {
			int adapterIndex = mLeftViewAdapterIndex + index;
			boolean handled = onItemLongClickListener.onItemLongClick(
					HorizontalListView.this, child, adapterIndex,
					mAdapter.getItemId(adapterIndex));

			if (handled) {
				// BZZZTT!!1!
				performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
			}
		}
	}
}
 
Example 34
Project: Multi-Mania-app   File: BulletStaggeredGridView.java   View source code 6 votes vote down vote up
boolean performLongPress(final View child,
                         final int longPressPosition, final long longPressId) {

    // TODO : add check for multiple choice mode.. currently modes are yet to be supported

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(this, child, longPressPosition, longPressId);
    }
    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(this);
    }
    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    return handled;
}
 
Example 35
Project: ischool-oppia-mobile   File: TwoWayView.java   View source code 6 votes vote down vote up
private boolean performLongPress(final View child,
        final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    boolean handled = false;

    OnItemLongClickListener listener = getOnItemLongClickListener();
    if (listener != null) {
        handled = listener.onItemLongClick(TwoWayView.this, child,
                longPressPosition, longPressId);
    }

    if (!handled) {
        mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId);
        handled = super.showContextMenuForChild(TwoWayView.this);
    }

    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example 36
Project: soulissapp   File: EcoGallery.java   View source code 6 votes vote down vote up
private boolean dispatchLongPress(View view, int position, long id) {
	boolean handled = false;

	if (mOnItemLongClickListener != null) {
		handled = mOnItemLongClickListener.onItemLongClick(this, mDownTouchView, mDownTouchPosition, id);
	}

	if (!handled) {
		mContextMenuInfo = new AdapterContextMenuInfo(view, position, id);
		handled = super.showContextMenuForChild(this);
	}

	if (handled) {
		performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
	}

	return handled;
}
 
Example 37
Project: mythmote   File: KeyBindingManager.java   View source code 6 votes vote down vote up
public void onClick(View v) {

		KeyBindingEntry entry = viewToEntryMap.get(v);

		if (null != entry && null != communicator) {
			Log.d(MythMote.LOG_TAG, "onClick " + entry.getFriendlyName()
					+ " command " + entry.getCommand());
			
			//send command
			communicator.SendCommand(entry.getCommand());
			
			//perform haptic feedback if enabled
			if(HapticFeedbackEnabled){
			v.performHapticFeedback(
					HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING,
					HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
			}
		}

	}
 
Example 38
Project: NHentai-android   File: TwoWayGallery.java   View source code 6 votes vote down vote up
private boolean dispatchLongPress(View view, int position, long id) {
	boolean handled = false;

	if (mOnItemLongClickListener != null) {
		handled = mOnItemLongClickListener.onItemLongClick(this, mDownTouchView,
				mDownTouchPosition, id);
	}

	if (!handled) {
		mContextMenuInfo = new AdapterContextMenuInfo(view, position, id);
		handled = super.showContextMenuForChild(this);
	}

	if (handled) {
		performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
	}

	return handled;
}
 
Example 39
Project: TextSecureSMP   File: RepeatableImageKey.java   View source code 6 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}
 
Example 40
Project: Silence   File: RepeatableImageKey.java   View source code 6 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}