use of org.moire.ultrasonic.service.DownloadService in project ultrasonic by ultrasonic.
the class SettingsFragment method setCacheLocation.
private void setCacheLocation(String path) {
File dir = new File(path);
if (!FileUtil.ensureDirectoryExistsAndIsReadWritable(dir)) {
Util.toast(getActivity(), R.string.settings_cache_location_error, false);
// Reset it to the default.
String defaultPath = FileUtil.getDefaultMusicDirectory().getPath();
if (!defaultPath.equals(path)) {
Util.getPreferences(getActivity()).edit().putString(Constants.PREFERENCES_KEY_CACHE_LOCATION, defaultPath).apply();
cacheLocation.setSummary(defaultPath);
cacheLocation.setText(defaultPath);
}
// Clear download queue.
DownloadService downloadService = DownloadServiceImpl.getInstance();
downloadService.clear();
}
}
use of org.moire.ultrasonic.service.DownloadService in project ultrasonic by ultrasonic.
the class EqualizerActivity method setup.
private void setup() {
DownloadService instance = DownloadServiceImpl.getInstance();
if (instance == null) {
return;
}
equalizerController = instance.getEqualizerController();
equalizer = equalizerController.getEqualizer();
initEqualizer();
final View presetButton = findViewById(R.id.equalizer_preset);
registerForContextMenu(presetButton);
presetButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
presetButton.showContextMenu();
}
});
CheckBox enabledCheckBox = (CheckBox) findViewById(R.id.equalizer_enabled);
enabledCheckBox.setChecked(equalizer.getEnabled());
enabledCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
setEqualizerEnabled(b);
}
});
}
use of org.moire.ultrasonic.service.DownloadService in project ultrasonic by ultrasonic.
the class MainActivity method setActiveServer.
private void setActiveServer(final int instance) {
final DownloadService service = getDownloadService();
if (Util.getActiveServer(this) != instance) {
if (service != null) {
service.clearIncomplete();
}
}
Util.setActiveServer(this, instance);
if (service != null) {
service.setJukeboxEnabled(Util.getJukeboxEnabled(this, instance));
}
}
use of org.moire.ultrasonic.service.DownloadService in project ultrasonic by ultrasonic.
the class SubsonicTabActivity method showNowPlaying.
public void showNowPlaying() {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
new SilentBackgroundTask<Void>(SubsonicTabActivity.this) {
@Override
protected Void doInBackground() throws Throwable {
if (!Util.getShowNowPlayingPreference(SubsonicTabActivity.this)) {
hideNowPlaying();
return null;
}
nowPlayingView = findViewById(R.id.now_playing);
if (nowPlayingView != null) {
final DownloadService downloadService = DownloadServiceImpl.getInstance();
if (downloadService != null) {
PlayerState playerState = downloadService.getPlayerState();
if (playerState.equals(PlayerState.PAUSED) || playerState.equals(PlayerState.STARTED)) {
DownloadFile file = downloadService.getCurrentPlaying();
if (file != null) {
final Entry song = file.getSong();
showNowPlaying(SubsonicTabActivity.this, downloadService, song, playerState);
}
} else {
hideNowPlaying();
}
}
}
return null;
}
@Override
protected void done(Void result) {
}
}.execute();
}
});
}
use of org.moire.ultrasonic.service.DownloadService in project ultrasonic by ultrasonic.
the class SubsonicTabActivity method getDownloadService.
public DownloadService getDownloadService() {
// If service is not available, request it to start and wait for it.
for (int i = 0; i < 5; i++) {
DownloadService downloadService = DownloadServiceImpl.getInstance();
if (downloadService != null) {
return downloadService;
}
Log.w(TAG, "DownloadService not running. Attempting to start it.");
startService(new Intent(this, DownloadServiceImpl.class));
Util.sleepQuietly(50L);
}
return DownloadServiceImpl.getInstance();
}
Aggregations