Java 类android.view.SoundEffectConstants 实例源码

项目:GitHub    文件:StickyRecyclerHeadersTouchListener.java   
@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;
}
项目: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;
    }
}
项目:RvAdapter    文件:StickyRecyclerHeadersTouchListener.java   
@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;
}
项目:redpacketui-open    文件:StickyRecyclerHeadersTouchListener.java   
@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;
}
项目:airgram    文件:ChatMessageCell.java   
private boolean checkOtherButtonMotionEvent(MotionEvent event) {
    if (documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT && currentMessageObject.type != 12 && documentAttachType != DOCUMENT_ATTACH_TYPE_MUSIC && documentAttachType != DOCUMENT_ATTACH_TYPE_VIDEO && documentAttachType != DOCUMENT_ATTACH_TYPE_GIF && currentMessageObject.type != 8) {
        return false;
    }

    int x = (int) event.getX();
    int y = (int) event.getY();

    boolean result = false;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (x >= otherX - dp(20) && x <= otherX + dp(20) && y >= otherY - dp(4) && y <= otherY + dp(30)) {
            otherPressed = true;
            result = true;
        }
    } else {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            if (otherPressed) {
                otherPressed = false;
                playSoundEffect(SoundEffectConstants.CLICK);
                delegate.didPressedOther(this);
            }
        }
    }
    return result;
}
项目:Hitalk    文件:StickyRecyclerHeadersTouchListener.java   
@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;
}
项目:xlight_android_native    文件:CustomViewAbove.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) {
            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;
}
项目:PlusGram    文件:ChatMessageCell.java   
private boolean checkOtherButtonMotionEvent(MotionEvent event) {
    if (documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT && currentMessageObject.type != 12 && documentAttachType != DOCUMENT_ATTACH_TYPE_MUSIC && documentAttachType != DOCUMENT_ATTACH_TYPE_VIDEO && documentAttachType != DOCUMENT_ATTACH_TYPE_GIF && currentMessageObject.type != 8 || hasGamePreview) {
        return false;
    }

    int x = (int) event.getX();
    int y = (int) event.getY();

    boolean result = false;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (x >= otherX - dp(20) && x <= otherX + dp(20) && y >= otherY - dp(4) && y <= otherY + dp(30)) {
            otherPressed = true;
            result = true;
        }
    } else {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            if (otherPressed) {
                otherPressed = false;
                playSoundEffect(SoundEffectConstants.CLICK);
                delegate.didPressedOther(this);
            }
        }
    }
    return result;
}
项目:LiuAGeAndroid    文件:CustomViewAbove.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) {
            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;
}
项目:GarageDoor    文件:GarageDoorIntentService.java   
@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Play a click sound and vibrate quickly
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    AudioManager audioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
    audioManager.playSoundEffect(SoundEffectConstants.CLICK, 1.0f);
    Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATOR_PULSE);

    try {
        Bundle data = new Bundle();
        data.putString("user",
                sharedPreferences.getString(GarageDoorWidgetProvider.PREF_USERNAME, ""));
        data.putString("password",
                sharedPreferences.getString(GarageDoorWidgetProvider.PREF_PASSWORD, ""));
        data.putString("timestamp", String.valueOf(System.currentTimeMillis() / 1000));

        String id = Integer.toString(getNextMsgId());
        gcm.send(GarageDoorWidgetProvider.GCM_SENDER_ID + "@gcm.googleapis.com",
                id, TIME_TO_LIVE, data);
    } catch (IOException e) {
        Log.e(TAG, "Error sending message", e);
    }
}
项目:FlickLauncher    文件: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;
    }
}
项目:DailyZhiHu    文件:CustomViewAbove.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) {
            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;
}
项目:SimpleUILauncher    文件: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;
    }
}
项目:WeatherStream    文件:CustomViewAbove.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) {
            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;
}
项目:rview    文件:RepositoryPageFragment.java   
private void bindPredefinedRepositoriesLink() {
    mBinding.repositoryPredefined.setMovementMethod(new LinkMovementMethod());
    String msg = getString(R.string.account_wizard_repository_page_message2);
    String link = getString(R.string.account_wizard_repository_page_message2_predefined);
    String text = String.format(Locale.getDefault(), msg, link);
    int pos = msg.indexOf("%1$s");

    // Create a clickable span
    Spannable span = Spannable.Factory.getInstance().newSpannable(text);
    if (pos >= 0) {
        span.setSpan(new ClickableSpan() {
            @Override
            public void onClick(View v) {
                // Click on span doesn't provide sound feedback it the text view doesn't
                // handle a click event. Just perform a click effect.
                v.playSoundEffect(SoundEffectConstants.CLICK);
                performOpenPredefinedRepositories();
            }
        }, pos, pos + link.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    mBinding.repositoryPredefined.setText(span);
}
项目: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);
}
项目: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);
}
项目:android-wgallery    文件:EcoGallery.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 (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);
}
项目:SimplOS    文件: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;
    }
}
项目:material-components-android    文件:Chip.java   
/**
 * Call this chip's {@link #onCloseIconClickListener}, if it is defined. Performs all normal
 * actions associated with clicking: reporting accessibility event, playing a sound, etc.
 *
 * @return True there was an assigned {@link #onCloseIconClickListener} that was called, false
 *     otherwise is returned.
 */
@CallSuper
public boolean performCloseIconClick() {
  playSoundEffect(SoundEffectConstants.CLICK);

  boolean result;
  if (onCloseIconClickListener != null) {
    onCloseIconClickListener.onClick(this);
    result = true;
  } else {
    result = false;
  }

  touchHelper.sendEventForVirtualView(
      CLOSE_ICON_VIRTUAL_ID, AccessibilityEvent.TYPE_VIEW_CLICKED);
  return result;
}
项目: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;
    }
}
项目:android-jungle-framework    文件:CommonHotTagAdapter.java   
@Override
public View getTagView(int position) {
    String tag = mTagList.get(position);
    TextView view = (TextView) View.inflate(mContext, R.layout.view_hot_tag, null);
    view.setText(tag);
    view.setTag(tag);
    view.setTextColor(ColorList.randomNextColor());
    view.setOnClickListener(mTagViewClickListener);

    if (mEditable) {
        view.setOnLongClickListener(mTagViewLongClickListener);

        view.performHapticFeedback(
                HapticFeedbackConstants.LONG_PRESS,
                HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
        view.playSoundEffect(SoundEffectConstants.CLICK);
    }

    return view;
}
项目:android-jungle-framework    文件:FavoriteLayoutView.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ItemHolder holder = null;

    if (convertView == null) {
        convertView = View.inflate(getContext(), R.layout.layout_favorite_item, null);
        holder = new ItemHolder(convertView);

        convertView.setTag(holder);
        convertView.setOnClickListener(mItemClickListener);
        convertView.setOnLongClickListener(mItemLongClickListener);

        convertView.performHapticFeedback(
                HapticFeedbackConstants.LONG_PRESS,
                HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
        convertView.playSoundEffect(SoundEffectConstants.CLICK);
    } else {
        holder = (ItemHolder) convertView.getTag();
    }

    FavoriteEntity entity = FavoriteManager.getInstance().getFavoriteEntity(position);
    holder.updateItem(entity);

    return convertView;
}
项目:android-drag-FlowLayout    文件:DragFlowLayout.java   
@Override
public boolean onSingleTapUp(MotionEvent e) {
    sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
    if (mClickListener == null) {
        return false;
    }
    //处理点击时,看起来有点怪异的感觉(控件偏离了点位置)
    removeCallbacks(mCheckForDrag);
    boolean performed = mClickListener.performClick(DragFlowLayout.this, mTouchChild, e, mDragState);
    // sDebugger.i("mGestureDetector_onSingleTapUp","----------------- > performed = " + performed);
    if (performed) {
        playSoundEffect(SoundEffectConstants.CLICK);
    } else if (mReDrag) {
        checkForDrag(0, true);
    }
    return performed;
}
项目:WebStarter    文件:TwoWayView.java   
/**
 * Scrolls to the next or previous item if possible.
 *
 * @param direction either {@link View#FOCUS_UP} or {@link View#FOCUS_DOWN} or
 *        {@link View#FOCUS_LEFT} or {@link View#FOCUS_RIGHT} depending on the
 *        current view orientation.
 *
 * @return whether selection was moved
 */
private boolean arrowScroll(int direction) {
    forceValidFocusDirection(direction);

    try {
        mInLayout = true;

        final boolean handled = arrowScrollImpl(direction);
        if (handled) {
            playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
        }

        return handled;
    } finally {
        mInLayout = false;
    }
}
项目:Android-MuPDF_as    文件:TwoWayView.java   
/**
 * Scrolls to the next or previous item if possible.
 *
 * @param direction either {@link View#FOCUS_UP} or {@link View#FOCUS_DOWN} or
 *        {@link View#FOCUS_LEFT} or {@link View#FOCUS_RIGHT} depending on the
 *        current view orientation.
 *
 * @return whether selection was moved
 */
private boolean arrowScroll(int direction) {
    forceValidFocusDirection(direction);

    try {
        mInLayout = true;

        final boolean handled = arrowScrollImpl(direction);
        if (handled) {
            playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
        }

        return handled;
    } finally {
        mInLayout = false;
    }
}
项目:Carbon    文件:CheckBox.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;
}
项目:EngineDriver    文件:throttle.java   
@Override
public boolean onTouch(View v, MotionEvent event) {
    // Log.d("Engine_Driver", "onTouch func " + function + " action " +
    // event.getAction());

    // make the click sound once
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        v.playSoundEffect(SoundEffectConstants.CLICK);
    }

    // if gesture in progress, skip button processing
    if (gestureInProgress) {
        return (true);
    }

    // if gesture just failed, insert one DOWN event on this control
    if (gestureFailed) {
        handleAction(MotionEvent.ACTION_DOWN);
        gestureFailed = false;  // just do this once
    }
    handleAction(event.getAction());
    return (true);
}
项目:FLauncher    文件: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;
    }
}
项目:ischool-oppia-mobile    文件:TwoWayView.java   
/**
 * Scrolls to the next or previous item if possible.
 *
 * @param direction either {@link View#FOCUS_UP} or {@link View#FOCUS_DOWN} or
 *        {@link View#FOCUS_LEFT} or {@link View#FOCUS_RIGHT} depending on the
 *        current view orientation.
 *
 * @return whether selection was moved
 */
private boolean arrowScroll(int direction) {
    forceValidFocusDirection(direction);

    try {
        mInLayout = true;

        final boolean handled = arrowScrollImpl(direction);
        if (handled) {
            playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
        }

        return handled;
    } finally {
        mInLayout = false;
    }
}
项目:soulissapp    文件:EcoGallery.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 (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);
}
项目:NHentai-android    文件:TwoWayAdapterView.java   
/**
 * Call the OnItemClickListener, if it is defined. Performs all normal
 * actions associated with clicking: reporting accessibility event, playing
 * a sound, etc.
 *
 * @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) {
    final boolean result;
    if (mOnItemClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        mOnItemClickListener.onItemClick(this, view, position, id);
        result = true;
    } else {
        result = false;
    }

    if (view != null) {
        view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
    }
    return result;
}
项目:konkeWatch    文件:TosGallery.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);
}
项目:KUAS-AP-Material    文件:PinnedSectionListView.java   
private boolean performPinnedItemClick() {
    if (mPinnedSection == null) {
        return false;
    }

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null && getAdapter().isEnabled(mPinnedSection.position)) {
        View view = mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}
项目:KUAS-AP-Material    文件:PinnedSectionListView.java   
private boolean performPinnedItemClick() {
    if (mPinnedSection == null) {
        return false;
    }

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null && getAdapter().isEnabled(mPinnedSection.position)) {
        View view = mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}
项目:MoneyRecord    文件:TosGallery.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 (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);
}
项目:shikimori    文件:PinnedSectionGridView.java   
private boolean performPinnedItemClick() {
    if (mPinnedSection == null)
        return false;

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null) {
        View view = mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}
项目:shikimori    文件:PinnedSectionListView.java   
private boolean performPinnedItemClick() {
    if (mPinnedSection == null)
        return false;

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null) {
        View view = mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}
项目:mc_backup    文件:TwoWayView.java   
/**
 * Scrolls to the next or previous item if possible.
 *
 * @param direction either {@link View#FOCUS_UP} or {@link View#FOCUS_DOWN} or
 *        {@link View#FOCUS_LEFT} or {@link View#FOCUS_RIGHT} depending on the
 *        current view orientation.
 *
 * @return whether selection was moved
 */
private boolean arrowScroll(int direction) {
    forceValidFocusDirection(direction);

    try {
        mInLayout = true;

        final boolean handled = arrowScrollImpl(direction);
        if (handled) {
            playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
        }

        return handled;
    } finally {
        mInLayout = false;
    }
}
项目:ProjectX    文件:BaseTabStrip.java   
/**
 * 点击
 *
 * @param position       位置
 * @param smoothScroll   是否平滑滚动
 * @param notifyListener 是否通知监听器
 * @return 点击成功
 */
public boolean performClick(int position, boolean smoothScroll, boolean notifyListener) {
    if (getViewPager() != null && position >= 0 && position < getItemCount()) {
        clickSelectedItem = position == mPosition;
        mPosition = position;
        if (!clickSelectedItem) {
            if (!smoothScroll) {
                mCurrentPager = position;
                mLastKnownPosition = mCurrentPager;
                mLastKnownPositionOffset = 0;
                jumpTo(mCurrentPager);
                notifyJumpTo(mCurrentPager);
            }
            getViewPager().setCurrentItem(position, smoothScroll);
        }
        if (clickListener != null && notifyListener) {
            clickListener.onItemClick(mPosition);
        }
        playSoundEffect(SoundEffectConstants.CLICK);
        return true;
    }
    return false;
}