Exemplo n.º 1
0
 @Override
 public boolean onKey(View v, int keyCode, KeyEvent event) {
   // If key arrives immediately after the activity has been cleaned up.
   if (volumizers.isEmpty()) return true;
   boolean isdown = event.getAction() == KeyEvent.ACTION_DOWN;
   switch (keyCode) {
     case KeyEvent.KEYCODE_VOLUME_DOWN:
       if (isdown) {
         activeVolumizer.changeVolumeBy(-1);
       }
       return true;
     case KeyEvent.KEYCODE_VOLUME_UP:
       if (isdown) {
         activeVolumizer.changeVolumeBy(1);
       }
       return true;
     case KeyEvent.KEYCODE_VOLUME_MUTE:
       if (isdown) {
         activeVolumizer.muteVolume();
       }
       return true;
     default:
       return false;
   }
 }
Exemplo n.º 2
0
 @Override
 public void onSampleStarting(SeekBarVolumizer requestedVolumizer) {
   // We stop all volumizers other than the given one
   for (SeekBarVolumizer volumizer : volumizers) {
     if (!volumizer.equals(requestedVolumizer)) {
       volumizer.stopSample();
     }
   }
   // key events will be handled by the volumizer that is currently active
   activeVolumizer = requestedVolumizer;
 }
Exemplo n.º 3
0
  /** Do clean up. This can be called multiple times! */
  private void cleanup() {
    // getPreferenceManager().unregisterOnActivityStopListener(this);

    Dialog dialog = getDialog();
    if (dialog != null && dialog.isShowing()) {
      View view =
          dialog.getWindow().getDecorView().findViewById(R.id.seekbar_dialog_seekbar_master_volume);
      if (view != null) {
        view.setOnKeyListener(null);
      }
      // TODO ? Stopped while dialog was showing, revert changes
    }
    for (SeekBarVolumizer volumizer : volumizers) {
      volumizer.stopSample();
      volumizer.mSeekBar.setOnSeekBarChangeListener(null);
    }
    volumizers.clear();
    activeVolumizer = null;
  }