コード例 #1
0
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

    // Manually update volume levels and textviews if the user manually moved the seekbar
    if (fromUser) {
      if (isBalanced) {
        updateLabel(progress + minLevel, progress + minLevel);
        headphoneAmpControl.setLevel(
            progress + minLevel,
            progress
                + minLevel); // Comment for non-immediate level change. See onStopTrackingTouch().
      } else {
        switch (seekBar.getId()) {
          case R.id.seekBar_main:
            updateLabel(progress + minLevel, seekBarMainRight.getProgress() + minLevel);
            headphoneAmpControl.setLevel(
                progress + minLevel,
                seekBarMainRight.getProgress()
                    + minLevel); // Comment for non-immediate level change. See
            // onStopTrackingTouch().
            break;
          case R.id.seekBar_mainRight:
            updateLabel(seekBarMain.getProgress() + minLevel, progress + minLevel);
            headphoneAmpControl.setLevel(
                seekBarMain.getProgress() + minLevel,
                progress + minLevel); // Comment for non-immediate level change. See
            // onStopTrackingTouch().
            break;
        }
      }
    }
  }
コード例 #2
0
  /** Rebuild main seekbars with values from the system files and preferences */
  public void rebuildSeekbar() {
    headphoneAmpControl.getLevelsFromFile();
    int currentLevelL = headphoneAmpControl.getCurrentLevelL();
    int currentLevelR = headphoneAmpControl.getCurrentLevelR();

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    minLevel = sp.getInt(MainActivity.SEEKBAR_MIN_LEVEL, MIN_LEVEL);
    maxLevel = sp.getInt(MainActivity.SEEKBAR_MAX_LEVEL, MAX_LEVEL);

    seekBarMain.setMax(maxLevel - minLevel);
    seekBarMainRight.setMax(maxLevel - minLevel);

    // Enforce safety levels
    if (currentLevelL > maxLevel) {
      currentLevelL = maxLevel;
    } else if (currentLevelL < minLevel) {
      currentLevelL = minLevel;
    }
    if (currentLevelR > maxLevel) {
      currentLevelR = maxLevel;
    } else if (currentLevelR < minLevel) {
      currentLevelR = minLevel;
    }

    // Determine visibility of right level seekbar
    if (isBalanced) {
      seekBarMainRight.setVisibility(View.GONE);
      textViewLevelRight.setVisibility(View.GONE);

      currentLevelR = currentLevelL;
      headphoneAmpControl.setLevel(currentLevelL, currentLevelR);
      updateSeekbar(currentLevelL, currentLevelR);
      updateLabel(currentLevelL, currentLevelR);
    } else {
      seekBarMainRight.setVisibility(View.VISIBLE);
      textViewLevelRight.setVisibility(View.VISIBLE);

      headphoneAmpControl.setLevel(currentLevelL, currentLevelR);
      updateSeekbar(currentLevelL, currentLevelR);
      updateLabel(currentLevelL, currentLevelR);
    }
  }