本文整理匯總了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);
}
}
}
}
});
}