Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Ima init all mah importantz stuffs 'ere
- */
- public void initMyAwesomeShit() {
- // first we makez our dialogz and shiet
- volumeDialog = new Dialog(ComediaTestActivity.this,
- com.comedia.use.R.style.Volume_Dialog);
- volumeDialog.getWindow().getAttributes().y = screenHeight / 2;
- // da key listenah
- volumeDialog.setContentView(com.comedia.use.R.layout.seekbar);
- volumeDialog.setCancelable(true);
- volumeDialog.setOnKeyListener(new OnKeyListener() {
- // wat to do on da key press man
- @Override
- public boolean onKey(DialogInterface dialog, int keyCode,
- KeyEvent event) {
- //SSSHIIIIIETTT
- // 22 je RIGHT
- // 21 je left
- Log.e("LOG_TAG", "\n\n\tKEY CODEEEEEEEE\n"+keyCode);
- if (keyCode == 136) {
- Log.e("LOG_TAG", "VOLUME UP");
- try {
- double currentVolume = service.getAudioControl()
- .getCurrentVolume(liveRouteID);
- double nextVolume = currentVolume + 1;
- if (nextVolume > 100) {
- nextVolume = 100;
- }
- if (!service.getAudioControl().setCurrentVolume(
- liveRouteID, nextVolume)) {
- Log.e("LOG_TAG", "Error setting volume");
- }
- setVolume((int) nextVolume);
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return true;
- } else if (keyCode == 135) {
- Log.e("LOG_TAG", "VOLUME DOWN");
- try {
- double currentVolume = service.getAudioControl()
- .getCurrentVolume(liveRouteID);
- double nextVolume = currentVolume - 1;
- if (nextVolume < 0) {
- nextVolume = 0;
- }
- if (!service.getAudioControl().setCurrentVolume(
- liveRouteID, nextVolume)) {
- Log.e("LOG_TAG", "Error setting volume");
- }
- setVolume((int) nextVolume);
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return false;
- }
- });
- volumeBar = (SeekBar) volumeDialog
- .findViewById(com.comedia.use.R.id.seek_bar);
- volumeBar.setMax(100);
- volumeBar.setProgress(50);
- volumeBar.setFocusable(false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement