mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Added ability to scan library in SettingsFragment
This commit is contained in:
parent
0c30e95c31
commit
c1d10e6ed0
11 changed files with 239 additions and 22 deletions
|
|
@ -3,6 +3,7 @@ package com.cappielloantonio.play.subsonic;
|
|||
import com.cappielloantonio.play.subsonic.api.albumsonglist.AlbumSongListClient;
|
||||
import com.cappielloantonio.play.subsonic.api.browsing.BrowsingClient;
|
||||
import com.cappielloantonio.play.subsonic.api.mediaannotation.MediaAnnotationClient;
|
||||
import com.cappielloantonio.play.subsonic.api.medialibraryscanning.MediaLibraryScanningClient;
|
||||
import com.cappielloantonio.play.subsonic.api.mediaretrieval.MediaRetrievalClient;
|
||||
import com.cappielloantonio.play.subsonic.api.playlist.PlaylistClient;
|
||||
import com.cappielloantonio.play.subsonic.api.searching.SearchingClient;
|
||||
|
|
@ -25,6 +26,7 @@ public class Subsonic {
|
|||
private SearchingClient searchingClient;
|
||||
private AlbumSongListClient albumSongListClient;
|
||||
private MediaAnnotationClient mediaAnnotationClient;
|
||||
private MediaLibraryScanningClient mediaLibraryScanningClient;
|
||||
|
||||
public Subsonic(SubsonicPreferences preferences) {
|
||||
this.preferences = preferences;
|
||||
|
|
@ -83,6 +85,13 @@ public class Subsonic {
|
|||
return mediaAnnotationClient;
|
||||
}
|
||||
|
||||
public MediaLibraryScanningClient getMediaLibraryScanningClient() {
|
||||
if (mediaLibraryScanningClient == null) {
|
||||
mediaLibraryScanningClient = new MediaLibraryScanningClient(this);
|
||||
}
|
||||
return mediaLibraryScanningClient;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
String url = preferences.getServerUrl() + "/rest/";
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.cappielloantonio.play.subsonic.api.medialibraryscanning;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.api.system.SystemService;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class MediaLibraryScanningClient {
|
||||
private static final String TAG = "SystemClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private MediaLibraryScanningService mediaLibraryScanningService;
|
||||
|
||||
public MediaLibraryScanningClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
.baseUrl(subsonic.getUrl())
|
||||
.addConverterFactory(TikXmlConverterFactory.create())
|
||||
.client(getOkHttpClient())
|
||||
.build();
|
||||
|
||||
this.mediaLibraryScanningService = retrofit.create(MediaLibraryScanningService.class);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> startScan() {
|
||||
Log.d(TAG, "startScan()");
|
||||
return mediaLibraryScanningService.startScan(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getScanStatus() {
|
||||
Log.d(TAG, "getScanStatus()");
|
||||
return mediaLibraryScanningService.getScanStatus(subsonic.getParams());
|
||||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
private HttpLoggingInterceptor getHttpLoggingInterceptor() {
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.cappielloantonio.play.subsonic.api.medialibraryscanning;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface MediaLibraryScanningService {
|
||||
@GET("startScan")
|
||||
Call<SubsonicResponse> startScan(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getScanStatus")
|
||||
Call<SubsonicResponse> getScanStatus(@QueryMap Map<String, String> params);
|
||||
}
|
||||
|
|
@ -1,39 +1,27 @@
|
|||
package com.cappielloantonio.play.subsonic.models;
|
||||
|
||||
public class ScanStatus {
|
||||
protected boolean scanning;
|
||||
protected Long count;
|
||||
import com.tickaroo.tikxml.annotation.Attribute;
|
||||
import com.tickaroo.tikxml.annotation.Xml;
|
||||
|
||||
/**
|
||||
* Gets the value of the scanning property.
|
||||
*/
|
||||
@Xml
|
||||
public class ScanStatus {
|
||||
@Attribute
|
||||
protected boolean scanning;
|
||||
@Attribute
|
||||
protected Long count;
|
||||
|
||||
public boolean isScanning() {
|
||||
return scanning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the scanning property.
|
||||
*/
|
||||
public void setScanning(boolean value) {
|
||||
this.scanning = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the count property.
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link Long }
|
||||
*/
|
||||
public Long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the count property.
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link Long }
|
||||
*/
|
||||
public void setCount(Long value) {
|
||||
this.count = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tickaroo.tikxml.annotation.Xml;
|
|||
public class SubsonicResponse {
|
||||
@Element
|
||||
private Error error;
|
||||
@Element(name = "scanStatus")
|
||||
private ScanStatus scanStatus;
|
||||
@Element(name = "topSongs")
|
||||
private TopSongs topSongs;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue