类android.view.SoundEffectConstants源码实例Demo

下面列出了怎么用android.view.SoundEffectConstants的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: Gallery.java
/**
 * Handles left, right, and clicking
 * @see android.view.View#onKeyDown
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        
    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (moveDirection(-1)) {
            playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
            return true;
        }
        break;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (moveDirection(1)) {
            playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
            return true;
        }
        break;
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_ENTER:
        mReceivedInvokeKeyDown = true;
        // fallthrough to default handling
    }
    
    return super.onKeyDown(keyCode, event);
}
 
源代码2 项目: 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;
    }
}
 
源代码3 项目: narrate-android   文件: EntryListDialogFragment.java
@Override
public boolean onSingleTapUp(MotionEvent e) {
    View view = mList.findChildViewUnder(e.getX(), e.getY());

    if (view != null) {
        view.playSoundEffect(SoundEffectConstants.CLICK);

        int pos = mList.getChildPosition(view);

        Intent i = new Intent(getActivity(), ViewEntryActivity.class);
        Bundle b = new Bundle();
        b.putParcelable(ViewEntryActivity.ENTRY_KEY, mItems.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);
}
 
源代码4 项目: Carbon   文件: Chip.java
@Override
public boolean performClick() {
    toggle();

    if (onCheckedChangeListener != null)
        onCheckedChangeListener.onCheckedChanged(this, isChecked());

    final boolean handled = super.performClick();
    if (!handled) {
        // View only makes a sound effect if the onClickListener was
        // called, so we'll need to make one here instead.
        playSoundEffect(SoundEffectConstants.CLICK);
    }

    return handled;
}
 
源代码5 项目: CircularView   文件: CircularView.java
@Override
public boolean onLongClick(View v) {
    if (mOnCircularViewObjectClickListener != null && isLongClickable()) {
        mLongClickRegistered = true;
        if (mTouchEventMarkerPos == -1) {
            playSoundEffect(SoundEffectConstants.CLICK);
            mOnCircularViewObjectClickListener.onClick(CircularView.this, true);
            mTouchEventMarkerPos = null;
        } else if (mTouchEventMarker != null) {
            playSoundEffect(SoundEffectConstants.CLICK);
            mOnCircularViewObjectClickListener.onMarkerClick(CircularView.this, mTouchEventMarker, mTouchEventMarkerPos, true);
            mTouchEventMarker = null;
            mTouchEventMarkerPos = null;
        }
        return mLongClickRegistered;
    }
    return false;
}
 
源代码6 项目: samples   文件: EcoGallery.java
/**
 * Handles left, right, and clicking
 *
 * @see View#onKeyDown
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {

        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (movePrevious()) {
                playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
            }
            return true;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (moveNext()) {
                playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
            }
            return true;

        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            mReceivedInvokeKeyDown = true;
            // fallthrough to default handling
    }

    return super.onKeyDown(keyCode, event);
}
 
源代码7 项目: a   文件: TabLayout.java
@Override
public boolean performClick() {
    final boolean handled = super.performClick();

    if (mTab != null) {
        if (!handled) {
            playSoundEffect(SoundEffectConstants.CLICK);
        }
        mTab.select();
        return true;
    } else {
        return handled;
    }
}
 
源代码8 项目: cwac-mediarouter   文件: MediaRouteButton.java
@Override
public boolean performClick() {
  // Send the appropriate accessibility events and call listeners
  boolean handled = super.performClick();
  if (!handled) {
    playSoundEffect(SoundEffectConstants.CLICK);
  }
  return showDialog() || handled;
}
 
源代码9 项目: 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;
}
 
源代码10 项目: tup.dota2recipe   文件: SimpleGridView.java
/**
 * Call the OnItemClickListener, if it is defined.
 * 
 * @param view
 *            The view within the AdapterView that was clicked.
 * @param position
 *            The position of the view in the adapter.
 * @param id
 *            The row id of the item that was clicked.
 * @return True if there was an assigned OnItemClickListener that was
 *         called, false otherwise is returned.
 */
public boolean performItemClick(View view, int position, long id) {
    if (mOnItemClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        mOnItemClickListener.onItemClick(this.mAdapter, view, position, id);
        return true;
    }

    return false;
}
 
源代码11 项目: android_9.0.0_r45   文件: ListView.java
/**
 * Scrolls to the next or previous item if possible.
 *
 * @param direction either {@link View#FOCUS_UP} or {@link View#FOCUS_DOWN}
 *
 * @return whether selection was moved
 */
boolean arrowScroll(int direction) {
    try {
        mInLayout = true;
        final boolean handled = arrowScrollImpl(direction);
        if (handled) {
            playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
        }
        return handled;
    } finally {
        mInLayout = false;
    }
}
 
源代码12 项目: 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;
}
 
源代码13 项目: android_9.0.0_r45   文件: ActionMenuPresenter.java
@Override
public boolean performClick() {
    if (super.performClick()) {
        return true;
    }

    playSoundEffect(SoundEffectConstants.CLICK);
    showOverflowMenu();
    return true;
}
 
源代码14 项目: TelePlus-Android   文件: SharedAudioCell.java
private boolean checkAudioMotionEvent(MotionEvent event) {
    int x = (int) event.getX();
    int y = (int) event.getY();
    boolean result = false;
    int side = AndroidUtilities.dp(36);
    boolean area = false;
    if (miniButtonState >= 0) {
        int offset = AndroidUtilities.dp(27);
        area = x >= buttonX + offset && x <= buttonX + offset + side && y >= buttonY + offset && y <= buttonY + offset + side;
    }
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (area) {
            miniButtonPressed = true;
            invalidate();
            result = true;
            updateRadialProgressBackground();
        }
    } else if (miniButtonPressed) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            miniButtonPressed = false;
            playSoundEffect(SoundEffectConstants.CLICK);
            didPressedMiniButton(true);
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
            miniButtonPressed = false;
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            if (!area) {
                miniButtonPressed = false;
                invalidate();
            }
        }
        updateRadialProgressBackground();
    }
    return result;
}
 
源代码15 项目: zen4android   文件: ActionMenuPresenter.java
@Override
public boolean performClick() {
    if (super.performClick()) {
        return true;
    }

    playSoundEffect(SoundEffectConstants.CLICK);
    showOverflowMenu();
    return true;
}
 
源代码16 项目: TelePlus-Android   文件: PhotoAttachPhotoCell.java
@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean result = false;

    checkFrame.getHitRect(rect);
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (rect.contains((int) event.getX(), (int) event.getY())) {
            pressed = true;
            invalidate();
            result = true;
        }
    } else if (pressed) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            getParent().requestDisallowInterceptTouchEvent(true);
            pressed = false;
            playSoundEffect(SoundEffectConstants.CLICK);
            delegate.onCheckClick(this);
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
            pressed = false;
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            if (!(rect.contains((int) event.getX(), (int) event.getY()))) {
                pressed = false;
                invalidate();
            }
        }
    }
    if (!result) {
        result = super.onTouchEvent(event);
    }

    return result;
}
 
源代码17 项目: TelePlus-Android   文件: ChatAttachAlert.java
@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean result = false;

    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        pressed = true;
        invalidate();
        result = true;
    } else if (pressed) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            getParent().requestDisallowInterceptTouchEvent(true);
            pressed = false;
            playSoundEffect(SoundEffectConstants.CLICK);
            delegate.didSelectBot(MessagesController.getInstance(currentAccount).getUser(DataQuery.getInstance(currentAccount).inlineBots.get((Integer) getTag()).peer.user_id));
            setUseRevealAnimation(false);
            dismiss();
            setUseRevealAnimation(true);
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
            pressed = false;
            invalidate();
        }
    }
    if (!result) {
        result = super.onTouchEvent(event);
    } else {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            startCheckLongPress();
        }
    }
    if (event.getAction() != MotionEvent.ACTION_DOWN && event.getAction() != MotionEvent.ACTION_MOVE) {
        cancelCheckLongPress();
    }

    return result;
}
 
@Override
public boolean onSingleTapUp(MotionEvent e) {
  int position = mDecor.findHeaderPositionUnder((int) e.getX(), (int) e.getY());
  if (position != -1) {
    View headerView = mDecor.getHeaderView(mRecyclerView, position);
    long headerId = getAdapter().getHeaderId(position);
    mOnHeaderClickListener.onHeaderClick(headerView, position, headerId);
    mRecyclerView.playSoundEffect(SoundEffectConstants.CLICK);
    headerView.onTouchEvent(e);
    return true;
  }
  return false;
}
 
@Override
public boolean onSingleTapUp(MotionEvent e) {
  int position = mDecor.findHeaderPositionUnder((int) e.getX(), (int) e.getY());
  if (position != -1) {
    View headerView = mDecor.getHeaderView(mRecyclerView, position);
    long headerId = getAdapter().getHeaderId(position);
    mOnHeaderClickListener.onHeaderClick(headerView, position, headerId);
    mRecyclerView.playSoundEffect(SoundEffectConstants.CLICK);
    headerView.onTouchEvent(e);
    return true;
  }
  return false;
}
 
@Override
public boolean performClick() {
    toggle();

    final boolean handled = super.performClick();
    if (!handled) {
        // View only makes a sound effect if the onClickListener was
        // called, so we'll need to make one here instead.
        playSoundEffect(SoundEffectConstants.CLICK);
    }

    return handled;
}
 
@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;
}
 
源代码22 项目: sealrtc-android   文件: BaseBeautyBox.java
@Override
public boolean performClick() {
    toggle();
    final boolean handled = super.performClick();
    if (!handled) {
        // View only makes a sound effect if the onClickListener was
        // called, so we'll need to make one here instead.
        playSoundEffect(SoundEffectConstants.CLICK);
    }
    return handled;
}
 
源代码23 项目: Telegram   文件: PhotoAttachPhotoCell.java
@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean result = false;

    checkFrame.getHitRect(rect);
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (rect.contains((int) event.getX(), (int) event.getY())) {
            pressed = true;
            invalidate();
            result = true;
        }
    } else if (pressed) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            getParent().requestDisallowInterceptTouchEvent(true);
            pressed = false;
            playSoundEffect(SoundEffectConstants.CLICK);
            sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
            delegate.onCheckClick(this);
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
            pressed = false;
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            if (!(rect.contains((int) event.getX(), (int) event.getY()))) {
                pressed = false;
                invalidate();
            }
        }
    }
    if (!result) {
        result = super.onTouchEvent(event);
    }

    return result;
}
 
源代码24 项目: jellyfin-androidtv   文件: ItemRowView.java
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
    super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    if (gainFocus) {
        mWholeRow.setBackgroundResource(R.drawable.btn_focus);
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
        if (rowSelectedListener != null) rowSelectedListener.onRowSelected(this);
    } else {
        mWholeRow.setBackground(normalBackground);
    }
}
 
源代码25 项目: TelePlus-Android   文件: SharedAudioCell.java
private boolean checkAudioMotionEvent(MotionEvent event) {
    int x = (int) event.getX();
    int y = (int) event.getY();
    boolean result = false;
    int side = AndroidUtilities.dp(36);
    boolean area = false;
    if (miniButtonState >= 0) {
        int offset = AndroidUtilities.dp(27);
        area = x >= buttonX + offset && x <= buttonX + offset + side && y >= buttonY + offset && y <= buttonY + offset + side;
    }
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (area) {
            miniButtonPressed = true;
            invalidate();
            result = true;
            updateRadialProgressBackground();
        }
    } else if (miniButtonPressed) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            miniButtonPressed = false;
            playSoundEffect(SoundEffectConstants.CLICK);
            didPressedMiniButton(true);
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
            miniButtonPressed = false;
            invalidate();
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            if (!area) {
                miniButtonPressed = false;
                invalidate();
            }
        }
        updateRadialProgressBackground();
    }
    return result;
}
 
源代码26 项目: samples   文件: EcoGalleryAdapterView.java
/**
 * Call the OnItemClickListener, if it is defined.
 *
 * @param view     The view within the AdapterView that was clicked.
 * @param position The position of the view in the adapter.
 * @param id       The row id of the item that was clicked.
 * @return True if there was an assigned OnItemClickListener that was
 * called, false otherwise is returned.
 */
public boolean performItemClick(View view, int position, long id) {
    if (mOnItemClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        mOnItemClickListener.onItemClick(this, view, position, id);
        return true;
    }

    return false;
}
 
源代码27 项目: Lay-s   文件: PLAAdapterView.java
/**
 * Call the OnItemClickListener, if it is defined.
 *
 * @param view The view within the AdapterView that was clicked.
 * @param position The position of the view in the adapter.
 * @param id The row id of the item that was clicked.
 * @return True if there was an assigned OnItemClickListener that was
 *         called, false otherwise is returned.
 */
public boolean performItemClick(View view, int position, long id) {
	if (mOnItemClickListener != null) {
		playSoundEffect(SoundEffectConstants.CLICK);
		mOnItemClickListener.onItemClick(this, view, position, id);
		return true;
	}

	return false;
}
 
源代码28 项目: AndroidBase   文件: LazyViewPager.java
public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) currentFocused = null;

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused,
            direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_LEFT) {
            // If there is nothing to the left, or this is causing us to
            // jump to the right, then what we really want to do is page left.
            if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) {
                handled = pageLeft();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_RIGHT) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        }
    } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pageLeft();
    } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageRight();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}
 
源代码29 项目: PLDroidShortVideo   文件: BeautyBox.java
@Override
public boolean performClick() {
    toggle();

    final boolean handled = super.performClick();
    if (!handled) {
        // View only makes a sound effect if the onClickListener was
        // called, so we'll need to make one here instead.
        playSoundEffect(SoundEffectConstants.CLICK);
    }

    return handled;
}
 
源代码30 项目: CSipSimple   文件: ActionMenuPresenter.java
@Override
public boolean performClick() {
    if (super.performClick()) {
        return true;
    }

    playSoundEffect(SoundEffectConstants.CLICK);
    showOverflowMenu();
    return true;
}
 
 类所在包
 类方法
 同包方法