@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { // for java.lang.ClassCastException Object tag = seekBar.getTag(); int n; if (tag instanceof Integer) n = (Integer) tag; else if (tag instanceof String) n = Integer.parseInt((String) tag); else throw new IllegalArgumentException("wtf exception"); TextView textView; try { textView = (TextView) this.getClass().getDeclaredField("text" + String.valueOf(n)).get(this); textView.setText( String.format("%.0f db", EqualizerBandsFragment.convertProgressToGain(progress))); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } saveBound(progress, n); BassPlayer.updateFX(progress, n); } }
@Override public void onResume() { super.onResume(); int[] bounds = getSavedBounds(); for (int i = 0; i < bounds.length; i++) { try { SeekBar seekBar = (SeekBar) this.getClass().getDeclaredField("seek" + String.valueOf(i)).get(this); seekBar.setProgress(bounds[i]); TextView textView = (TextView) this.getClass().getDeclaredField("text" + String.valueOf(i)).get(this); textView.setText( String.format("%.1f db", EqualizerBandsFragment.convertProgressToGain(bounds[i]))); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } }