diff --git a/app/src/main/java/com/cappielloantonio/tempo/repository/ScanRepository.java b/app/src/main/java/com/cappielloantonio/tempo/repository/ScanRepository.java index a674540e..5beb4c6d 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/repository/ScanRepository.java +++ b/app/src/main/java/com/cappielloantonio/tempo/repository/ScanRepository.java @@ -17,8 +17,12 @@ public class ScanRepository { .enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) { - if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getScanStatus() != null) { - callback.onSuccess(response.body().getSubsonicResponse().getScanStatus().isScanning(), response.body().getSubsonicResponse().getScanStatus().getCount()); + if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse() != null) { + if (response.body().getSubsonicResponse().getError() != null) { + callback.onError(new Exception(response.body().getSubsonicResponse().getError().getMessage())); + } else if (response.body().getSubsonicResponse().getScanStatus() != null) { + callback.onSuccess(response.body().getSubsonicResponse().getScanStatus().isScanning(), response.body().getSubsonicResponse().getScanStatus().getCount()); + } } } @@ -36,8 +40,12 @@ public class ScanRepository { .enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) { - if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getScanStatus() != null) { - callback.onSuccess(response.body().getSubsonicResponse().getScanStatus().isScanning(), response.body().getSubsonicResponse().getScanStatus().getCount()); + if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse() != null) { + if (response.body().getSubsonicResponse().getError() != null) { + callback.onError(new Exception(response.body().getSubsonicResponse().getError().getMessage())); + } else if (response.body().getSubsonicResponse().getScanStatus() != null) { + callback.onSuccess(response.body().getSubsonicResponse().getScanStatus().isScanning(), response.body().getSubsonicResponse().getScanStatus().getCount()); + } } } diff --git a/app/src/main/java/com/cappielloantonio/tempo/repository/SystemRepository.java b/app/src/main/java/com/cappielloantonio/tempo/repository/SystemRepository.java index 0a91c175..4dc1dea4 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/repository/SystemRepository.java +++ b/app/src/main/java/com/cappielloantonio/tempo/repository/SystemRepository.java @@ -22,7 +22,7 @@ public class SystemRepository { public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) { if (response.body() != null) { if (response.body().getSubsonicResponse().getStatus().equals(ResponseStatus.FAILED)) { - callback.onError(new Exception(response.body().getSubsonicResponse().getError().getCode().getValue() + " - " + response.body().getSubsonicResponse().getError().getMessage())); + callback.onError(new Exception(response.body().getSubsonicResponse().getError().getCode() + " - " + response.body().getSubsonicResponse().getError().getMessage())); } else if (response.body().getSubsonicResponse().getStatus().equals(ResponseStatus.OK)) { String password = response.raw().request().url().queryParameter("p"); String token = response.raw().request().url().queryParameter("t"); diff --git a/app/src/main/java/com/cappielloantonio/tempo/subsonic/models/Error.kt b/app/src/main/java/com/cappielloantonio/tempo/subsonic/models/Error.kt index 9ee39ec4..f50b8c4f 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/subsonic/models/Error.kt +++ b/app/src/main/java/com/cappielloantonio/tempo/subsonic/models/Error.kt @@ -4,6 +4,6 @@ import androidx.annotation.Keep @Keep class Error { - var code: ErrorCode? = null + var code: Int? = null var message: String? = null } \ No newline at end of file