Exemplo n.º 1
0
 public void savePreset() {
   final int sbOne = sb1.getProgress();
   final int sbTwo = sb2.getProgress();
   final int sbThree = sb3.getProgress();
   final int sbFour = sb4.getProgress();
   final int sbFive = sb5.getProgress();
   final int skOne = sk1.getProgress();
   final int skTwo = sk2.getProgress();
   final String preset = presetsSpinner.getSelectedItem().toString().trim();
   Editor editor = prefs.edit();
   editor.putBoolean(EQUALIZER_SAVE, true);
   editor.putString(EQUALIZER_PRESET, preset);
   if ("Custom".equals(preset)) {
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_ONE, sbOne);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_TWO, sbTwo);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_THREE, sbThree);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FOUR, sbFour);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FIVE, sbFive);
     editor.putInt(EQUALIZER_SEEKBAR_CUSTOM_ONE, skOne);
     editor.putInt(EQUALIZER_SEEKBAR_CUSTOM_TWO, skTwo);
   } else {
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_ONE, sbOne);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_TWO, sbTwo);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_THREE, sbThree);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_FOUR, sbFour);
     editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_FIVE, sbFive);
     editor.putInt(EQUALIZER_SEEKBAR_ONE, skOne);
     editor.putInt(EQUALIZER_SEEKBAR_TWO, skTwo);
   }
   editor.apply();
 }
Exemplo n.º 2
0
 public void setSavedPreset() {
   final int sbOne, sbTwo, sbThree, sbFour, sbFive, skOne, skTwo;
   if ("Custom".equals(presetsSpinner.getSelectedItem())) {
     sbOne = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_ONE, 0);
     sbTwo = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_TWO, 0);
     sbThree = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_THREE, 0);
     sbFour = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FOUR, 0);
     sbFive = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FIVE, 0);
     skOne = prefs.getInt(EQUALIZER_SEEKBAR_CUSTOM_ONE, 0);
     skTwo = prefs.getInt(EQUALIZER_SEEKBAR_CUSTOM_TWO, 0);
   } else {
     sbOne = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_ONE, 0);
     sbTwo = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_TWO, 0);
     sbThree = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_THREE, 0);
     sbFour = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_FOUR, 0);
     sbFive = prefs.getInt(EQUALIZER_VERTICAL_SEEKBAR_FIVE, 0);
     skOne = prefs.getInt(EQUALIZER_SEEKBAR_ONE, 0);
     skTwo = prefs.getInt(EQUALIZER_SEEKBAR_TWO, 0);
   }
   sb1.setProgressAndThumb(sbOne);
   sb2.setProgressAndThumb(sbTwo);
   sb3.setProgressAndThumb(sbThree);
   sb4.setProgressAndThumb(sbFour);
   sb5.setProgressAndThumb(sbFive);
   Utils.changeAtBand(equalizer, band1, sbOne - 15);
   Utils.changeAtBand(equalizer, band2, sbTwo - 15);
   Utils.changeAtBand(equalizer, band2, sbThree - 15);
   Utils.changeAtBand(equalizer, band3, sbFour - 15);
   Utils.changeAtBand(equalizer, band4, sbFive - 15);
   presetsSpinner.setSelection(0);
   Toast.makeText(getApplicationContext(), R.string.user, Toast.LENGTH_SHORT).show();
   sk1.setProgress(skOne);
   sk2.setProgress(skTwo);
   dbChangePg(sbOne, sbTwo, sbThree, sbFour, sbFive, 0, skOne, skTwo);
 }
Exemplo n.º 3
0
 private void setValues(TextView sbP, VerticalSeekBar sb, short band, int progress) {
   if ("Custom".equals(presetsSpinner.getSelectedItem())) {
     sbP.setText(Integer.toString(progress - 15));
     sb.setProgress(progress);
     Utils.changeAtBand(equalizer, band, progress - 15);
   } else {
     sbP.setText(Integer.toString(progress));
     sb.setProgress(progress + 15);
     Utils.changeAtBand(equalizer, band, progress);
   }
 }
Exemplo n.º 4
0
 public void setEqualizerPreset(Short preset, int p1, int p2, int p3, int p4, int p5) {
   try {
     equalizer.usePreset(preset);
   } catch (Throwable e) {
     e.printStackTrace();
   }
   sb1.setProgressAndThumb(15 + p1);
   sb2.setProgressAndThumb(15 + p2);
   sb3.setProgressAndThumb(15 + p3);
   sb4.setProgressAndThumb(15 + p4);
   sb5.setProgressAndThumb(15 + p5);
 }
Exemplo n.º 5
0
  private void enableAll() {

    sb1.setEnabled(true);
    sb2.setEnabled(true);
    sb3.setEnabled(true);
    sb4.setEnabled(true);
    sb5.setEnabled(true);

    sk1.setEnabled(true);
    sk2.setEnabled(true);

    presetsSpinner.setEnabled(true);
  }
Exemplo n.º 6
0
  private void disableAll() {

    sb1.setEnabled(false);
    sb2.setEnabled(false);
    sb3.setEnabled(false);
    sb4.setEnabled(false);
    sb5.setEnabled(false);

    sk1.setEnabled(false);
    sk2.setEnabled(false);

    presetsSpinner.setEnabled(false);
  }
Exemplo n.º 7
0
 @Override
 public void onStopTrackingTouch(SeekBar seekBar) {
   if (presetsSpinner.getSelectedItem().equals("Custom")) {
     savePreset();
     dbChangePg(
         sb1.getProgress(),
         sb2.getProgress(),
         sb3.getProgress(),
         sb4.getProgress(),
         sb5.getProgress(),
         presetsSpinner.getSelectedItemPosition(),
         sk1pgs,
         sk2pgs);
   }
 }
Exemplo n.º 8
0
  public void initEqualizer() {

    sbP1 = (TextView) findViewById(R.id.textViewSB1);
    sbP2 = (TextView) findViewById(R.id.textViewSB2);
    sbP3 = (TextView) findViewById(R.id.textViewSB3);
    sbP4 = (TextView) findViewById(R.id.textViewSB4);
    sbP5 = (TextView) findViewById(R.id.textViewSB5);

    sb1.setOnSeekBarChangeListener(this);
    sb2.setOnSeekBarChangeListener(this);
    sb3.setOnSeekBarChangeListener(this);
    sb4.setOnSeekBarChangeListener(this);
    sb5.setOnSeekBarChangeListener(this);

    sk1.setOnSeekBarChangeListener(this);
    sk2.setOnSeekBarChangeListener(this);
    if (getEqualizer() == null || getBassBoost() == null || getVirtualizer() == null) return;
    presetsAdapter =
        new ArrayAdapter<>(
            this,
            android.R.layout.simple_spinner_dropdown_item,
            getResources().getStringArray(R.array.presets));
    presetsSpinner.setAdapter(presetsAdapter);
    presetsSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (null != view) {
              setPreset(((TextView) view).getText().toString());
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
    testMethod();
    setPresets();
  }