feat: implemented new API getLyricsBySongId for retrieving (synced) song lyrics based on song ID

This commit is contained in:
CappielloAntonio 2024-02-17 23:43:02 +01:00
parent b9462d7374
commit 54be869081
11 changed files with 197 additions and 0 deletions

View file

@ -0,0 +1,37 @@
package com.cappielloantonio.tempo.repository;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.tempo.App;
import com.cappielloantonio.tempo.subsonic.base.ApiResponse;
import com.cappielloantonio.tempo.subsonic.models.LyricsList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class OpenRepository {
public MutableLiveData<LyricsList> getLyricsBySongId(String id) {
MutableLiveData<LyricsList> lyricsList = new MutableLiveData<>();
App.getSubsonicClientInstance(false)
.getOpenClient()
.getLyricsBySongId(id)
.enqueue(new Callback<ApiResponse>() {
@Override
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getLyricsList() != null) {
lyricsList.setValue(response.body().getSubsonicResponse().getLyricsList());
}
}
@Override
public void onFailure(@NonNull Call<ApiResponse> call, @NonNull Throwable t) {
}
});
return lyricsList;
}
}