mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Add dialog when server is unreachable
This commit is contained in:
parent
652aa1426d
commit
33512eec2d
6 changed files with 141 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ package com.cappielloantonio.play.repository;
|
|||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.interfaces.SystemCallback;
|
||||
|
|
@ -11,6 +12,7 @@ import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
|||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class SystemRepository {
|
||||
private static final String TAG = "SongRepository";
|
||||
|
|
@ -49,4 +51,27 @@ public class SystemRepository {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<Boolean> ping() {
|
||||
MutableLiveData<Boolean> pingResult = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getSystemClient()
|
||||
.ping()
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
pingResult.postValue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<SubsonicResponse> call, @NonNull Throwable t) {
|
||||
pingResult.postValue(false);
|
||||
}
|
||||
});
|
||||
|
||||
return pingResult;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue