removed threads from mpdcontroller

This commit is contained in:
Lucas Pleß 2012-06-15 09:33:15 +02:00
parent 28989f2511
commit da3aef9704
1 changed files with 49 additions and 82 deletions

View File

@ -41,9 +41,7 @@ public class MPDController implements IMPDController {
@Override @Override
public void playSong(final String artist, final String title) { public void playSong(final String artist, final String title) {
if(mpd != null) { if(mpd != null) {
Runnable r = new Runnable() {
@Override
public void run() {
addToPlayListIfNeeded(artist, title); addToPlayListIfNeeded(artist, title);
try { try {
@ -68,12 +66,7 @@ public class MPDController implements IMPDController {
} catch (MPDPlayerException e) { } catch (MPDPlayerException e) {
Logger.sLog("MPD error: " + e.getMessage()); Logger.sLog("MPD error: " + e.getMessage());
} }
}
};
synchronized (lockObject) {
new Thread(r).start();
}
} }
} }
@ -85,9 +78,7 @@ public class MPDController implements IMPDController {
@Override @Override
public void addToPlayList(final String artist, final String title) { public void addToPlayList(final String artist, final String title) {
if(mpd != null) { if(mpd != null) {
Runnable r = new Runnable() {
@Override
public void run() {
MPDDatabase db = mpd.getMPDDatabase(); MPDDatabase db = mpd.getMPDDatabase();
MPDPlaylist playlist = mpd.getMPDPlaylist(); MPDPlaylist playlist = mpd.getMPDPlaylist();
@ -108,12 +99,6 @@ public class MPDController implements IMPDController {
Logger.sLog("MPD error: " + e.getMessage()); Logger.sLog("MPD error: " + e.getMessage());
} }
} }
};
synchronized (lockObject) {
new Thread(r).start();
}
}
} }
/** /**
@ -123,9 +108,6 @@ public class MPDController implements IMPDController {
@Override @Override
public void setVolume(final int volume) { public void setVolume(final int volume) {
if(mpd != null) { if(mpd != null) {
Runnable r = new Runnable() {
@Override
public void run() {
try { try {
mpd.getMPDPlayer().setVolume(volume); mpd.getMPDPlayer().setVolume(volume);
} catch (MPDConnectionException e) { } catch (MPDConnectionException e) {
@ -134,12 +116,6 @@ public class MPDController implements IMPDController {
Logger.sLog("MPD error: " + e.getMessage()); Logger.sLog("MPD error: " + e.getMessage());
} }
} }
};
synchronized (lockObject) {
new Thread(r).start();
}
}
} }
/** /**
@ -148,9 +124,6 @@ public class MPDController implements IMPDController {
@Override @Override
public void clearPlaylist() { public void clearPlaylist() {
if(mpd != null) { if(mpd != null) {
Runnable r = new Runnable() {
@Override
public void run() {
try { try {
MPDPlaylist playlist = mpd.getMPDPlaylist(); MPDPlaylist playlist = mpd.getMPDPlaylist();
playlist.clearPlaylist(); playlist.clearPlaylist();
@ -164,12 +137,6 @@ public class MPDController implements IMPDController {
Logger.sLog("MPD error: " + e.getMessage()); Logger.sLog("MPD error: " + e.getMessage());
} }
} }
};
synchronized (lockObject) {
new Thread(r).start();
}
}
} }
private void addToPlayListIfNeeded(final String artist, final String title) { private void addToPlayListIfNeeded(final String artist, final String title) {