Methods Summary |
---|
private void | displayVal(int viewId, int val)
TextView textView = (TextView)findViewById(viewId);
String text = Integer.toString(val);
textView.setText(text);
|
private void | getEffect(int session)
synchronized (sInstances) {
if (sInstances.containsKey(session)) {
mVisualizer = sInstances.get(session);
} else {
try{
mVisualizer = new Visualizer(session);
} catch (UnsupportedOperationException e) {
Log.e(TAG,"Visualizer library not loaded");
throw (new RuntimeException("Cannot initialize effect"));
} catch (RuntimeException e) {
throw e;
}
sInstances.put(session, mVisualizer);
}
}
mReleaseButton.setEnabled(false);
mOnOffButton.setEnabled(false);
if (mVisualizer != null) {
mCaptureSize = mVisualizer.getCaptureSize();
mReleaseButton.setChecked(true);
mReleaseButton.setEnabled(true);
mEnabled = mVisualizer.getEnabled();
mOnOffButton.setChecked(mEnabled);
mOnOffButton.setEnabled(true);
mCallbackButton.setEnabled(!mEnabled);
}
|
public void | onCheckedChanged(android.widget.CompoundButton buttonView, boolean isChecked)
// OnCheckedChangeListener
if (buttonView.getId() == R.id.visualizerOnOff) {
if (mVisualizer != null) {
mEnabled = isChecked;
mCallbackButton.setEnabled(!mEnabled);
if (mCallbackOn && mEnabled) {
mVisualizer.setDataCaptureListener(mVisualizerListener,
10000,
true,
true);
}
mVisualizer.setEnabled(mEnabled);
if (mCallbackOn) {
if (!mEnabled) {
mVisualizer.setDataCaptureListener(null,
10000,
false,
false);
}
} else {
int msg = isChecked ? MSG_START_CAPTURE : MSG_STOP_CAPTURE;
mVisualizerTestHandler.sendMessage(
mVisualizerTestHandler.obtainMessage(msg, 0, 0, null));
}
}
}
if (buttonView.getId() == R.id.visuReleaseButton) {
if (isChecked) {
if (mVisualizer == null) {
getEffect(sSession);
}
} else {
if (mVisualizer != null) {
putEffect(sSession);
}
}
}
if (buttonView.getId() == R.id.visuCallbackOnOff) {
mCallbackOn = isChecked;
}
|
public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
TextView textView;
setContentView(R.layout.visualizertest);
mSessionText = (EditText) findViewById(R.id.sessionEdit);
mSessionText.setOnKeyListener(mSessionKeyListener);
mSessionText.setText(Integer.toString(sSession));
mReleaseButton = (ToggleButton)findViewById(R.id.visuReleaseButton);
mOnOffButton = (ToggleButton)findViewById(R.id.visualizerOnOff);
mCallbackButton = (ToggleButton)findViewById(R.id.visuCallbackOnOff);
mCallbackOn = false;
mCallbackButton.setChecked(mCallbackOn);
mVisualizerTestHandler = new VisualizerTestHandler();
mVisualizerListener = new VisualizerListener();
getEffect(sSession);
if (mVisualizer != null) {
mReleaseButton.setOnCheckedChangeListener(this);
mOnOffButton.setOnCheckedChangeListener(this);
mCallbackButton.setOnCheckedChangeListener(this);
}
|
public void | onPause()
super.onPause();
|
public void | onResume()
super.onResume();
|
private void | putEffect(int session)
mOnOffButton.setChecked(false);
mOnOffButton.setEnabled(false);
synchronized (sInstances) {
if (mVisualizer != null) {
mVisualizer.release();
Log.d(TAG,"Visualizer released");
mVisualizer = null;
sInstances.remove(session);
}
}
|