settings - allow testing connection while offline
This commit is contained in:
parent
a72f978001
commit
e4456ef62a
|
@ -3,6 +3,7 @@ Changelog
|
||||||
|
|
||||||
## Next
|
## Next
|
||||||
* Fix pausing playback on disconnect on API 26+
|
* Fix pausing playback on disconnect on API 26+
|
||||||
|
* Allow testing connection in settings while offline
|
||||||
|
|
||||||
|
|
||||||
## Version 0.2.4
|
## Version 0.2.4
|
||||||
|
|
|
@ -650,7 +650,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
|
||||||
|
|
||||||
previousInstance = Util.getActiveServer(context);
|
previousInstance = Util.getActiveServer(context);
|
||||||
testingConnection = true;
|
testingConnection = true;
|
||||||
MusicService musicService = MusicServiceFactory.getMusicService(context);
|
MusicService musicService = MusicServiceFactory.getOnlineService();
|
||||||
try {
|
try {
|
||||||
musicService.setInstance(instance);
|
musicService.setInstance(instance);
|
||||||
musicService.ping(context, this);
|
musicService.ping(context, this);
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Subsonic.
|
|
||||||
|
|
||||||
Subsonic is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Subsonic is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Copyright 2009 (C) Sindre Mehus
|
|
||||||
*/
|
|
||||||
package net.nullsum.audinaut.service;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import net.nullsum.audinaut.util.Util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Sindre Mehus
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class MusicServiceFactory {
|
|
||||||
|
|
||||||
private static final MusicService REST_MUSIC_SERVICE = new CachedMusicService(new RESTMusicService());
|
|
||||||
private static final MusicService OFFLINE_MUSIC_SERVICE = new OfflineMusicService();
|
|
||||||
|
|
||||||
public static MusicService getMusicService(Context context) {
|
|
||||||
return Util.isOffline(context) ? OFFLINE_MUSIC_SERVICE : REST_MUSIC_SERVICE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package net.nullsum.audinaut.service
|
||||||
|
|
||||||
|
import net.nullsum.audinaut.util.Util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
|
||||||
|
object MusicServiceFactory {
|
||||||
|
@JvmStatic
|
||||||
|
val onlineService: MusicService = CachedMusicService(RESTMusicService())
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val offlineService: MusicService = OfflineMusicService()
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getMusicService(context: Context) : MusicService {
|
||||||
|
return if (Util.isOffline(context)) offlineService else onlineService
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue