mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Added Subsonic client singleton
This commit is contained in:
parent
702b454bf6
commit
4053500080
1 changed files with 20 additions and 0 deletions
|
|
@ -7,6 +7,8 @@ import android.content.SharedPreferences;
|
|||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.cappielloantonio.play.helper.ThemeHelper;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.SubsonicPreferences;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import org.jellyfin.apiclient.AppInfo;
|
||||
|
|
@ -23,6 +25,7 @@ public class App extends Application {
|
|||
private static final String TAG = "App";
|
||||
private static App instance;
|
||||
private static ApiClient apiClient;
|
||||
private static Subsonic subsonic;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
|
@ -60,4 +63,21 @@ public class App extends Application {
|
|||
|
||||
return jellyfin.createApi(server, null, AndroidDevice.fromContext(context), new ApiEventListener());
|
||||
}
|
||||
|
||||
public static Subsonic getSubsonicClientInstance(Context context) {
|
||||
if (subsonic == null) {
|
||||
subsonic = getSubsonicClient(context);
|
||||
}
|
||||
return subsonic;
|
||||
}
|
||||
|
||||
private static Subsonic getSubsonicClient(Context context) {
|
||||
String server = PreferenceUtil.getInstance(context).getServer();
|
||||
String username = PreferenceUtil.getInstance(context).getUser();
|
||||
String password = PreferenceUtil.getInstance(context).getPassword();
|
||||
|
||||
SubsonicPreferences preferences = new SubsonicPreferences(server, username, password);
|
||||
|
||||
return new Subsonic(preferences);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue