Java Code Examples for android.view.View#playSoundEffect()
The following examples show how to use
android.view.View#playSoundEffect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FocusHelper.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
/** * Helper method to be used for playing sound effects. */ @Thunk private static void playSoundEffect(int keyCode, View v) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT); break; case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_PAGE_DOWN: case KeyEvent.KEYCODE_MOVE_END: v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN); break; case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_PAGE_UP: case KeyEvent.KEYCODE_MOVE_HOME: v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP); break; default: break; } }
Example 2
Source File: CalendarFragment.java From narrate-android with Apache License 2.0 | 6 votes |
@Override public boolean onSingleTapUp(MotionEvent e) { View view = mRecyclerView.findChildViewUnder(e.getX(), e.getY()); if (view != null) { view.playSoundEffect(SoundEffectConstants.CLICK); int pos = mRecyclerView.getChildPosition(view); Intent i = new Intent(getActivity(), ViewEntryActivity.class); Bundle b = new Bundle(); b.putParcelable(ViewEntryActivity.ENTRY_KEY, mDisplayedEntries.get(pos)); i.putExtras(b); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.buildDrawingCache(true); Bitmap drawingCache = view.getDrawingCache(true); Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0).toBundle(); getActivity().startActivity(i, bundle); } else { startActivity(i); } } return super.onSingleTapUp(e); }
Example 3
Source File: FixedURLSpan.java From Conversations with GNU General Public License v3.0 | 6 votes |
@Override public void onClick(View widget) { final Uri uri = Uri.parse(getURL()); final Context context = widget.getContext(); final boolean candidateToProcessDirectly = "xmpp".equals(uri.getScheme()) || ("https".equals(uri.getScheme()) && "conversations.im".equals(uri.getHost()) && uri.getPathSegments().size() > 1 && Arrays.asList("j","i").contains(uri.getPathSegments().get(0))); if (candidateToProcessDirectly && context instanceof ConversationsActivity) { if (((ConversationsActivity) context).onXmppUriClicked(uri)) { widget.playSoundEffect(0); return; } } final Intent intent = new Intent(Intent.ACTION_VIEW, uri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } //intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); try { context.startActivity(intent); widget.playSoundEffect(0); } catch (ActivityNotFoundException e) { Toast.makeText(context, R.string.no_application_found_to_open_link, Toast.LENGTH_SHORT).show(); } }
Example 4
Source File: FixedURLSpan.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override public void onClick(View widget) { final Uri uri = Uri.parse(getURL()); final Context context = widget.getContext(); final boolean candidateToProcessDirectly = "xmpp".equals(uri.getScheme()) || ("https".equals(uri.getScheme()) && Config.inviteHostURL.equals(uri.getHost()) && uri.getPathSegments().size() > 1 && Arrays.asList("j", "i").contains(uri.getPathSegments().get(0))); if (candidateToProcessDirectly && context instanceof ConversationsActivity) { if (((ConversationsActivity) context).onXmppUriClicked(uri)) { widget.playSoundEffect(0); return; } } final Intent intent = new Intent(Intent.ACTION_VIEW, uri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } //intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); try { context.startActivity(intent); widget.playSoundEffect(0); } catch (ActivityNotFoundException e) { ToastCompat.makeText(context, R.string.no_application_found_to_open_link, Toast.LENGTH_SHORT).show(); } }
Example 5
Source File: FocusHelper.java From Trebuchet with GNU General Public License v3.0 | 6 votes |
/** * Helper method to be used for playing sound effects. */ @Thunk static void playSoundEffect(int keyCode, View v) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT); break; case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_PAGE_DOWN: case KeyEvent.KEYCODE_MOVE_END: v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN); break; case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_PAGE_UP: case KeyEvent.KEYCODE_MOVE_HOME: v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP); break; default: break; } }
Example 6
Source File: ItemClickSupport.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override boolean performItemClick(RecyclerView parent, View view, int position, long id) { if (mItemClickListener != null) { view.playSoundEffect(SoundEffectConstants.CLICK); mItemClickListener.onItemClick(parent, view, position, id); return true; } return false; }
Example 7
Source File: ClickRecyclerView.java From UpcomingMoviesMVP with Apache License 2.0 | 5 votes |
@Override boolean performItemClick(RecyclerView parent, View view, int position, long id) { if (mItemClickListener != null) { view.playSoundEffect(SoundEffectConstants.CLICK); mItemClickListener.onItemClick(parent, view, position, id); return true; } return false; }
Example 8
Source File: MaterialNavHeadItemActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { if (!drawerTouchLocked) { MaterialHeadItem headItem = findHeadItemNumber(MaterialHeadItem.THIRD_HEADITEM); if (headItem != null) { headItemThirdPhoto.setSoundEffectsEnabled(true); v.playSoundEffect(android.view.SoundEffectConstants.CLICK); headItemThirdPhoto.setSoundEffectsEnabled(false); if (headItemChangedListener != null) headItemChangedListener.onBeforeChangeHeadItem(headItem); switchHeadItemsIcon(headItem, true); if (headItemChangedListener != null) headItemChangedListener.onAfterChangeHeadItem(headItem); } else {// if there is no second account user clicked for open it //accountListener.onAccountOpening(currentAccount); if (headItemManager.get(0).getBackgroundOnClickListener() != null) { headItemThirdPhoto.setSoundEffectsEnabled(true); v.playSoundEffect(android.view.SoundEffectConstants.CLICK); headItemThirdPhoto.setSoundEffectsEnabled(false); headItemManager.get(0).getBackgroundOnClickListener().onClick(headItemManager.get(0)); if (headItemManager.get(0).isCloseDrawerBackgroundOnClick() && !deviceSupportMultiPane()) { drawerLayout.closeDrawer(drawerViewGroup); } } } } }
Example 9
Source File: ItemClickSupport.java From MultiView with Apache License 2.0 | 5 votes |
@Override boolean performItemClick(RecyclerView parent, View view, int position, long id) { if (mItemClickListener != null) { view.playSoundEffect(SoundEffectConstants.CLICK); mItemClickListener.onItemClick(parent, view, position, id); return true; } return false; }
Example 10
Source File: AppMenuButtonHelper.java From 365browser with Apache License 2.0 | 5 votes |
@Override public boolean performAccessibilityAction(View host, int action, Bundle args) { if (action == AccessibilityNodeInfo.ACTION_CLICK) { if (!mMenuHandler.isAppMenuShowing()) { showAppMenu(host, false); } else { mMenuHandler.hideAppMenu(); } host.playSoundEffect(SoundEffectConstants.CLICK); host.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); return true; } return super.performAccessibilityAction(host, action, args); }
Example 11
Source File: GridBuilder.java From GridBuilder with Apache License 2.0 | 5 votes |
@Override public void onFocusChange(View v, boolean hasFocus) { if (!(v instanceof IGridItemView)) { return; } GridItem gridItem = ((IGridItemView) v).getGridItem(); if (null != mItemSelectedListener) { mItemSelectedListener.onItemSelected(gridItem, v, hasFocus); } if (hasFocus) { v.bringToFront(); mGridLayout.invalidate(); enlargeItem(v, gridItem); refreshReflection(mBaseHeight); if (mSoundEffectsEnabled) { v.setSoundEffectsEnabled(true); v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN); v.setSoundEffectsEnabled(false); } } else { narrowItem(v, gridItem); if (null == mGridLayout.getFocusedChild()) { refreshReflection(mBaseHeight); } } }
Example 12
Source File: OdysseyRecyclerView.java From odyssey with GNU General Public License v3.0 | 5 votes |
@Override public boolean onInterceptTouchEvent(@NonNull RecyclerView view, @NonNull MotionEvent motionEvent) { final View childView = view.findChildViewUnder(motionEvent.getX(), motionEvent.getY()); if (childView != null && mGestureDetector.onTouchEvent(motionEvent)) { childView.playSoundEffect(SoundEffectConstants.CLICK); mOnItemClickListener.onItemClick(view.getChildAdapterPosition(childView)); return true; } return false; }
Example 13
Source File: ItemClickSupport.java From PlayWidget with MIT License | 5 votes |
@Override boolean performItemClick(RecyclerView parent, View view, int position, long id) { if (mItemClickListener != null) { view.playSoundEffect(SoundEffectConstants.CLICK); mItemClickListener.onItemClick(parent, view, position, id); return true; } return false; }
Example 14
Source File: EntriesListFragment.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapUp(MotionEvent e) { View view = mRecyclerView.findChildViewUnder(e.getX(), e.getY()); if (mActionMode != null) { toggleSelectedItem(mRecyclerView.getChildPosition(view)); } else { if ( view != null ) { view.playSoundEffect(SoundEffectConstants.CLICK); int pos = mRecyclerView.getChildPosition(view); Intent i = new Intent(getActivity(), ViewEntryActivity.class); Bundle b = new Bundle(); b.putParcelable(ViewEntryActivity.ENTRY_KEY, ((MainActivity) getActivity()).entries.get(pos - mAdapter.getSectionOffset(pos))); i.putExtras(b); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.buildDrawingCache(true); Bitmap drawingCache = view.getDrawingCache(true); Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0).toBundle(); getActivity().startActivity(i, bundle); } else { startActivity(i); } } } return super.onSingleTapUp(e); }
Example 15
Source File: Utils.java From android_tv_metro with Apache License 2.0 | 5 votes |
public static void playKeySound(View view, int soundKey) { if (null != view) { if (soundKey == SOUND_KEYSTONE_KEY) { view.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN); } else if (soundKey == SOUND_ERROR_KEY) { view.playSoundEffect(5); } } }
Example 16
Source File: Utils.java From android_tv_metro with Apache License 2.0 | 5 votes |
public static void playKeySound(View view, int soundKey) { if (null != view) { if (soundKey == SOUND_KEYSTONE_KEY) { view.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN); } else if (soundKey == SOUND_ERROR_KEY) { view.playSoundEffect(5); } } }
Example 17
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 4 votes |
public static void playClickSound(View view) { view.playSoundEffect(SoundEffectConstants.CLICK); }
Example 18
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 4 votes |
public static void playClickSound(View view) { view.playSoundEffect(SoundEffectConstants.CLICK); }
Example 19
Source File: SlidingUpPanelLayout.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public boolean onTouchEvent(MotionEvent motionevent) { boolean flag; if (!mCanSlide || !mIsSlidingEnabled) { flag = super.onTouchEvent(motionevent); } else { mDragHelper.processTouchEvent(motionevent); int i = motionevent.getAction(); flag = true; switch (i & 0xff) { default: return flag; case 0: // '\0' float f4 = motionevent.getX(); float f5 = motionevent.getY(); mInitialMotionX = f4; mInitialMotionY = f5; return flag; case 1: // '\001' dispatchOnPanelLastOffset(mSlideableView); break; } float f = motionevent.getX(); float f1 = motionevent.getY(); float f2 = f - mInitialMotionX; float f3 = f1 - mInitialMotionY; int j = mDragHelper.getTouchSlop(); View view; if (mDragView != null) { view = mDragView; } else { view = mSlideableView; } if (f2 * f2 + f3 * f3 < (float)(j * j) && isDragViewUnder((int)f, (int)f1)) { view.playSoundEffect(0); if (!isExpanded() && !isAnchored()) { expandPane(mAnchorPoint); return flag; } else { collapsePane(); return flag; } } } return flag; }
Example 20
Source File: RecyclerListView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public RecyclerListViewItemClickListener(Context context) { gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { if (currentChildView != null && (onItemClickListener != null || onItemClickListenerExtended != null)) { onChildPressed(currentChildView, true); final View view = currentChildView; final int position = currentChildPosition; final float x = e.getX(); final float y = e.getY(); if (instantClick && position != -1) { view.playSoundEffect(SoundEffectConstants.CLICK); if (onItemClickListener != null) { onItemClickListener.onItemClick(view, position); } else if (onItemClickListenerExtended != null) { onItemClickListenerExtended.onItemClick(view, position, x, y); } } AndroidUtilities.runOnUIThread(clickRunnable = new Runnable() { @Override public void run() { if (this == clickRunnable) { clickRunnable = null; } if (view != null) { onChildPressed(view, false); if (!instantClick) { view.playSoundEffect(SoundEffectConstants.CLICK); if (position != -1) { if (onItemClickListener != null) { onItemClickListener.onItemClick(view, position); } else if (onItemClickListenerExtended != null) { onItemClickListenerExtended.onItemClick(view, position, x, y); } } } } } }, ViewConfiguration.getPressedStateDuration()); if (selectChildRunnable != null) { View pressedChild = currentChildView; AndroidUtilities.cancelRunOnUIThread(selectChildRunnable); selectChildRunnable = null; currentChildView = null; interceptedByChild = false; removeSelection(pressedChild, e); } } return true; } @Override public void onLongPress(MotionEvent event) { if (currentChildView == null || currentChildPosition == -1 || onItemLongClickListener == null && onItemLongClickListenerExtended == null) { return; } View child = currentChildView; if (onItemLongClickListener != null) { if (onItemLongClickListener.onItemClick(currentChildView, currentChildPosition)) { child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } } else if (onItemLongClickListenerExtended != null) { if (onItemLongClickListenerExtended.onItemClick(currentChildView, currentChildPosition, event.getX(), event.getY())) { child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); longPressCalled = true; } } } }); }