mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 18:31:40 +00:00
Reinforced response checks on ScanRepository
This commit is contained in:
parent
68930a19a4
commit
1dac0afa6f
1 changed files with 9 additions and 9 deletions
|
|
@ -2,10 +2,10 @@ package com.cappielloantonio.play.repository;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.cappielloantonio.play.App;
|
import com.cappielloantonio.play.App;
|
||||||
import com.cappielloantonio.play.interfaces.ScanCallback;
|
import com.cappielloantonio.play.interfaces.ScanCallback;
|
||||||
import com.cappielloantonio.play.interfaces.SystemCallback;
|
|
||||||
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
|
||||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
|
|
@ -14,7 +14,7 @@ import retrofit2.Callback;
|
||||||
public class ScanRepository {
|
public class ScanRepository {
|
||||||
private static final String TAG = "SongRepository";
|
private static final String TAG = "SongRepository";
|
||||||
|
|
||||||
private Application application;
|
private final Application application;
|
||||||
|
|
||||||
public ScanRepository(Application application) {
|
public ScanRepository(Application application) {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
|
|
@ -26,14 +26,14 @@ public class ScanRepository {
|
||||||
.startScan()
|
.startScan()
|
||||||
.enqueue(new Callback<SubsonicResponse>() {
|
.enqueue(new Callback<SubsonicResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<SubsonicResponse> call, retrofit2.Response<SubsonicResponse> response) {
|
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull retrofit2.Response<SubsonicResponse> response) {
|
||||||
if (response.body().getScanStatus() != null) {
|
if (response.isSuccessful() && response.body() != null && response.body().getScanStatus() != null) {
|
||||||
callback.onSuccess(response.body().getScanStatus().isScanning(), response.body().getScanStatus().getCount());
|
callback.onSuccess(response.body().getScanStatus().isScanning(), response.body().getScanStatus().getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
public void onFailure(@NonNull Call<SubsonicResponse> call, @NonNull Throwable t) {
|
||||||
callback.onError(new Exception(t.getMessage()));
|
callback.onError(new Exception(t.getMessage()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -45,14 +45,14 @@ public class ScanRepository {
|
||||||
.startScan()
|
.startScan()
|
||||||
.enqueue(new Callback<SubsonicResponse>() {
|
.enqueue(new Callback<SubsonicResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<SubsonicResponse> call, retrofit2.Response<SubsonicResponse> response) {
|
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull retrofit2.Response<SubsonicResponse> response) {
|
||||||
if (response.body().getScanStatus() != null) {
|
if (response.isSuccessful() && response.body() != null && response.body().getScanStatus() != null) {
|
||||||
callback.onSuccess(response.body().getScanStatus().isScanning(), response.body().getScanStatus().getCount());
|
callback.onSuccess(response.body().getScanStatus().isScanning(), response.body().getScanStatus().getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
public void onFailure(@NonNull Call<SubsonicResponse> call, @NonNull Throwable t) {
|
||||||
callback.onError(new Exception(t.getMessage()));
|
callback.onError(new Exception(t.getMessage()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue