android.view.View#playSoundEffect ( )源码实例Demo

下面列出了android.view.View#playSoundEffect ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LaunchEnr   文件: FocusHelper.java
/**
 * 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;
    }
}
 
源代码2 项目: narrate-android   文件: CalendarFragment.java
@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);
}
 
源代码3 项目: Conversations   文件: FixedURLSpan.java
@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();
	}
}
 
源代码4 项目: Trebuchet   文件: FocusHelper.java
/**
 * 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;
    }
}
 
源代码5 项目: Pix-Art-Messenger   文件: FixedURLSpan.java
@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();
    }
}
 
源代码6 项目: android_tv_metro   文件: Utils.java
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);
   		}
	}
}
 
源代码7 项目: UltimateAndroid   文件: ItemClickSupport.java
@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;
}
 
源代码8 项目: android_tv_metro   文件: Utils.java
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);
   		}
	}
}
 
源代码9 项目: narrate-android   文件: EntriesListFragment.java
@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);
}
 
源代码10 项目: PlayWidget   文件: ItemClickSupport.java
@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;
}
 
源代码11 项目: odyssey   文件: OdysseyRecyclerView.java
@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;
}
 
源代码12 项目: GridBuilder   文件: GridBuilder.java
@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);
        }
    }
}
 
源代码13 项目: 365browser   文件: AppMenuButtonHelper.java
@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);
}
 
源代码14 项目: MultiView   文件: ItemClickSupport.java
@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;
}
 
@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);
                }
            }
        }
    }
}
 
源代码16 项目: UpcomingMoviesMVP   文件: ClickRecyclerView.java
@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;
}
 
源代码17 项目: TelePlus-Android   文件: RecyclerListView.java
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;
                }
            }
        }
    });
}
 
源代码18 项目: iBeebo   文件: Utility.java
public static void playClickSound(View view) {
    view.playSoundEffect(SoundEffectConstants.CLICK);
}
 
源代码19 项目: iBeebo   文件: Utility.java
public static void playClickSound(View view) {
    view.playSoundEffect(SoundEffectConstants.CLICK);
}
 
源代码20 项目: MiBandDecompiled   文件: SlidingUpPanelLayout.java
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;
}
 
 方法所在类
 同类方法