本文整理汇总了Java中android.view.View.playSoundEffect方法的典型用法代码示例。如果您正苦于以下问题:Java View.playSoundEffect方法的具体用法?Java View.playSoundEffect怎么用?Java View.playSoundEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.playSoundEffect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playSoundEffect
import android.view.View; //导入方法依赖的package包/类
/**
* 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: playSoundEffect
import android.view.View; //导入方法依赖的package包/类
/**
* 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;
}
}
示例3: onInterceptTouchEvent
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent motionEvent) {
View child = rv.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child != null && gestureDetector.onTouchEvent(motionEvent)) {
child.playSoundEffect(SoundEffectConstants.CLICK);
int position = rv.getChildAdapterPosition(child);
callback.onFeedbackItemClick(position);
}
return false;
}
示例4: RecyclerListViewItemClickListener
import android.view.View; //导入方法依赖的package包/类
public RecyclerListViewItemClickListener(Context context) {
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (currentChildView != null && onItemClickListener != null) {
currentChildView.setPressed(true);
final View view = currentChildView;
if (instantClick) {
view.playSoundEffect(SoundEffectConstants.CLICK);
onItemClickListener.onItemClick(view, currentChildPosition);
}
AndroidUtilities.runOnUIThread(clickRunnable = new Runnable() {
@Override
public void run() {
if (this == clickRunnable) {
clickRunnable = null;
}
if (view != null) {
view.setPressed(false);
if (!instantClick) {
view.playSoundEffect(SoundEffectConstants.CLICK);
if (onItemClickListener != null) {
onItemClickListener.onItemClick(view, currentChildPosition);
}
}
}
}
}, ViewConfiguration.getPressedStateDuration());
if (selectChildRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(selectChildRunnable);
selectChildRunnable = null;
currentChildView = null;
interceptedByChild = false;
}
}
return true;
}
@Override
public void onLongPress(MotionEvent event) {
if (currentChildView != null) {
if (onItemLongClickListener != null) {
if (onItemLongClickListener.onItemClick(currentChildView, currentChildPosition)) {
currentChildView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
}
}
}
});
}
示例5: RecyclerListViewItemClickListener
import android.view.View; //导入方法依赖的package包/类
public RecyclerListViewItemClickListener(Context context) {
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (currentChildView != null && onItemClickListener != null) {
currentChildView.setPressed(true);
final View view = currentChildView;
if (instantClick) {
view.playSoundEffect(SoundEffectConstants.CLICK);
onItemClickListener.onItemClick(view, currentChildPosition);
}
AndroidUtilities.runOnUIThread(clickRunnable = new Runnable() {
@Override
public void run() {
if (this == clickRunnable) {
clickRunnable = null;
}
if (view != null) {
view.setPressed(false);
if (!instantClick) {
view.playSoundEffect(SoundEffectConstants.CLICK);
if (onItemClickListener != null) {
onItemClickListener.onItemClick(view, currentChildPosition);
}
}
}
}
}, ViewConfiguration.getPressedStateDuration());
if (selectChildRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(selectChildRunnable);
selectChildRunnable = null;
currentChildView = null;
interceptedByChild = false;
}
}
return true;
}
@Override
public void onLongPress(MotionEvent event) {
if (currentChildView != null) {
View child = currentChildView;
if (onItemLongClickListener != null) {
if (onItemLongClickListener.onItemClick(currentChildView, currentChildPosition)) {
child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
}
}
}
});
}