FileDocCategorySizeDatePackage
BassBoostTest.javaAPI DocAndroid 5.1 API9752Thu Mar 12 22:22:30 GMT 2015com.android.effectstest

BassBoostTest

public class BassBoostTest extends android.app.Activity implements android.widget.CompoundButton.OnCheckedChangeListener

Fields Summary
private static final String
TAG
private static int
NUM_PARAMS
private EffectParameter
mStrength
private android.media.audiofx.BassBoost
mBassBoost
android.widget.ToggleButton
mOnOffButton
android.widget.ToggleButton
mReleaseButton
android.widget.EditText
mSessionText
static int
sSession
EffectListner
mEffectListener
private static HashMap
sInstances
String
mSettings
private View.OnKeyListener
mSessionKeyListener
Constructors Summary
public BassBoostTest()


      
        Log.d(TAG, "contructor");
    
Methods Summary
private voidgetEffect(int session)

        synchronized (sInstances) {
            if (sInstances.containsKey(session)) {
                mBassBoost = sInstances.get(session);
            } else {
                try{
                    mBassBoost = new BassBoost(0, session);
                } catch (IllegalArgumentException e) {
                    Log.e(TAG,"BassBoost effect not supported");
                } catch (IllegalStateException e) {
                    Log.e(TAG,"BassBoost cannot get strength supported");
                } catch (UnsupportedOperationException e) {
                    Log.e(TAG,"BassBoost library not loaded");
                } catch (RuntimeException e) {
                    Log.e(TAG,"BassBoost effect not found");
                }
                sInstances.put(session, mBassBoost);
            }
            mReleaseButton.setEnabled(false);
            mOnOffButton.setEnabled(false);

            if (mBassBoost != null) {
                if (mSettings != "") {
                    mBassBoost.setProperties(new BassBoost.Settings(mSettings));
                }
                mBassBoost.setEnableStatusListener(mEffectListener);
                mBassBoost.setControlStatusListener(mEffectListener);
                mBassBoost.setParameterListener(mEffectListener);

                mReleaseButton.setChecked(true);
                mReleaseButton.setEnabled(true);

                mOnOffButton.setChecked(mBassBoost.getEnabled());
                mOnOffButton.setEnabled(true);
            }
        }
    
public voidonCheckedChanged(android.widget.CompoundButton buttonView, boolean isChecked)


    // OnCheckedChangeListener
          
        if (buttonView.getId() == R.id.bassboostOnOff) {
            if (mBassBoost != null) {
                mBassBoost.setEnabled(isChecked);
                mStrength.updateDisplay();
            }
        }
        if (buttonView.getId() == R.id.bbReleaseButton) {
            if (isChecked) {
                if (mBassBoost == null) {
                    getEffect(sSession);
                    if (mBassBoost != null) {
                        mStrength.setEffect(mBassBoost);
                        mStrength.setEnabled(mBassBoost.getStrengthSupported());
                    }
                }
            } else {
                if (mBassBoost != null) {
                    mStrength.setEnabled(false);
                    putEffect(sSession);
                }
            }
        }
    
public voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);

        SeekBar seekBar;
        TextView textView;

        setContentView(R.layout.bassboosttest);

        mSessionText = (EditText) findViewById(R.id.sessionEdit);
        mSessionText.setOnKeyListener(mSessionKeyListener);

        mSessionText.setText(Integer.toString(sSession));

        mReleaseButton = (ToggleButton)findViewById(R.id.bbReleaseButton);
        mOnOffButton = (ToggleButton)findViewById(R.id.bassboostOnOff);

        getEffect(sSession);

        if (mBassBoost != null) {
            mReleaseButton.setOnCheckedChangeListener(this);
            mOnOffButton.setOnCheckedChangeListener(this);

            textView = (TextView)findViewById(R.id.bbStrengthMin);
            textView.setText("0");
            textView = (TextView)findViewById(R.id.bbStrengthMax);
            textView.setText("1000");
            seekBar = (SeekBar)findViewById(R.id.bbStrengthSeekBar);
            textView = (TextView)findViewById(R.id.bbStrengthValue);
            mStrength = new BassBoostParam(mBassBoost, 0, 1000, seekBar, textView);
            seekBar.setOnSeekBarChangeListener(mStrength);
            mStrength.setEnabled(mBassBoost.getStrengthSupported());
        }
    
public voidonPause()

        super.onPause();
    
public voidonResume()

        super.onResume();
    
private voidputEffect(int session)

        mOnOffButton.setChecked(false);
        mOnOffButton.setEnabled(false);
        synchronized (sInstances) {
            if (mBassBoost != null) {
                mSettings = mBassBoost.getProperties().toString();
                mBassBoost.release();
                Log.d(TAG,"BassBoost released");
                mBassBoost = null;
                sInstances.remove(session);
            }
        }