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