android.view.HapticFeedbackConstants Java Examples

The following examples show how to use android.view.HapticFeedbackConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlarmConfigFragment.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
private void initDelete() {
    mDelete.setOnClickListener(v -> new AlertDialog.Builder(getActivity())
            .setTitle(mTimes.getName())
            .setMessage(getString(R.string.delAlarmConfirm, mAlarm.getTitle()))
            .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
            .setPositiveButton(R.string.yes, (dialog, which) -> {
                mTimes.getUserAlarms().remove(mAlarm);
                dismiss();
            }).show());

    if (BuildConfig.DEBUG)
        mDelete.setOnLongClickListener(v -> {
            getActivity().getWindow().getDecorView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
            AlarmService.setAlarm(getActivity(), new Pair<>(mAlarm, LocalDateTime.now().plusSeconds(5)));
            return true;
        });

}
 
Example #2
Source File: Tools.java    From RemoteControlView with Apache License 2.0 6 votes vote down vote up
public static void startDrag(View view){
    DraggableInfo tag = (DraggableInfo) view.getTag();
    if (tag == null){
        tag = new DraggableInfo("Text", 0, 0, 1);
    }
    Intent intent = new Intent();
    intent.putExtra("data", tag);
    ClipData dragData = ClipData.newIntent("value", intent);
    View.DragShadowBuilder myShadow = new View.DragShadowBuilder(view);
    // 震动反馈,不需要震动权限
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        view.startDragAndDrop(dragData, myShadow, null, 0);
    }else{
        view.startDrag(dragData, myShadow, null, 0);
    }
}
 
Example #3
Source File: EcoGallery.java    From samples with Apache License 2.0 6 votes vote down vote up
private boolean dispatchLongPress(View view, int position, long id) {
    boolean handled = false;

    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(this, mDownTouchView, mDownTouchPosition, id);
    }

    if (!handled) {
        mContextMenuInfo = new AdapterContextMenuInfo(view, position, id);
        handled = super.showContextMenuForChild(this);
    }

    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example #4
Source File: RepeatableImageKey.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}
 
Example #5
Source File: EntityView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public EntityView(Context context, Point pos) {
    super(context);

    uuid = UUID.randomUUID();
    position = pos;

    gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        public void onLongPress(MotionEvent e) {
            if (hasPanned || hasTransformed || hasReleased) {
                return;
            }

            recognizedLongPress = true;
            if (delegate != null) {
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                delegate.onEntityLongClicked(EntityView.this);
            }
        }
    });
}
 
Example #6
Source File: EntityView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public EntityView(Context context, Point pos) {
    super(context);

    uuid = UUID.randomUUID();
    position = pos;

    gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        public void onLongPress(MotionEvent e) {
            if (hasPanned || hasTransformed || hasReleased) {
                return;
            }

            recognizedLongPress = true;
            if (delegate != null) {
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                delegate.onEntityLongClicked(EntityView.this);
            }
        }
    });
}
 
Example #7
Source File: TouchNavigationMethod.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public boolean onDown(MotionEvent e) {
    int x = screenToViewX((int) e.getX());
    int y = screenToViewY((int) e.getY());
    _isCaretTouched = isNearChar(x, y, _textField.getCaretPosition());

    if (_textField.isFlingScrolling()) {
        _textField.stopFlingScrolling();
    } else if (_textField.isSelectText()) {
        if (isNearChar(x, y, _textField.getSelectionStart())) {
            _textField.focusSelectionStart();
            _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            _isCaretTouched = true;
        } else if (isNearChar(x, y, _textField.getSelectionEnd())) {
            _textField.focusSelectionEnd();
            _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            _isCaretTouched = true;
        }
    }

    if (_isCaretTouched) {
        _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return true;
}
 
Example #8
Source File: TouchNavigationMethod.java    From CodeEditor with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onDown(MotionEvent e) {
    int x = screenToViewX((int) e.getX());
    int y = screenToViewY((int) e.getY());
    _isCaretTouched = isNearChar(x, y, _textField.getCaretPosition());

    if (_textField.isFlingScrolling()) {
        _textField.stopFlingScrolling();
    } else if (_textField.isSelectText()) {
        if (isNearChar(x, y, _textField.getSelectionStart())) {
            _textField.focusSelectionStart();
            _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            _isCaretTouched = true;
        } else if (isNearChar(x, y, _textField.getSelectionEnd())) {
            _textField.focusSelectionEnd();
            _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            _isCaretTouched = true;
        }
    }

    if (_isCaretTouched) {
        _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return true;
}
 
Example #9
Source File: TrackSelectionAdapterWrapper.java    From ticdesign with Apache License 2.0 6 votes vote down vote up
boolean performLongPress(final View child,
                         final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL) {
        if (mChoiceActionMode == null) {
            setItemChecked(longPressPosition, true);
            child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        }
        return true;
    }

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(this, child,
                longPressPosition, longPressId);
    }
    if (handled) {
        child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example #10
Source File: CabbageContributorsWedge.java    From Status with Apache License 2.0 6 votes vote down vote up
@Override
public void bind(Context context, final ViewHolder viewHolder) {
    super.bind(context, viewHolder);
    viewHolder.itemView.findViewById(R.id.first).setOnLongClickListener(v -> {
        v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        Glide.with(v.getContext()).load(CABBAGE_URL).into(new SimpleTarget<Drawable>() {
            @Override
            public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                ImageView imageView = viewHolder.itemView.findViewById(R.id.firstImage);
                if (imageView != null)
                    imageView.setImageDrawable(resource);
            }
        });

        return false;
    });
}
 
Example #11
Source File: ChatAdapter.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private void checkForLink(String message, SpannableStringBuilder spanbuilder) {
    Matcher linkMatcher = Patterns.WEB_URL.matcher(message);
    while (linkMatcher.find()) {
        String url = linkMatcher.group(0);

        if (!url.matches("^https?://.+"))
            url = "http://" + url;

        final String finalUrl = url;
        ClickableSpan clickableSpan = new ClickableSpan() {
            @Override
            public void onClick(View view) {
                CustomTabsIntent.Builder mTabs = new CustomTabsIntent.Builder();
                mTabs.setStartAnimations(context, R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
                mTabs.setExitAnimations(context, R.anim.fade_in_semi_anim, R.anim.slide_out_bottom_anim);
                mTabs.build().launchUrl(context, Uri.parse(finalUrl));

                mRecyclerView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
            }
        };

        spanbuilder.setSpan(clickableSpan, linkMatcher.start(), linkMatcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
Example #12
Source File: TouchNavigationMethod.java    From CodeEditor with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onDown(MotionEvent e) {
    int x = screenToViewX((int) e.getX());
    int y = screenToViewY((int) e.getY());
    _isCaretTouched = isNearChar(x, y, _textField.getCaretPosition());

    if (_textField.isFlingScrolling()) {
        _textField.stopFlingScrolling();
    } else if (_textField.isSelectText()) {
        if (isNearChar(x, y, _textField.getSelectionStart())) {
            _textField.focusSelectionStart();
            _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            _isCaretTouched = true;
        } else if (isNearChar(x, y, _textField.getSelectionEnd())) {
            _textField.focusSelectionEnd();
            _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            _isCaretTouched = true;
        }
    }

    if (_isCaretTouched) {
        _textField.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return true;
}
 
Example #13
Source File: MainActivity.java    From FloatingSearchView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_clear:
            mSearchView.setText(null);
            mSearchView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
            break;
        case R.id.menu_toggle_icon:
            item.setChecked(!item.isChecked());
            mSearchView.showIcon(item.isChecked());
            break;
        case R.id.menu_tts:
            PackageUtils.startTextToSpeech(this, getString(R.string.speech_prompt), REQ_CODE_SPEECH_INPUT);
            break;
        case R.id.menu_icon_search:
        case R.id.menu_icon_drawer:
        case R.id.menu_icon_custom:
            updateNavigationIcon(item.getItemId());
            Toast.makeText(MainActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
            break;
    }
    return true;
}
 
Example #14
Source File: ChatAdapter.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
private void checkForLink(String message, SpannableStringBuilder spanbuilder) {
	linkMatcher = linkPattern.matcher(message);
	while(linkMatcher.find()) {
		final String url = linkMatcher.group(1);

		ClickableSpan clickableSpan = new ClickableSpan() {
			@Override
			public void onClick(View view) {
				CustomTabsIntent.Builder mTabs = new CustomTabsIntent.Builder();
				mTabs.setStartAnimations(context, R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
				mTabs.setExitAnimations(context, R.anim.fade_in_semi_anim, R.anim.slide_out_bottom_anim);
				mTabs.build().launchUrl(context, Uri.parse(url));

				mRecyclerView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
			}
		};

		int start = message.indexOf(url);
		spanbuilder.setSpan(clickableSpan, start, start + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
	}
}
 
Example #15
Source File: Gallery.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private boolean dispatchLongPress(View view, int position, long id, float x, float y,
        boolean useOffsets) {
    boolean handled = false;
    
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(this, mDownTouchView,
                mDownTouchPosition, id);
    }

    if (!handled) {
        mContextMenuInfo = new AdapterContextMenuInfo(view, position, id);

        if (useOffsets) {
            handled = super.showContextMenuForChild(view, x, y);
        } else {
            handled = super.showContextMenuForChild(this);
        }
    }

    if (handled) {
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }
    
    return handled;
}
 
Example #16
Source File: HorizontalListView.java    From RxZhihuDaily with MIT License 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                    .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example #17
Source File: HorizontalListView.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    unpressTouchedChild();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());
    if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        OnItemLongClickListener onItemLongClickListener = getOnItemLongClickListener();
        if (onItemLongClickListener != null) {
            int adapterIndex = mLeftViewAdapterIndex + index;
            boolean handled = onItemLongClickListener.onItemLongClick(HorizontalListView.this, child, adapterIndex, mAdapter
                    .getItemId(adapterIndex));

            if (handled) {
                // BZZZTT!!1!
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
    }
}
 
Example #18
Source File: Tool.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
public static void vibrate(View view) {
    Vibrator vibrator = (Vibrator) view.getContext().getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator == null) {
        // some manufacturers do not vibrate on long press
        // might as well make this a fallback method
        view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        vibrator.vibrate(VibrationEffect.createOneShot(50, 160));
    } else {
        vibrator.vibrate(50);
    }
}
 
Example #19
Source File: EqualizerActivity.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekArc arg0, int arg1, boolean arg2) {
    virtualizerLevel = (short) arg1;
    if (mApp.isServiceRunning()) {
        mApp.getService().getEqualizerHelper().getVirtualizer().setStrength((short) virtualizerLevel);
    }
    float angle = ((float) arg1 / 1000) * 280;
    mImageButtonVirtualizer.setRotation(angle);

    if ((arg1 == 5 || arg1 == 990) && arg2) {
        arg0.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }
}
 
Example #20
Source File: SwipeSwitchLayout.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void innerNestedScroll(int dxUnconsumed) {
    if (Math.abs(nestedScrollingDistance) >= nestedScrollingTrigger) {
        swipeDistance -= dxUnconsumed;
    } else {
        nestedScrollingDistance -= dxUnconsumed;
        swipeDistance -= dxUnconsumed / 10f;
        if (Math.abs(nestedScrollingDistance) >= nestedScrollingTrigger) {
            performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        }
    }
    setTranslation(swipeTrigger, NESTED_SCROLLING_RATIO);
}
 
Example #21
Source File: ClickHelper.java    From Virtualview-Android with MIT License 5 votes vote down vote up
@Override
public void run() {
    if (!mClickFinished && null != mView) {
        boolean ret = mView.click(mStartX, mStartY, true);
        if (ret && mHolderView != null) {
            mLongClickPressed = true;
            mHolderView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        }
    }
}
 
Example #22
Source File: EqualizerActivity.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar arg0, int seekBarLevel, boolean changedByUser) {
    try {
        short twelvePointFiveKiloHertzBand = mApp.getService().getEqualizerHelper().getEqualizer().getBand(9000000);
        if (seekBarLevel == 16) {
            e12_5HzTextView.setText("0 dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twelvePointFiveKiloHertzBand, (short) 0);
        } else if (seekBarLevel < 16) {
            if (seekBarLevel == 0) {
                e12_5HzTextView.setText("-" + "15 dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twelvePointFiveKiloHertzBand, (short) (-1500));
            } else {
                e12_5HzTextView.setText("-" + (16 - seekBarLevel) + " dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twelvePointFiveKiloHertzBand, (short) -((16 - seekBarLevel) * 100));
            }

        } else if (seekBarLevel > 16) {
            e12_5HzTextView.setText("+" + (seekBarLevel - 16) + " dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twelvePointFiveKiloHertzBand, (short) ((seekBarLevel - 16) * 100));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if ((seekBarLevel == 31 || seekBarLevel == 0) && changedByUser) {
        arg0.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }
    twelvePointFiveKilohertzLevel = seekBarLevel;
}
 
Example #23
Source File: ChatBaseCell.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
public void run() {
    if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) {
        if (delegate != null) {
            checkingForLongPress = false;
            MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
            onTouchEvent(event);
            event.recycle();
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            delegate.didLongPressed(ChatBaseCell.this);
        }
    }
}
 
Example #24
Source File: EqualizerActivity.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar arg0, int seekBarLevel, boolean changedByUser) {
    try {
        short fiveKiloHertzBand = mApp.getService().getEqualizerHelper().getEqualizer().getBand(5000000);
        if (seekBarLevel == 16) {
            e5kHzTextView.setText("0 dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fiveKiloHertzBand, (short) 0);
        } else if (seekBarLevel < 16) {
            if (seekBarLevel == 0) {
                e5kHzTextView.setText("-" + "15 dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fiveKiloHertzBand, (short) (-1500));
            } else {
                e5kHzTextView.setText("-" + (16 - seekBarLevel) + " dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fiveKiloHertzBand, (short) -((16 - seekBarLevel) * 100));
            }

        } else if (seekBarLevel > 16) {
            e5kHzTextView.setText("+" + (seekBarLevel - 16) + " dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fiveKiloHertzBand, (short) ((seekBarLevel - 16) * 100));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if ((seekBarLevel == 31 || seekBarLevel == 0) && changedByUser) {
        arg0.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }
    fiveKilohertzLevel = seekBarLevel;
}
 
Example #25
Source File: EqualizerActivity.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar arg0, int seekBarLevel, boolean changedByUser) {
    try {
        short fourteenKiloHertzBand = mApp.getService().getEqualizerHelper().getEqualizer().getBand(2000000);
        if (seekBarLevel == 16) {
            e2kHzTextView.setText("0 dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fourteenKiloHertzBand, (short) 0);
        } else if (seekBarLevel < 16) {

            if (seekBarLevel == 0) {
                e2kHzTextView.setText("-" + "15 dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fourteenKiloHertzBand, (short) (-1500));
            } else {
                e2kHzTextView.setText("-" + (16 - seekBarLevel) + " dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fourteenKiloHertzBand, (short) -((16 - seekBarLevel) * 100));
            }

        } else if (seekBarLevel > 16) {
            e2kHzTextView.setText("+" + (seekBarLevel - 16) + " dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(fourteenKiloHertzBand, (short) ((seekBarLevel - 16) * 100));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if ((seekBarLevel == 31 || seekBarLevel == 0) && changedByUser) {
        arg0.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }
    twoKilohertzLevel = seekBarLevel;
}
 
Example #26
Source File: EqualizerActivity.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar arg0, int seekBarLevel, boolean changedByUser) {
    try {
        //Get the appropriate equalizer band.
        short threeKiloHertzBand = mApp.getService().getEqualizerHelper().getEqualizer().getBand(800000);
        //Set the gain level text based on the slider position.
        if (seekBarLevel == 16) {
            e800HzTextView.setText("0 dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(threeKiloHertzBand, (short) 0);
        } else if (seekBarLevel < 16) {
            if (seekBarLevel == 0) {
                e800HzTextView.setText("-" + "15 dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(threeKiloHertzBand, (short) (-1500));
            } else {
                e800HzTextView.setText("-" + (16 - seekBarLevel) + " dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(threeKiloHertzBand, (short) -((16 - seekBarLevel) * 100));
            }

        } else if (seekBarLevel > 16) {
            e800HzTextView.setText("+" + (seekBarLevel - 16) + " dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(threeKiloHertzBand, (short) ((seekBarLevel - 16) * 100));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if ((seekBarLevel == 31 || seekBarLevel == 0) && changedByUser) {
        arg0.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }
    eightHundredHertzLevel = seekBarLevel;
}
 
Example #27
Source File: AlarmConfigFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
private void initTimes() {
    for (int i = 0; i < 6; i++) {
        final Vakit time = Vakit.getByIndex(i);
        mTimesText[i].setText(time.getString());

        setTime(time, isTime(time));

        mTimesViews[i].setOnClickListener(v -> {
            getActivity().getWindow().getDecorView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
            setTime(time, !isTime(time));
        });
    }
}
 
Example #28
Source File: EqualizerActivity.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar arg0, int seekBarLevel, boolean changedByUser) {

    try {
        //Get the appropriate equalizer band.
        short twoThirtyHertzBand = mApp.getService().getEqualizerHelper().getEqualizer().getBand(130000);

        //Set the gain level text based on the slider position.
        if (seekBarLevel == 16) {
            e130HzTextView.setText("0 dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twoThirtyHertzBand, (short) 0);
        } else if (seekBarLevel < 16) {
            if (seekBarLevel == 0) {
                e130HzTextView.setText("-" + "15 dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twoThirtyHertzBand, (short) (-1500));
            } else {
                e130HzTextView.setText("-" + (16 - seekBarLevel) + " dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twoThirtyHertzBand, (short) -((16 - seekBarLevel) * 100));
            }

        } else if (seekBarLevel > 16) {
            e130HzTextView.setText("+" + (seekBarLevel - 16) + " dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(twoThirtyHertzBand, (short) ((seekBarLevel - 16) * 100));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if ((seekBarLevel == 31 || seekBarLevel == 0) && changedByUser) {
        arg0.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }
    oneThirtyHertzLevel = seekBarLevel;
}
 
Example #29
Source File: EqualizerActivity.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar arg0, int seekBarLevel, boolean changedByUser) {
    try {
        short sixtyHertzBand = mApp.getService().getEqualizerHelper().getEqualizer().getBand(50000);
        if (seekBarLevel == 16) {
            e50HzTextView.setText("0 dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(sixtyHertzBand, (short) 0);
        } else if (seekBarLevel < 16) {
            if (seekBarLevel == 0) {
                e50HzTextView.setText("-" + "15 dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(sixtyHertzBand, (short) (-1500));

            } else {
                e50HzTextView.setText("-" + (16 - seekBarLevel) + " dB");
                mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(sixtyHertzBand, (short) -((16 - seekBarLevel) * 100));
            }
        } else if (seekBarLevel > 16) {
            e50HzTextView.setText("+" + (seekBarLevel - 16) + " dB");
            mApp.getService().getEqualizerHelper().getEqualizer().setBandLevel(sixtyHertzBand, (short) ((seekBarLevel - 16) * 100));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    if ((seekBarLevel == 31 || seekBarLevel == 0) && changedByUser) {
        arg0.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }

    Logger.log("LEVEL " + seekBarLevel);

    fiftyHertzLevel = seekBarLevel;

}
 
Example #30
Source File: RepeatableImageKey.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, ViewConfiguration.getKeyRepeatTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}